8000 Limit AuthZEN queries to tokens with the authzen scope and audience by kanywst · Pull Request #55111 · keycloak/keycloak · GitHub
[go: up one dir, main page]

Skip to content

Limit AuthZEN queries to tokens with the authzen scope and audience - #55111

Open
kanywst wants to merge 1 commit into
keycloak:mainfrom
kanywst:authzen-limit-scope-aud
Open

kanywst wants to merge 1 commit into
keycloak:mainfrom
kanywst:authzen-limit-scope-aud

Conversation

@kanywst
@kanywst kanywst commented Nov 12, 2026 •
Copy link
Copy Markdown

Closes #50527

The authzen client scope isn't created automatically; the guide covers adding it with an audience mapper. A missing scope or wrong audience returns 401, same as the other authentication failures in AuthZenResource.

AI disclosure: AI agents assisted with implementation and tests.

Closes keycloak#50527

Signed-off-by: kanywst <45947799+kanywst@users.noreply.github.com>
@kanywst
kanywst marked this pull request as ready for review November 12, 2026 14:32
@kanywst
kanywst requested a review from a team as a code owner November 12, 2026 14:32
Copilot AI balanced review requested due to automatic review settings November 12, 2026 14:32
Copilot AI left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are reported for the AuthZEN scope and audience restrictions.

No open issues 🎉

What changed in this PR

Restricts access to Keycloak’s AuthZEN endpoints to tokens containing the authzen scope and the 8000 realm-specific AuthZEN audience, addressing #50527.

Changes:

  • Enforces scope and audience checks, returning 401 Unauthorized when either requirement is unmet.
  • Updates test clients and adds rejection tests for missing scope and incorrect audience.
  • Documents manual client-scope setup and the upgrade requirement.
File Description
docs/​guides/​securing-apps/​authzen-authorization.adoc Explains token requirements and client-scope configuration.
docs/​documentation/​upgrading/​topics/​changes/​changes-27_0_0.adoc Documents the new authentication requirements for upgrades.
authzen/​tests/​base/​src/​test/​java/​org/​keycloak/​tests/​authzen/​AuthZenScope.java Adds a shared helper to configure the scope and audience mapper.
authzen/​tests/​base/​src/​test/​java/​org/​keycloak/​tests/​authzen/​AuthZenEvaluationTest.java Configures test clients and tests rejection of missing scope and incorrect audience.
authzen/​tests/​base/​src/​test/​java/​org/​keycloak/​tests/​authzen/​AuthZenEvaluationsTest.java Configures test clients and tests missing-scope rejection for batch evaluations.
authzen/​tests/​base/​src/​test/​java/​org/​keycloak/​tests/​authzen/​AuthZenEvaluationInteropTest.java Configures the interoperability client with the required scope and audience.
authzen/​services/​src/​main/​java/​org/​keycloak/​authorization/​authzen/​AuthZenWellKnownProvider.java Adds audience helpers based on the realm’s frontend URL.
authzen/​services/​src/​main/​java/​org/​keycloak/​authorization/​authzen/​AuthZenResource.java Enforces audience and scope validation during authentication.
authzen/​services/​src/​main/​java/​org/​keycloak/​authorization/​authzen/​AuthZen.java Defines the shared authzen scope constant.

Review effort: Balanced

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.

Limit AuthZEN queries to clients with 'authzen' scope and expected audience

2 participants

0