Skip to content

fix(auth/keycloak): enable Standard Token Exchange v2 on peer clients#116

Draft
aktech wants to merge 5 commits into
mainfrom
fix/token-exchange-v2-standard
Draft

fix(auth/keycloak): enable Standard Token Exchange v2 on peer clients#116
aktech wants to merge 5 commits into
mainfrom
fix/token-exchange-v2-standard

Conversation

@aktech

@aktech aktech commented May 6, 2026

Copy link
Copy Markdown
Member

Keycloak 26.2+ defaults to V2 for the token-exchange grant. Operator only wired V1 fine-grained-authz, which V2 ignores → every exchange returns 403 "Client not allowed to exchange". Sets standard.token.exchange.enabled=true attribute on each peer client. V1 wiring kept for older Keycloak.

aktech added 2 commits May 6, 2026 20:21
Keycloak 26.2+ enables TOKEN_EXCHANGE_STANDARD_V2 by default. V2 routes
the urn:ietf:params:oauth:grant-type:token-exchange grant through the
new path which checks the requesting client's
`standard.token.exchange.enabled` attribute. The legacy V1
fine-grained-authz wiring on the target client is silently ignored.

Without this attribute every exchange returns
`403 access_denied "Client not allowed to exchange"`. Both Nebi
auto-auth at JupyterLab spawn and the jhub-apps environment selector
fail silently as a result.

ConfigureTokenExchange now sets the attribute on each peer client via
UpdateClient before doing V1 wiring. V1 path kept intact for clusters
running Keycloak <26 with V2 disabled.
@github-actions

github-actions Bot commented May 6, 2026

Copy link
Copy Markdown

Docker Images Built

Images pushed to Quay.io for branch fix-token-exchange-v2-standard:

Image Tag Platforms
Operator quay.io/nebari/nebari-operator:fix-token-exchange-v2-standard linux/amd64 + linux/arm64

Test the operator:

kubectl apply -k https://github.com/nebari-dev/nebari-operator.git/config/default?ref=fix/token-exchange-v2-standard
kubectl set image deployment/nebari-operator-controller-manager manager=quay.io/nebari/nebari-operator:fix-token-exchange-v2-standard -n nebari-operator-system

aktech added 3 commits May 6, 2026 22:19
V2 also requires the target client to be in the requesting client's
scope tree, otherwise Keycloak rejects with
`400 invalid_request "Requested audience not available: <target>"`,
even when the requester has standard.token.exchange.enabled=true.

Add an oidc-audience-mapper on each peer client whose
included.client.audience points to this NebariApp's clientId.
Idempotent via name-based skip + 409 tolerance.
@github-actions

github-actions Bot commented May 6, 2026

Copy link
Copy Markdown

Docker Images Built

Images pushed to Quay.io for branch fix-token-exchange-v2-standard:

Image Tag Platforms
Operator quay.io/nebari/nebari-operator:fix-token-exchange-v2-standard linux/amd64 + linux/arm64

Test the operator:

kubectl apply -k https://github.com/nebari-dev/nebari-operator.git/config/default?ref=fix/token-exchange-v2-standard
kubectl set image deployment/nebari-operator-controller-manager manager=quay.io/nebari/nebari-operator:fix-token-exchange-v2-standard -n nebari-operator-system

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants