This article draws attention to a breaking behavioral change introduced in Keycloak >=26.7.5 regarding the configuration of OpenID Connect (OIDC) audience mappers. This change may break token validation for clients configured using legacy or deprecated settings.
Background:
Services often validate the Audience (aud) claim inside an incoming access or ID token to verify that the token was explicitly issued for them. If the expected audience string is missing from the token, the service will reject the token and authentication will fail. The behavioral change in Keycloak affects OIDC clients with a deprecated Audience configuration.
Problem
Starting in Keycloak 26.7.5, Keycloak introduced a stricter validation rule for client audience mappers:
When an OIDC audience mapper (oidc-audience-mapper) uses the Included Client Audience (included.client.audience) setting, but the specified value does not correspond to an existing and enabled Keycloak Client ID, Keycloak now silently ignores the mapper.
- Previous Behavior (< 26.7.5): Keycloak treated non-existent client IDs as literal strings and included them directly in the token’s
audclaim. - Current Behavior (≥ 26.7.5): Keycloak drops the mapper output entirely.
The token is issued without the requested audience value, causing downstream authentication to fail.
Which Services Are Affected?
Univention automatically updates and handles all core Nubus services, UCS apps, and built-in components.
However, custom or additional OIDC clients must be checked and updated manually if they rely on an audience mapper that passes a custom string (such as an external URI or non-client identifier) via the included.client.audience setting.
For these clients, custom or literal audience strings must be moved to the Included Custom Audience (included.custom.audience) setting instead.
How to Detect Affected OIDC Client Configurations
The easiest way to check for affected OIDC client configurations is to use the script /usr/share/univention-keycloak/fix-audience-mappers provided by Univention for UCS 5.2-7 errata level 638, UCS 5.0-10 errata level 1503 and Nubus for Kubernetes version 1.23.2:
UCS:
/usr/share/univention-keycloak/fix-audience-mappers --dry-run
Nubus for Kubernetes:
NS={NAMESPACE}
IMAGE=artifacts.software-univention.de/nubus-dev/images/keycloak-bootstrap:26.7.4-nubus3-post-main@sha256:7d3e17bc77b5c444a13c925920e537b97898b1bd3857132f0e2927101a1e8b2a
POD=$(kubectl get pods -n "$NS" -l app.kubernetes.io/name=keycloak-bootstrap \
--sort-by=.metadata.creationTimestamp -o name | tail -1)
kubectl debug -n "$NS" "$POD" --copy-to=keycloak-fix-audience --container=main \
--set-image=main="$IMAGE" \
-- sh -c '/usr/share/univention-keycloak/fix-audience-mappers \
--realm "$KEYCLOAK_REALM" \
--keycloak-url "$KEYCLOAK_URL" --binduser "$KEYCLOAK_USERNAME" \
--bindpwdfile /credentials/keycloak.secret --dry-run'
kubectl wait -n "$NS" --for=jsonpath='{.status.phase}'=Succeeded \
pod/keycloak-fix-audience --timeout=60s
kubectl logs -n "$NS" -f keycloak-fix-audience -c main
kubectl delete pod -n "$NS" keycloak-fix-audience
You can also export your realm clients from the Keycloak Admin Console and manually check affected OIDC clients:
- Log into the Keycloak Admin Console.
- Select your target realm (e.g.,
ucsornubus). - Navigate to Realm Settings.
- Click Actions (top right) and select Partial export.
- Enable Include clients and download the JSON file.
- Open the exported JSON file and inspect your OIDC clients:
- Filter for clients where
"protocol": "openid-connect". - Check the
protocolMappersarray for mappers where"protocolMapper": "oidc-audience-mapper". - Look for mappers containing the
included.client.audiencekey inconfig.
- Verify whether the value of
included.client.audiencematches a valid, active Client ID in Keycloak. - If the value is a literal string, URL/URI, or non-existent client ID, the mapper must be updated.
How to Fix the Audience Mapper
If an OIDC client uses a custom string or non-existent client ID in the Included Client Audience field you can use the mentioned script fix-audience-mappers to repair broken configuration:
UCS:
/usr/share/univention-keycloak/fix-audience-mappers
Nubus for Kubernetes:
Run the commands from How to Detect Affected OIDC Client Configurations → Nubus for Kubernetes without the --dry-run flag.
Note: Be sure to update any corresponding Configuration-as-Code (e.g., Terraform, Helm values, CLI scripts, or Ansible playbooks) to prevent future deployments from overwriting the fix.