Skip to content

Do not pass the client for Delegation parameterized scope type - #51254

Merged
ahus1 merged 1 commit into
keycloak:mainfrom
rmartinc:issue-51253
Jul 29, 2026
Merged

Do not pass the client for Delegation parameterized scope type#51254
ahus1 merged 1 commit into
keycloak:mainfrom
rmartinc:issue-51253

Conversation

@rmartinc

@rmartinc rmartinc commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Closes #51253

The PR removes passing the client for the canImpersonate method. It seems that passing the client uses a special handling only used for Token Exchange V1 that uses the target user instead of the admin to evaluate the policies (which is very weird I must say). With this change the same behavior than in the normal impersonation in the user resource is used. Test added to use FGAP in the TE delegation test class.

@rmartinc rmartinc changed the title Use root.identity for the canExchange method in UserPermissionsV2 Do not pass the client for Delegation parameterized scope type Jul 29, 2026
Closes issue-51253

Signed-off-by: rmartinc <rmartinc@redhat.com>
@rmartinc
rmartinc marked this pull request as ready for review July 29, 2026 07:59
@rmartinc
rmartinc requested a review from a team as a code owner July 29, 2026 07:59
Copilot AI review requested due to automatic review settings July 29, 2026 07:59

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.

Pull request overview

Fixes delegation authorization under FGAPv2 by evaluating impersonation policies using the administrator identity.

Changes:

  • Stops passing the client during delegation impersonation checks.
  • Adds an integration test covering FGAPv2 delegation, refresh, exchange, and permission removal.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
services/.../DelegationScopeType.java Uses the correct impersonation evaluation context.
tests/.../TokenExchangeDelegationTest.java Adds FGAPv2 delegation coverage.

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

Approving from the perspective of TE Delegation demo scenario:

@ahus1
ahus1 merged commit 4e321b8 into keycloak:main Jul 29, 2026
99 of 101 checks passed
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.

Do not pass the client for Delegation parameterized scope type

5 participants