Use code exchange for OIDC - #928
Merged
DavidMStraub merged 2 commits intoAug 11, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the OIDC flow to avoid sending tokens back to the browser via cookies, instead using a short-lived, single-use “exchange code” that the frontend redeems via /oidc/tokens/. It also adjusts CORS credentials settings accordingly.
Changes:
- Replace OIDC callback token handoff from HttpOnly cookies to a server-side cached, signed exchange code in the redirect fragment.
- Change
/oidc/tokens/from a cookie-basedGETexchange to a JSON-bodyPOSTexchange using a new Marshmallow schema. - Disable CORS
supports_credentialssince the OIDC flow no longer relies on credentialed cookie requests.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| tests/test_endpoints/test_oidc.py | Updates tests to validate code exchange behavior and absence of token leakage. |
| gramps_webapi/app.py | Disables CORS credential support (supports_credentials=False). |
| gramps_webapi/api/resources/schemas.py | Adds OIDCTokenExchangeSchema and updates token schema description for code exchange. |
| gramps_webapi/api/resources/oidc.py | Implements signed exchange code storage/redemption and switches token exchange endpoint to POST. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.
Suppressed comments (1)
gramps_webapi/api/resources/oidc.py:73
- The comment on OIDC_CODE_CACHE_TIMEOUT suggests an expired code could be reported as something other than expired and that redeemed codes remain detectable beyond the code lifetime. In practice,
_redeem_exchange_codeaborts onSignatureExpiredbefore consulting the cache/claim marker, so this comment is misleading. Please adjust the comment to match the actual behavior (valid-but-missing entry => server/cache error; valid-but-replayed => "already used").
# The cached entries outlive the code itself, so that an expired code is always
# reported as expired rather than as a missing entry, and so that a redeemed one
# is still known to have been redeemed.
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.
No description provided.