Repository navigation
fix: revoke the JWT on logout via a jti denylist - #50
Merged
Merged
Conversation
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #20.
Before this change, logout only deleted the cookie. A copy of the token taken before logout stayed valid for the rest of its 7 days.
What changes
jti.jtiand the token's expiry to a newrevoked_tokenstable. It also prunes rows that have already expired, so no scheduled job is needed. The insert isON CONFLICT DO NOTHING, so two concurrent logouts of one token don't collide.jwt_cookie_authgets arevoked_token_handlerthat rejects listed tokens, andrequire_claims=["jti"], so a token without ajtigets a 401.Design notes
test_logout_keeps_other_sessions). A token version onuserswas rejected because one logout would end every session.retrieve_user_handlerstill reads nothing, so the ADR-0010 invariant test is unchanged apart from dropping the "logout does not revoke" remark from its docstring.jtiand are rejected. The alternative was to let them through for up to 7 days without any way to revoke them.Tests
jtigets a 401.jti, so they still reach the paths they pin.just test: 123 passed, 100% coverage.just test-migrations: 4 passed.just lintandjust adr-checkare clean.