You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Support federated credentials for outbound OIDC identity brokering
#55674
When Keycloak brokers user login to an external OIDC identity provider, it must authenticate itself at that provider’s token endpoint. The built-in broker supports client secrets and self-signed JWT assertions, but does not appear to support obtaining a client assertion from a workload identity provider.
For example, a Keycloak instance hosted in Azure Container Apps could use its user-assigned managed identity as a federated credential on a Microsoft Entra application. Instead of storing an Entra client secret or managing a certificate, Keycloak would obtain a short-lived managed-identity token and present it as the client assertion when redeeming the user’s authorization code. The user would still authenticate interactively with Entra.
Could the OIDC broker support a configurable source of externally issued client assertions? Ideally this would provide an extensibility point rather than hard-coding a single cloud provider. A managed-identity implementation could be one source.
The capability should cover authorization-code redemption and applicable refresh-token requests, retain the existing PKCE and token-validation behavior, handle assertion expiration and failures safely, and avoid logging assertions. It should not change existing broker configurations by default.
Context and questions
In Keycloak 26.8.2, the broker generates its own assertion in AbstractOAuth2IdentityProvider.authenticateTokenRequest. A custom identity provider appears necessary to obtain and send an external assertion today. Is there already a supported extension point or a planned feature for this outbound use case?
This differs from #38146, where clients use federated assertions to authenticate to Keycloak. It also differs from #54103, which proposes static token-request parameters and excludes dynamic client assertions.
The Azure example needs end-to-end verification for authorization-code redemption, including multitenant and personal Microsoft account scenarios. I would welcome feedback on the desired design and compatibility requirements.
Thanks for the writeup @pauska , and for tracing it to the actual code path rather than just describing the symptom.
Your reading is correct on both counts. AbstractOAuth2IdentityProvider.authenticateTokenRequest is a binary choice: either isJWTAuthentication(), which signs an assertion with the realm's own key via generateToken(), or one of the client-secret variants. There is no hook for an assertion minted somewhere else, so today a custom identity provider overriding that method really is the only route, and it is not something we support as an extension point.
There is an existing proposal for the same capability in #53617, filed in October. I would suggest we consolidate there, since it has a concrete design and milestones, and I am replying to it now as well. Before we do, one difference from your issue is worth carrying over rather than losing in the merge.
#53617 sources the assertion from an identity provider configured in Keycloak: a Kubernetes or SPIFFE provider that issues Keycloak's own workload identity, referenced by a new client authentication method on the OIDC provider. Your case does not fit that shape. An Azure managed identity is not a Keycloak identity provider; Keycloak would obtain it from the platform's instance metadata service. So the token source is ambient infrastructure rather than configured trust, and the design in #53617 as currently written would not cover it.
That makes your framing the more general one, and I think it is the right requirement: the assertion source should be a pluggable abstraction, with "configured Kubernetes or SPIFFE provider" and "ambient cloud managed identity" as two implementations, rather than the configured-provider case being the only shape the feature knows about. That is a design constraint worth settling early, because it is much harder to retrofit.
One concrete note for your Entra scenario: getClientAssertionAudience() already exists on the OIDC provider config, so the non-standard api://AzureADTokenExchange audience is at least expressible today. The missing piece is purely where the assertion comes from, not how it is addressed.
I cannot commit to scope or sequencing here on my own, since this has to line up with the capability model in #43486. Following up on #53617 as the main thread.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Problem
When Keycloak brokers user login to an external OIDC identity provider, it must authenticate itself at that provider’s token endpoint. The built-in broker supports client secrets and self-signed JWT assertions, but does not appear to support obtaining a client assertion from a workload identity provider.
For example, a Keycloak instance hosted in Azure Container Apps could use its user-assigned managed identity as a federated credential on a Microsoft Entra application. Instead of storing an Entra client secret or managing a certificate, Keycloak would obtain a short-lived managed-identity token and present it as the client assertion when redeeming the user’s authorization code. The user would still authenticate interactively with Entra.
Microsoft describes the managed-identity trust configuration: https://learn.microsoft.com/en-us/entra/workload-id/workload-identity-federation-config-app-trust-managed-identity
Proposed capability
Could the OIDC broker support a configurable source of externally issued client assertions? Ideally this would provide an extensibility point rather than hard-coding a single cloud provider. A managed-identity implementation could be one source.
The capability should cover authorization-code redemption and applicable refresh-token requests, retain the existing PKCE and token-validation behavior, handle assertion expiration and failures safely, and avoid logging assertions. It should not change existing broker configurations by default.
Context and questions
In Keycloak 26.8.2, the broker generates its own assertion in
AbstractOAuth2IdentityProvider.authenticateTokenRequest. A custom identity provider appears necessary to obtain and send an external assertion today. Is there already a supported extension point or a planned feature for this outbound use case?This differs from #38146, where clients use federated assertions to authenticate to Keycloak. It also differs from #54103, which proposes static token-request parameters and excludes dynamic client assertions.
The Azure example needs end-to-end verification for authorization-code redemption, including multitenant and personal Microsoft account scenarios. I would welcome feedback on the desired design and compatibility requirements.
All reactions
Replies: 3 comments
Uh oh!
There was an error while loading. Please reload this page.
Isn't this also covered in #53617?
All reactions
Uh oh!
There was an error while loading. Please reload this page.
Thanks for the writeup @pauska , and for tracing it to the actual code path rather than just describing the symptom.
Your reading is correct on both counts.
AbstractOAuth2IdentityProvider.authenticateTokenRequestis a binary choice: eitherisJWTAuthentication(), which signs an assertion with the realm's own key viagenerateToken(), or one of the client-secret variants. There is no hook for an assertion minted somewhere else, so today a custom identity provider overriding that method really is the only route, and it is not something we support as an extension point.There is an existing proposal for the same capability in #53617, filed in October. I would suggest we consolidate there, since it has a concrete design and milestones, and I am replying to it now as well. Before we do, one difference from your issue is worth carrying over rather than losing in the merge.
#53617 sources the assertion from an identity provider configured in Keycloak: a Kubernetes or SPIFFE provider that issues Keycloak's own workload identity, referenced by a new client authentication method on the OIDC provider. Your case does not fit that shape. An Azure managed identity is not a Keycloak identity provider; Keycloak would obtain it from the platform's instance metadata service. So the token source is ambient infrastructure rather than configured trust, and the design in #53617 as currently written would not cover it.
That makes your framing the more general one, and I think it is the right requirement: the assertion source should be a pluggable abstraction, with "configured Kubernetes or SPIFFE provider" and "ambient cloud managed identity" as two implementations, rather than the configured-provider case being the only shape the feature knows about. That is a design constraint worth settling early, because it is much harder to retrofit.
One concrete note for your Entra scenario:
getClientAssertionAudience()already exists on the OIDC provider config, so the non-standardapi://AzureADTokenExchangeaudience is at least expressible today. The missing piece is purely where the assertion comes from, not how it is addressed.I cannot commit to scope or sequencing here on my own, since this has to line up with the capability model in #43486. Following up on #53617 as the main thread.
All reactions
Uh oh!
There was an error while loading. Please reload this page.
Thank you for the detailed reply! For some reason I was unable to find #53617 when I searched for existing issues.
I'll close this one.
All reactions