-
Notifications
You must be signed in to change notification settings - Fork 0
Auth: Magic link migrations #83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
RandyJDean
wants to merge
1
commit into
main
Choose a base branch
from
08-17-auth_magic_link_migrations
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+40
−0
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| -- Single-use sign-in tokens emailed to users. Keyed by email (not member id) | ||
| -- because the member row is only created once the link is verified. | ||
| -- Lookups only ever happen by token_hash, which the UNIQUE constraint already | ||
| -- indexes; email is read out, never searched on, so it needs no index of its own. | ||
| -- For the same reason the surrogate key is a throwaway identity int rather than a | ||
| -- UUID: nothing ever reads it back, so it only has to be unique, not meaningful. | ||
| CREATE TABLE IF NOT EXISTS "magic_link_tokens" ( | ||
| id INT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, | ||
| email TEXT NOT NULL, | ||
| token_hash TEXT UNIQUE NOT NULL, | ||
| expires_at TIMESTAMPTZ NOT NULL, | ||
| consumed_at TIMESTAMPTZ, | ||
| created_at TIMESTAMPTZ NOT NULL DEFAULT NOW() | ||
| ); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| -- Spring Session JDBC schema, copied verbatim from spring-session-jdbc's | ||
| -- org/springframework/session/jdbc/schema-postgresql.sql so Flyway owns it | ||
| -- (spring.session.jdbc.initialize-schema is set to "never" in application.yml). | ||
| CREATE TABLE SPRING_SESSION ( | ||
| PRIMARY_ID CHAR(36) NOT NULL, | ||
| SESSION_ID CHAR(36) NOT NULL, | ||
| CREATION_TIME BIGINT NOT NULL, | ||
| LAST_ACCESS_TIME BIGINT NOT NULL, | ||
| MAX_INACTIVE_INTERVAL INT NOT NULL, | ||
| EXPIRY_TIME BIGINT NOT NULL, | ||
| PRINCIPAL_NAME VARCHAR(100), | ||
| CONSTRAINT SPRING_SESSION_PK PRIMARY KEY (PRIMARY_ID) | ||
| ); | ||
|
|
||
| CREATE UNIQUE INDEX SPRING_SESSION_IX1 ON SPRING_SESSION (SESSION_ID); | ||
| CREATE INDEX SPRING_SESSION_IX2 ON SPRING_SESSION (EXPIRY_TIME); | ||
| CREATE INDEX SPRING_SESSION_IX3 ON SPRING_SESSION (PRINCIPAL_NAME); | ||
|
|
||
| CREATE TABLE SPRING_SESSION_ATTRIBUTES ( | ||
| SESSION_PRIMARY_ID CHAR(36) NOT NULL, | ||
| ATTRIBUTE_NAME VARCHAR(200) NOT NULL, | ||
| ATTRIBUTE_BYTES BYTEA NOT NULL, | ||
| CONSTRAINT SPRING_SESSION_ATTRIBUTES_PK PRIMARY KEY (SESSION_PRIMARY_ID, ATTRIBUTE_NAME), | ||
| CONSTRAINT SPRING_SESSION_ATTRIBUTES_FK FOREIGN KEY (SESSION_PRIMARY_ID) | ||
| REFERENCES SPRING_SESSION (PRIMARY_ID) ON DELETE CASCADE | ||
| ); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have any logic to delete these anywhere? Doesn't have to be now but having a bunch of single use tokens clogging the DB is not ideal.
May also be helpful to have expiry be an index as well so we can easily have some cleanup job that runs on however many expired tokens.