Add support for per-client signing key selection for SAML and OIDC - #47277
Add support for per-client signing key selection for SAML and OIDC#47277wadahiro wants to merge 1 commit into
Conversation
117c498 to
c1d7047
Compare
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.model.session.UserSessionInitializerTest#testUserSessionPropagationBetweenSitesKeycloak CI - Store Model Tests org.keycloak.testsuite.model.session.UserSessionProviderOfflineModelTest#testOfflineSessionLazyLoadingKeycloak CI - Store Model Tests |
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.model.singleUseObject.SingleUseObjectModelTest#testClusterKeycloak CI - Store Model Tests |
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.forms.MultipleTabsLoginTest#multipleTabsParallelLoginTestWithAuthSessionExpiredAndRegisterClickKeycloak CI - Forms IT (chrome) |
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.forms.MultipleTabsLoginTest#testLoginPageRefreshKeycloak CI - Forms IT (chrome) |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 40 out of 40 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (2)
services/src/main/java/org/keycloak/protocol/saml/SamlProtocol.java:725
- This Redirect-bound LogoutRequest puts the transformed XML
KeyNameintoMessageSigningKeyId. When the client usesCERT_SUBJECTorNONE, the extension no longer identifies the selected KID, so key lookup/rotation can fail; the extension must carrykeyPair.getKid()while the XML signature may still use the transformer.
KeyWrapper keyPair = getSigningKey(samlClient);
String keyName = samlClient.getXmlSigKeyInfoKeyNameTransformer().getKeyName(keyPair.getKid(), keyPair.getCertificate());
services/src/main/java/org/keycloak/protocol/saml/SamlProtocol.java:781
- The final Redirect-bound LogoutResponse also reuses the transformed XML
KeyNameforMessageSigningKeyId. WithCERT_SUBJECTorNONE, that extension cannot identify the configured signing KID; keepkeyNameforsignWith, but put the rawkeyPair.getKid()in the extension.
String keyName = transformer.getKeyName(keyPair.getKid(), keyPair.getCertificate());
binding.signatureAlgorithm(algorithm).signWith(keyName, (PrivateKey) keyPair.getPrivateKey(), (PublicKey) keyPair.getPublicKey(), keyPair.getCertificate()).signDocument();
Closes keycloak#10367 Signed-off-by: Hiroyuki Wada <h2-wada@nri.co.jp>
Closes #10367
The original issue (#10367) requests per-client signing key selection for SAML to support gradual key rotation. This PR extends the scope to OIDC as well, since the same need exists there — for example, relying parties that do not support JWKS URL and require manual key configuration, or environments where there is no network path from RP to OP (e.g., OIDC Implicit Flow with manually managed keys). In these cases, key rotation must be coordinated per-client, and a simultaneous switch is not feasible.
Supported signing points
OIDC: separate signing key per token type (matching the existing per-token-type algorithm
settings)
SAML: single signing key applied to all signing points
If the configured key is not available (passive, disabled, or not found), it falls back to the
realm's active signing key.
Admin UI
SigningKeySelectcomponent shared by OIDC and SAML, enabling per-client signing key selection in client settingsDocumentation
Tests