Repository navigation
Conversation
…ject issuer When subject_issuer is not a provider alias, the external-to-internal exchange looks for a provider that claims the issuer among all providers that can exchange external tokens. A disabled one made the lookup throw, so the exchange failed with a 500 whenever such a provider sorted ahead of the one that matches. Query only enabled providers. The issuer test now sends the issuer it is given; it sent the alias before. Closes keycloak#49205 Signed-off-by: Yang Bai <271969568+ybai08@users.noreply.github.com>
|
The one red job, |
|
@mposolda, could you take a look at this when you have time? It fixes #49205: a token exchange fails when another identity provider in the realm is disabled. It's a one-line change in |
Closes #49205
In an external-to-internal token exchange,
subject_issuercan be an identity provider alias or the issuer of the token. When it is not an alias,AbstractTokenExchangeProvider.locateExchangeExternalTokenByAliasasks every provider that can exchange external tokens whether it is the issuer. It builds each provider withIdentityBrokerService.getIdentityProvider, which throwsIdentityBrokerExceptionfor a disabled provider, and nothing in that loop catches it. Providers come back ordered by alias, so a disabled provider whose alias sorts ahead of the matching one makes the exchange fail with a 500.The lookup now queries only enabled providers, with the same
IdentityProviderQuery...with(IdentityProviderModel.ENABLED, "true")thatLinkedAccountsResourceandAccountConsoleuse.Test
KcOidcBrokerTokenExchangeTestgetstestExternalInternalTokenExchangeUsingIssuerWithDisabledProvider: a disabled OIDC provider with the aliasa-disabled-idpahead of the broker, and an exchange by issuer.While writing it I found that the existing
testExternalInternalTokenExchangeUsingIssuernever took this path:assertExternalToInternalExchangeignored itssubjectIssuerargument and the request always sent the alias. The helper now sends the issuer it is given. The other callers keep sending the alias.What I ran
./mvnw test -Pauth-server-quarkus -Dtest=KcOidcBrokerTokenExchangeTest -pl testsuite/integration-arquillian/tests/basemainwith only the test change: 11 run, 1 failure, the new test (Expected: <200> but: was <500>). The other 10 pass, including the issuer test that now really sends the issuer../mvnw spotless:check -pl services,testsuite/integration-arquillian/tests/base: clean.AI usage: an AI agent was used to write this change; I have reviewed it.