Repository navigation
fix(auth): extract refresh token field and validate JWT with secret - #19
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.
Summary
POST /refreshalways returned 401: the router passed the wholeRefreshTokenRequestmodel intoAuthService.refresh, which fed it tojwt.get_unverified_claims/jwt.decodeas if it were a raw string token. The service now reads the.refreshfield and decodes it withSECRETandALGORITHM.AuthService.refresh()covering every error branch (missing session, missing/wrong scope, missing sub, unknown user, missing/expired exp, invalid signature, database error) plus the session-rotation happy path.test_refreshexercises the full HTTP path (200 with a valid token); a garbage token is asserted to return 401.Changes
services/auth_services.pyrefresh()decodesrefresh.refreshwithSECRET/ALGORITHMinstead of the Pydantic modeltest/test_routers/test_auth.pyAuthService.refresh()branches, HTTP integration test, garbage-token 401 test; removed dead string-literal tests and the no-asserttest_refresh_token_formatTest plan
pytest -q --disable-warnings→ 169 passed (Redis up via docker compose)refresh()makes exactly its covering test(s) failtest_refresh: 401 ≠ 200) and pass with the fixdb/database.py, CORS origin) remain stashed and out of this PR