Skip to content

Map token_exchange_enabled to Keycloak standard.token.exchange.enable…#594

Open
madnialihussain wants to merge 1 commit into
masterfrom
THREESCALE-12102-support-token-exchange
Open

Map token_exchange_enabled to Keycloak standard.token.exchange.enable…#594
madnialihussain wants to merge 1 commit into
masterfrom
THREESCALE-12102-support-token-exchange

Conversation

@madnialihussain
Copy link
Copy Markdown

What this PR does / why we need it:

Maps the token_exchange_enabled OIDC flow from Porta to the Keycloak client attribute standard.token.exchange.enabled, enabling RHBK Standard Token Exchange (V2) on synced clients.

Unlike the other OIDC flows (standardFlowEnabled, implicitFlowEnabled, etc.) which are top-level Keycloak client fields, token exchange is controlled via the client attributes hash with key standard.token.exchange.enabled. This PR handles that difference in KeycloakAdapter::OAuthConfiguration.

Also adds the urn:ietf:params:oauth:grant-type:token-exchange grant type mapping in RESTAdapter::GrantTypes for non-Keycloak OIDC providers that follow RFC 8693.

Ticket requirements (THREESCALE-12102):

  1. Add native support in APIcast for validating OBO tokens: (Verified). APIcast validates OBO tokens out of the box since they are standard JWTs. Tested by obtaining an OBO token via Keycloak token exchange and
    sending it through APIcast, returned HTTP 200.

  2. Ensure compatibility with RHBK Standard Token Exchange (V2): Companion Porta PR adds the UI/API toggle. This Zync PR maps it to Keycloak's standard.token.exchange.enabled attribute. Verified end-to-end: toggle
    ON in Porta → Keycloak client shows standard.token.exchange.enabled: "true", toggle OFF → shows "false", toggle ON again → shows "true".

  3. Provide configuration options to enforce policies based on both client and user claims: (Verified). The OBO token contains both client claims (azp, client_id) and user claims (sub, preferred_username, email,
    roles). APIcast extracts the client identity via jwt_claim_with_client_id (mapped to azp) for rate limiting, and existing policies like keycloak_role_check can enforce rules on user roles. Tested with an unknown
    client azp → APIcast returned HTTP 403.

Which issue(s) this PR fixes

https://redhat.atlassian.net/browse/THREESCALE-12102

Verification steps

  1. Enable token_exchange_enabled on a service in Porta
  2. Verify the Keycloak client has standard.token.exchange.enabled: "true" in its attributes
  3. Verify the 3scale: true attribute is preserved alongside token exchange
  4. Disable token_exchange_enabled and verify the attribute is set to "false"
  5. Run tests: bundle exec rails test test/adapters/keycloak_adapter_test.rb test/adapters/rest_adapter_test.rb

Note: End-to-end testing (Porta → Zync → Keycloak → APIcast) was done by temporarily cherry-picking commits from PR #4310 (OIDC sync token rotation). Will re-test after #4310 is merged.

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.

1 participant