-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #38 from DavidBuchanan314/token-revocation
refreshSession, deleteSession
- Loading branch information
Showing
8 changed files
with
304 additions
and
74 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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,34 @@ | ||
# TODO: some smarter way of handling migrations | ||
|
||
import apsw | ||
import apsw.bestpractice | ||
|
||
apsw.bestpractice.apply(apsw.bestpractice.recommended) | ||
|
||
from millipds import static_config | ||
|
||
|
||
def migrate(con: apsw.Connection): | ||
version_now, *_ = con.execute("SELECT db_version FROM config").fetchone() | ||
|
||
assert version_now == 2 | ||
|
||
con.execute( | ||
""" | ||
CREATE TABLE revoked_token( | ||
did TEXT NOT NULL, | ||
jti TEXT NOT NULL, | ||
expires_at INTEGER NOT NULL, | ||
PRIMARY KEY (did, jti) | ||
) STRICT, WITHOUT ROWID | ||
""" | ||
) | ||
|
||
con.execute("UPDATE config SET db_version=3") | ||
|
||
|
||
if __name__ == "__main__": | ||
with apsw.Connection(static_config.MAIN_DB_PATH) as con: | ||
migrate(con) | ||
|
||
print("v2 -> v3 Migration successful") |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.