Skip to content

Make UMA ticket resource resolution independent of permission order - #55591

Open
sakshichitnis27 wants to merge 1 commit into
keycloak:mainfrom
sakshichitnis27:issue-55472-uma-permission-order
Open

sakshichitnis27 wants to merge 1 commit into
keycloak:mainfrom
sakshichitnis27:issue-55472-uma-permission-order

Conversation

@sakshichitnis27

@sakshichitnis27 sakshichitnis27 commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Closes #55472

The invalid_resource check now runs once, after all requested permissions were processed, instead of while the first one is resolved.

Decisions and assumptions:

  • A permission whose resource cannot be resolved for the identity is skipped, and the request only fails with invalid_resource if no requested permission could be resolved. This matches what already happened when an unresolvable resource was not the first one, and keeps the existing result for single-resource requests. The alternative (always fail on any unresolvable resource) would turn requests that succeed today into errors, so I did not pick it; happy to change it if maintainers prefer that.
  • The error message still names the first unresolvable resource, and the PERMISSION_TOKEN_ERROR event is still fired.
  • Processing now continues after an unresolvable resource, so a later permission with an invalid scope reports invalid_scope where it previously never got that far.

This change and its tests were written with the help of an AI coding agent (Claude Code).

@sakshichitnis27
sakshichitnis27 marked this pull request as ready for review November 26, 2026 18:25
@sakshichitnis27
sakshichitnis27 requested a review from a team as a code owner November 26, 2026 18:25
Copilot AI balanced review requested due to automatic review settings November 26, 2026 18:25

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 making UMA unresolved-resource errors independent of permission order.

No open issues 🎉

What changed in this PR

Addresses #55472 by making UMA ticket requests with unresolvable resource names behave consistently regardless of permission order.

Changes:

  • Defers invalid_resource until permission processing finishes, preserving the first unresolved resource in the error and the existing error event.
  • Adds regression tests for unknown resources, resources owned by another user, and requests where no resource resolves.
  • Adds a test helper for sending multiple permission parameters.
File Description
tests/​utils-shared/​src/​main/​java/​org/​keycloak/​testsuite/​util/​oauth/​PermissionGrantRequest.java Adds a fluent helper for appending permission parameters.
tests/​base/​src/​test/​java/​org/​keycloak/​tests/​authz/​services/​uma/​UmaGrantTypeTest.java Tests order-independent resolution and unresolved-resource errors.
services/​src/​main/​java/​org/​keycloak/​authorization/​authorization/​AuthorizationTokenService.java Tracks unresolved resources and defers the error check until after processing.

Review effort: Balanced

Closes keycloak#55472

Signed-off-by: sakshichitnis27 <sakshigchitnis27@gmail.com>
@sakshichitnis27
sakshichitnis27 force-pushed the issue-55472-uma-permission-order branch from 499d340 to 4c729ce Compare November 27, 2026 00:11
Copilot AI balanced review requested due to automatic review settings November 27, 2026 00:11

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

A regression test is still needed to verify that an unknown resource followed by an invalid scope returns invalid_scope rather than invalid_resource.

1 open issue

Review effort: Balanced

Comment on lines +530 to +532
if (!resolved && unresolvedResourceId == null) {
unresolvedResourceId = resourceId;
}
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.

UMA ticket grant: invalid_resource depends on the order of requested permissions

2 participants