Skip to content

THREESCALE-15279: Add an "audience" protocol mapper to Keycloak integration#597

Open
jlledom wants to merge 1 commit into
masterfrom
THREESCALE-15279-token-introspection
Open

THREESCALE-15279: Add an "audience" protocol mapper to Keycloak integration#597
jlledom wants to merge 1 commit into
masterfrom
THREESCALE-15279-token-introspection

Conversation

@jlledom

@jlledom jlledom commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Jira Issue:

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

Description:

As the issue describes, after a breaking change in a recent RHBK release, the token introspection feature stopped working. In order to fix it, we need to ensure the access token received from keycloak includes the client id in the aud field.

Keycloak provides a way to write on this field, which is installing a protocol mapper type oidc-audiende-mapper in all clients.

This PR modifies the Keycloak integration in Zync to add such mapper in the requests to the client registration service in Keycloak.

Verification steps:

  1. Ensure the server allows the oidc-audience-mapper for client registration
    • Keycloak: Realm Settings -> Client Registration -> Client Registration Policies
    • RHBK: Clients -> Client Registration
    • In both cases, add oidc-audience-mapper to the Allowed Protocol Mapper Types policy for both Anonymous and Authenticated clients
  2. Sync an application from porta. The fastest way is to regenerate the client secret.
  3. You should see the mapper in the server UI
    • Keycloak: Clients -> [client id] -> Mappers
    • RHBK: Clients -> [client id] -> Client Scopes -> [client id]-dedicated -> Mappers
  4. Get an access token
ACCESS_TOKEN=`curl   -d "client_id=[client_id]"   -d "client_secret=[client_secret]"   -d "grant_type=client_credentials"   "[endpoint]/auth/realms/[realm]/protocol/openid-connect/token" | jq -r '.access_token'`
  1. Get the introspection token
curl -X POST     [endpoint]/auth/realms/joan/protocol/openid-connect/token/introspect     -u "[client_id]:[client_secret]"     -d "token=$ACCESS_TOKEN"
  1. You should get a valid token. If you get {"active": false} then it's not working.

RHBK 26.6.2+ rejects token introspection when the calling client is
not in the token's aud claim. Previously, Zync created OIDC clients
without an audience mapper, so tokens only contained aud: "account".
This caused introspection to fail with "Client '<client_id>' is not
in the token audience".

Add an oidc-audience-mapper protocol mapper to every client created
or updated by Zync. The mapper injects the client's own ID into the
aud claim of access tokens, satisfying RHBK's new validation
requirement while leaving ID tokens unchanged.

Assisted-by: Claude Code
@jlledom jlledom self-assigned this Jul 1, 2026
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