Skip to content

Check legacy client templates against allowed scopes - #55158

Open
lhanusov wants to merge 1 commit into
keycloak:mainfrom
lhanusov:fix/54456-legacy-client-template-scopes
Open

lhanusov wants to merge 1 commit into
keycloak:mainfrom
lhanusov:fix/54456-legacy-client-template-scopes

Conversation

@lhanusov

@lhanusov lhanusov commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Closes #54456

Co-authored: Codex noreply@openai.com

@lhanusov
lhanusov force-pushed the fix/54456-legacy-client-template-scopes branch from 02958bf to 5947f2f Compare November 13, 2026 12:07
@lhanusov
lhanusov marked this pull request as ready for review November 13, 2026 12:08
@lhanusov
lhanusov requested a review from a team as a code owner November 13, 2026 12:08
Copilot AI balanced review requested due to automatic review settings November 13, 2026 12:08

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.

🟡 Changes recommended

The tests lack a successful allowlisted legacy-name normalization case, so removing normalization would not be caught.

1 open issue
What changed in this PR

This PR addresses #54456 by applying the Allowed Client Scopes registration policy to deprecated clientTemplate requests, closing a bypass of administrator-configured scope restrictions.

Changes:

  • Normalize legacy template names before checking the scope allowlist.
  • Add registration tests for blocked legacy names and an allowed scope.
  • Document the policy change and upgrade considerations.
File Description
tests/​base/​src/​test/​java/​org/​keycloak/​tests/​client/​ClientRegistrationPoliciesTest.java Adds parameterized legacy-template registration tests.
services/​src/​main/​java/​org/​keycloak/​services/​clientregistration/​policy/​impl/​ClientScopesClientRegistrationPolicy.java Checks normalized legacy template names against allowed scopes.
docs/​guides/​securing-apps/​client-registration.adoc Documents legacy-template policy enforcement.
docs/​documentation/​upgrading/​topics/​changes/​changes-27_0_0.adoc Explains rejection behavior, existing assignments, and upgrade requirements.

Review effort: Balanced

@lhanusov
lhanusov force-pushed the fix/54456-legacy-client-template-scopes branch from 5947f2f to 89cc43d Compare November 13, 2026 12:27
Copilot AI balanced review requested due to automatic review settings November 13, 2026 12:27

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 change enforcing allowed client scopes on legacy client templates.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@graziang

Copy link
Copy Markdown
Contributor

@lhanusov The fix looks correct, but clientTemplate is deprecated and it will be probably removed with Keycloak 27 as tracked in #51613.
That said, does it make sense to add this fix and documentation to the main branch? Or would it only make sense for release branches? @mposolda WDYT?

@mposolda mposolda 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.

@graziang That's good point.

I think that for now, it makes sense to include this fix in main as it is not 100% sure that we manage to remove clientTemplate support in KC 27 (hopefully yes).

I've created an issue #55219 and added a note about reverting those changes from main (including upgrading guide note) in case that clientTemplate is going to be removed.

For now, I am approving the PR. Hopefully can be backported to 26.8 once merged. I've rebased the PR, hopefully that helps with "SAST" tests.

Closes keycloak#54456

Signed-off-by: Lukas Hanusovsky <lhanusov@redhat.com>
@mposolda
mposolda force-pushed the fix/54456-legacy-client-template-scopes branch from 89cc43d to 5c8f2ff Compare November 16, 2026 10:48
Copilot AI balanced review requested due to automatic review settings November 16, 2026 10:48

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 were identified for the change enforcing allowed-scope restrictions on legacy client templates.

No open issues 🎉

Review effort: Balanced

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dynamic client registration can attach a client scope the admin meant to block (26.8.1)

4 participants