Fix OIDC authentication to support standards-compliant providers - #7
Open
tilwegener wants to merge 3 commits into
Open
tilwegener wants to merge 3 commits into
tilwegener wants to merge 3 commits into
Conversation
Refactored authentication redirection logic to use signinRedirect method and removed unused OIDC config fetching.
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
This PR removes the remaining Keycloak-specific authentication logic from the frontend and delegates the complete OIDC flow to
react-oidc-context/oidc-client-ts.The previous implementation manually constructed the authorization request and manually exchanged the authorization code for tokens. This only worked with Keycloak because the endpoints were hardcoded as:
/protocol/openid-connect/auth/protocol/openid-connect/tokenAs a result, standards-compliant OIDC providers such as Pocket ID could not authenticate successfully.
Changes
AuthGuard
auth.signinRedirect().getAuthority,getClientId,getScope).Callback Route
react-oidc-context/oidc-client-tshandle:The callback route is now only responsible for:
Why
The project already depends on
react-oidc-context, which internally usesoidc-client-tsto implement the complete Authorization Code Flow with PKCE.By bypassing the library and implementing parts of the protocol manually, the frontend became tightly coupled to Keycloak-specific endpoints and omitted parts of the PKCE flow required by other OpenID Connect providers.
Using the library as intended restores compatibility with any standards-compliant OIDC provider exposing a valid discovery document.
Benefits
Breaking Changes
None.
Existing OIDC configuration (
authority,clientId, andscope) remains unchanged.Testing