Repository navigation
fix: a login lasts a week, not a quarter of an hour - #68
Merged
Merged
Conversation
/login called create_access_token without an expiry, so every token used its 15-minute default, though auth.ACCESS_TOKEN_EXPIRE_MINUTES says 7 days. A quarter of an hour after signing in, the next request got a 401, and api.ts dropped the token and sent the browser to /login: logged out over and over. create_access_token now defaults to ACCESS_TOKEN_EXPIRE_MINUTES. The tests' client_for fixture skips authentication, so nothing caught it; test_auth.py signs in for real, checks the token lasts 7 days and works, and that a wrong password gets none. The first test fails on the old default.
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.
Why
The user kept getting logged out of Windrush.
/logincalledcreate_access_tokenwithout an expiry, so every token used its 15-minute default, thoughauth.ACCESS_TOKEN_EXPIRE_MINUTESsays 7 days. A quarter of an hour after signing in, the next request got a 401.frontend/src/app/api.tsthen dropped the token and sent the browser to/login, over and over.The signing key comes from
JWT_SECRETin.env, so API rebuilds weren't the cause.What changed
auth.create_access_tokennow defaults toACCESS_TOKEN_EXPIRE_MINUTES(7 days); an explicitexpires_deltastill wins.Tests
client_forfixture skips authentication, which is why nothing caught this. Newtests/test_auth.pysigns in for real:/persona;After deploy
Rebuild the API with
docker compose up -d --build api. A token issued before the fix still expires 15 minutes after its sign-in; the next sign-in lasts a week.