fix(auth): forward iss param in OIDC callback for RFC 9207 compliance#82
Open
Sanamy-ManNguyen wants to merge 1 commit intoTaskosaur:mainfrom
Open
fix(auth): forward iss param in OIDC callback for RFC 9207 compliance#82Sanamy-ManNguyen wants to merge 1 commit intoTaskosaur:mainfrom
Sanamy-ManNguyen wants to merge 1 commit intoTaskosaur:mainfrom
Conversation
Providers that set authorization_response_iss_parameter_supported=true in their discovery metadata (including Keycloak 19+) require openid-client to receive the iss authorization-response parameter during token exchange under RFC 9207. The callback controller read only code and state from the query string, so openid-client threw 'iss missing from the response' and users saw 'SSO Authentication Failed' in the UI. Thread iss from the query string through the controller into OidcService.handleCallback, and include it in the params object passed to oidcClient.callback when present. The parameter is optional so providers that do not advertise iss support continue to work. Reproduces with Keycloak 19+ using the default realm discovery. Verified fix by completing an SSO login against Keycloak 26 with authorization_response_iss_parameter_supported=true.
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.
Description
OIDC SSO login fails with
SSO Authentication Failedfor all users whose identity provider advertisesauthorization_response_iss_parameter_supported: truein its discovery document (Keycloak 19+ by default, and other OPs following RFC 9207).The backend logs show the real error:
openid-clientv5 enforces RFC 9207: when the issuer's discovery metadata declaresauthorization_response_iss_parameter_supported: true, the library validates thatissis present in the parameters passed toclient.callback(). The callback controller inauth.controller.tsonly readscodeandstatefrom the query string, soissis dropped even though the IdP sends it in the redirect. Every fresh SSO login fails.This PR threads the
issauthorization-response parameter from the callback query string throughAuthController.oidcCallbackintoOidcService.handleCallback, and includes it in the params object passed tooidcClient.callback()when present.Type of Change
Reproduction
authorization_response_iss_parameter_supportedistrue(the default).?code=...&state=...&iss=https://...but Taskosaur responds withSSO Authentication Failed.OIDC callback error: iss missing from the response.After this fix, the same flow completes successfully.
Changes
backend/src/modules/auth/auth.controller.ts— add@Query('iss') iss: stringand pass it intohandleCallback.backend/src/modules/auth/services/oidc.service.ts— accept optionaliss, build the params object conditionally so it is included only when the IdP sends it (backwards compatible with IdPs that don't advertise RFC 9207 support).backend/src/modules/auth/services/oidc.service.spec.ts— new unit tests covering:issis forwarded toopenid-clientwhen providedissis omitted when not provided (backwards compatible)issis omitted when passed as an empty stringTesting
npm run build)npx jest src/modules/auth/services/oidc.service.spec.ts— 3/3 passing)Checklist
issis optional, existing IdPs that don't advertiseauthorization_response_iss_parameter_supportedcontinue to work unchangedReferences
isswhen the issuer advertises support)