Repository navigation
Add FAPI 2.0 with DPoP to the OIDC and OAuth2 identity providers - #55204
Open
justin-tay wants to merge 1 commit into
Open
justin-tay wants to merge 1 commit into
justin-tay wants to merge 1 commit into
Conversation
Closes keycloak#51393 Signed-off-by: Justin Tay <49700559+justin-tay@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Selecting the active realm key for each DPoP proof can break login and refresh flows after key rotation because existing codes and tokens remain bound to the original key.
1 open issue
What changed in this PR
Adds DPoP-based FAPI 2.0 client support to Keycloak’s OIDC and OAuth2 identity brokers, addressing #51393. Mutual TLS support remains separate.
Changes:
- Adds pushed authorization requests, signed request objects, and DPoP proofs with nonce retries.
- Strengthens state, issuer, token signature, audience, expiration, and nonce validation.
- Adds Admin UI settings, documentation, and integration tests, and updates provider extension hooks.
| File | Description |
|---|---|
testsuite/integration-arquillian/servers/auth-server/services/testsuite-providers/src/main/java/org/keycloak/testsuite/broker/oidc/TestKeycloakOidcIdentityProviderFactory.java |
Adapts the legacy test provider to the new parameter hook. |
tests/custom-providers/src/main/resources/META-INF/services/org.keycloak.protocol.ProtocolMapper |
Registers the wrong-nonce test mapper. |
tests/custom-providers/src/main/java/org/keycloak/tests/providers/broker/oidc/WrongNonceProtocolMapper.java |
Generates incorrect nonces for rejection tests. |
tests/custom-providers/src/main/java/org/keycloak/tests/providers/broker/oidc/TestKeycloakOidcIdentityProviderFactory.java |
Adapts the test provider to the new parameter hook. |
tests/base/src/test/java/org/keycloak/tests/broker/OidcBrokerLogoutTokenTest.java |
Tests logout-token validation. |
tests/base/src/test/java/org/keycloak/tests/broker/oidc/KcOidcBrokerRequestObjectTest.java |
Tests signed request objects passed by value. |
tests/base/src/test/java/org/keycloak/tests/broker/oidc/KcOidcBrokerFapi2DPoPTest.java |
Tests FAPI brokering and invalid-response rejection. |
tests/base/src/test/java/org/keycloak/tests/broker/oidc/KcOidcBrokerFapi2DPoPMessageSigningTest.java |
Tests signed-request requirements and lifespan limits. |
tests/base/src/test/java/org/keycloak/tests/broker/oidc/AbstractKcOidcBrokerFapi2Test.java |
Provides shared HTTPS and FAPI test configuration. |
tests/base/src/test/java/org/keycloak/tests/broker/OAuth2BrokerFapi2DPoPTest.java |
Tests DPoP nonce retries, token types, and state validation. |
tests/base/src/test/java/org/keycloak/tests/broker/KcOAuth2BrokerDPoPTest.java |
Tests OAuth2 brokering with DPoP and metadata import. |
tests/base/src/test/java/org/keycloak/tests/admin/identityprovider/IdentityProviderOidcTest.java |
Tests new configuration validation rules. |
services/src/main/java/org/keycloak/social/google/GoogleIdentityProvider.java |
Migrates Google-specific authorization parameters. |
services/src/main/java/org/keycloak/broker/oidc/OIDCIdentityProviderFactory.java |
Imports new OIDC metadata settings. |
services/src/main/java/org/keycloak/broker/oidc/OIDCIdentityProviderConfig.java |
Adds token algorithm and audience settings. |
services/src/main/java/org/keycloak/broker/oidc/OIDCIdentityProvider.java |
Integrates DPoP requests and stronger token validation. |
services/src/main/java/org/keycloak/broker/oidc/OAuth2IdentityProviderConfig.java |
Adds shared FAPI configuration and metadata validation. |
services/src/main/java/org/keycloak/broker/oidc/AbstractOAuth2IdentityProvider.java |
Implements pushed requests, request objects, DPoP, and callback checks. |
services/src/main/java/org/keycloak/broker/oauth/OAuth2IdentityProviderFactory.java |
Imports new OAuth2 metadata settings. |
services/src/main/java/org/keycloak/broker/oauth/OAuth2IdentityProvider.java |
Uses DPoP-aware requests for user profiles. |
js/apps/admin-ui/test/identity-providers/oidc.spec.ts |
Tests OIDC FAPI settings and editability. |
js/apps/admin-ui/test/identity-providers/oauth2.spec.ts |
Tests new OAuth2 settings. |
js/apps/admin-ui/test/identity-providers/main.ts |
Separates form filling from provider creation. |
js/apps/admin-ui/src/identity-providers/add/ResponseValidationSettings.tsx |
Adds shared response-validation controls. |
js/apps/admin-ui/src/identity-providers/add/DiscoverySettings.tsx |
Separates metadata fields from editable client settings. |
js/apps/admin-ui/src/identity-providers/add/DetailSettings.tsx |
Adds authentication and response-validation panels. |
js/apps/admin-ui/src/identity-providers/add/AddOpenIdConnect.tsx |
Exposes validation settings during OIDC creation. |
js/apps/admin-ui/src/identity-providers/add/AddOAuth2.tsx |
Exposes validation settings during OAuth2 creation. |
js/apps/admin-ui/maven-resources/theme/keycloak.v2/admin/messages/messages_en.properties |
Adds labels and help text for new controls. |
docs/documentation/server_admin/topics/identity-broker/oidc.adoc |
Documents OIDC settings and FAPI configuration. |
docs/documentation/server_admin/topics/identity-broker/oauth2.adoc |
Documents OAuth2 request and DPoP settings. |
core/src/main/java/org/keycloak/util/DPoPGenerator.java |
Supports supplied signers and nonce claims. |
core/src/main/java/org/keycloak/OID4VCConstants.java |
Reuses the shared request-object type constant. |
core/src/main/java/org/keycloak/OAuthErrorException.java |
Adds the DPoP nonce-challenge error constant. |
core/src/main/java/org/keycloak/OAuth2Constants.java |
Defines the shared request-object JWT type. |
Review effort: Balanced
|
|
||
| private String createDPoPProof(String method, String url, String accessToken, String nonce) { | ||
| String algorithm = getConfig().getDPoPSigningAlg(); | ||
| KeyWrapper key = session.keys().getActiveKey(session.getContext().getRealm(), KeyUse.SIG, algorithm); |
Unreported flaky test detectedIf the flaky tests below are affected by the changes, please review and update the changes accordingly. Otherwise, a maintainer should report the flaky tests prior to merging the PR. org.keycloak.testsuite.cluster.JGroupsCertificateRotationClusterTest#testCoordinatorHasScheduleTask |
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.
Closes #51393
This adds FAPI 2.0 support (the DPoP aspect only, mTLS will be separate) to the OIDC and OAuth2 identity providers, so Keycloak can act as a FAPI 2.0 client when brokering to an upstream IdP.
Notable changes
Breaking changes for custom providers extending
AbstractOAuth2IdentityProvider/OIDCIdentityProvidercreateAuthorizationUrl(AuthenticationRequest)now returnsURIinstead ofUriBuilderand throwsIOException. Subclasses that tweaked the URL should override the newaddAuthorizationParameters(request, parameters)instead.GoogleIdentityProvideris updated accordingly.parseTokenInput(String, boolean)is nowparseTokenInput(String, boolean, String expectedAlgorithm).OIDCIdentityProvider.validateToken(String)is renamed tovalidateIdToken(String).expclaim are now rejected.