Switch ACCESS_TOKEN_EXPIRE_MINUTES to SECONDS#3096
Conversation
Greptile SummaryThis PR refactors the access token expiration constant from Key changes:
The refactor improves clarity by making the unit explicit in both the constant name and the value, and eliminates the previously implicit Confidence Score: 5/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant Client
participant AuthEndpoint as /api/token
participant OAuthHandler
Client->>AuthEndpoint: POST (grant_type=password or refresh_token)
AuthEndpoint->>OAuthHandler: create_oauth_token(expires_delta=timedelta(seconds=1800))
OAuthHandler-->>AuthEndpoint: access_token (JWT, exp = now + 1800s)
AuthEndpoint-->>Client: { access_token, token_type, expires: 1800 }
Note over AuthEndpoint: ACCESS_TOKEN_EXPIRE_SECONDS = 30 * 60 = 1800<br/>(previously ACCESS_TOKEN_EXPIRE_MINUTES = 30,<br/>used as timedelta(minutes=30) — same duration)
Last reviewed commit: 1f64e84 |
There was a problem hiding this comment.
Pull request overview
This PR standardizes the access-token expiry configuration to use seconds (instead of minutes) in the auth endpoint and updates the backend endpoint tests accordingly.
Changes:
- Renames
ACCESS_TOKEN_EXPIRE_MINUTEStoACCESS_TOKEN_EXPIRE_SECONDS(set to30 * 60) inbackend/endpoints/auth.py. - Updates
/api/tokenlogic to usetimedelta(seconds=...)and returnsexpiresdirectly as seconds. - Updates all affected endpoint tests/fixtures to import and use
ACCESS_TOKEN_EXPIRE_SECONDS, plus a small test assertion hardening intest_device.py.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| backend/endpoints/auth.py | Switches access token expiry constant to seconds and updates token issuance/response accordingly. |
| backend/tests/endpoints/conftest.py | Updates test fixtures to build access tokens with timedelta(seconds=...). |
| backend/tests/endpoints/test_oauth.py | Updates assertions and imports to use seconds-based expiry constant. |
| backend/tests/endpoints/test_identity.py | Updates token creation to use seconds-based expiry constant. |
| backend/tests/endpoints/test_device.py | Updates token fixture to seconds; adds original is not None assertion before dereference. |
| backend/tests/endpoints/test_saves.py | Updates token creation to use seconds-based expiry constant. |
| backend/tests/endpoints/roms/test_upload.py | Updates token fixture to use seconds-based expiry constant. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
☂️ Python Coverage
Overall Coverage
New FilesNo new covered files... Modified Files
|
Description
Explain the changes or enhancements you are proposing with this pull request.
Checklist
Please check all that apply.
Screenshots (if applicable)