Repository navigation
fix(auth): require an authorization code on the confidential OIDC callback - #35679
mohityadav766 wants to merge 2 commits into
Conversation
…lback Establish the login session only from the ID token the back-channel token exchange returns. Require the authorization code on the callback and reject a request that carries only a front-channel token.
❌ PR checklist incompleteThis PR cannot be merged until the following are addressed on its linked issue:
The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically. Maintainers can bypass this check by adding the |
|
✅ SSO Login Nightly — PASSED View workflow run · Commit
Totals: 94 passed · 0 failed · 0 flaky · 0 skipped · duration 18m 39s |
Require an authorization code only when the configured response_type is a code flow (plain or hybrid), so a deployment set to a pure implicit response_type is not rejected. Cover the callback rejection end-to-end and the response_type handling with tests.
Code Review ✅ Approved 3 closed / 3 findings🔴 High risk · Requiring a code on confidential OIDC callbacks changes authentication decisions; providers returning incompatible responses could block legitimate logins. Hardens the confidential OIDC callback to require an authorization code and establish sessions only from the back-channel ID token. Resolved findings: confidential clients with ✅ 3 closed✅ Edge Case: Confidential clients set to responseType id_token now fail every login
✅ Quality: New rule "confidential login only via back-channel ID token" is unrecorded
✅ Quality: Tests call the private guard by reflection, not the callback
VerificationRules No rules evaluated Functional validation Not enabledAuto-approval Not enabledFor more verification details, comment OptionsDisplay: compact → Showing compact verification results. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
| } | ||
|
|
||
| private void requireAuthorizationCode(UserSession session, OidcCredentials credentials) { | ||
| if (expectsAuthorizationCode() && credentials.getCode() == null) { |
There was a problem hiding this comment.
When responseType is id_token, the new expectsAuthorizationCode() exemption lets a token-only callback skip the token exchange. handleCallback then reads the supplied token’s claims without checking its signature and uses them to select a user and activate a session. Someone can start login, copy the state and nonce from the login redirect, and submit a forged token naming another user.
Keep the authorization-code requirement for this handler, or verify front-channel tokens before trusting their claims.
How this was verified: The exempt callback copies the supplied token into credentials, skips the code exchange, and passes its unchecked claims through user lookup to session activation.
Knowledge Base Used: Platform security and governance
Summary
Harden the confidential OIDC login callback so the session is established only from the ID token returned by the back-channel token exchange. The callback now requires an authorization code and rejects a request that carries only a front-channel token.
Fixes #
Tests
AuthenticationCodeFlowHandlerTestfor the callback with, and without, an authorization code.mvn -pl openmetadata-service -am ... -Dtest=AuthenticationCodeFlowHandlerTest package→ green (85 tests).🤖 Generated with Claude Code
The PR should not merge until implicit callbacks cannot create sessions from forged identity claims.
Findings
Summary
The PR requires an authorization code before exchanging tokens for code-based OIDC login.
Diagram
%%{init: {'theme': 'neutral'}}%% flowchart TD A[OIDC callback] --> B{Configured response type includes code?} B -->|Yes| C{Authorization code present?} C -->|No| D[Reject with HTTP 400] C -->|Yes| E[Exchange code with provider] B -->|No| F[Keep browser-supplied token] E --> G[Read identity claims] F --> G G --> H[Find user and activate session]Reviews (2) · Last reviewed commit: "fix(auth): scope the callback code requi..." · Reviewed by Greptile