Repository navigation
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The collection find() endpoint lacks the resource-ownership restriction applied to findById(), allowing users to retrieve mixed-owner policies through an alternate read path.
1 open issue
What changed in this PR
This PR addresses #55388 by strengthening resource-ownership checks for user-managed permissions in the UMA Protection API.
Changes:
- Checks ownership of every associated resource before read-by-ID, update, and delete operations.
- Rejects policies without associated resources.
- Adds regression tests for mixed-owner, same-owner multi-resource, and resource-less policies.
| File | Description |
|---|---|
| testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/authz/UserManagedPermissionServiceTest.java | Adds ownership and resource-less policy regression tests. |
| services/src/main/java/org/keycloak/authorization/protection/policy/UserManagedPermissionService.java | Centralizes checks across all resources associated with a policy. |
Review effort: Balanced
sguilhen
force-pushed
the
55388-uma-multi-resource-ownership
branch
from
November 25, 2026 18:07
f908c20 to
c2b9e62
Compare
sguilhen
force-pushed
the
55388-uma-multi-resource-ownership
branch
from
November 26, 2026 14:26
c2b9e62 to
3f3edc8
Compare
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Permission pagination loads all matching policies even for tiny pages and silently truncates explicit max=-1 requests, introducing performance and backward-compatibility regressions.
2 open issues
1 resolved since last review
Review effort: Balanced
sguilhen
force-pushed
the
55388-uma-multi-resource-ownership
branch
from
November 26, 2026 15:14
3f3edc8 to
a6ad2f9
Compare
sguilhen
force-pushed
the
55388-uma-multi-resource-ownership
branch
from
November 26, 2026 15:59
a6ad2f9 to
4403253
Compare
Closes keycloak#55388 Signed-off-by: Stefan Guilhen <sguilhen@redhat.com>
sguilhen
force-pushed
the
55388-uma-multi-resource-ownership
branch
from
November 26, 2026 23:20
4403253 to
0545c92
Compare
| // type, any owner) from one created through this self-service API; the resource ownership check in | ||
| // checkRequest() is not enough on its own, since the caller may happen to own the resource an | ||
| // admin-authored permission of a different type governs | ||
| if (!"uma".equals(policy.getType()) || !identity.getId().equals(policy.getOwner())) { |
| // a user-managed permission (type "uma") is only ever created through the Protection API with a single | ||
| // resource attached; multiple resources are only reachable by an administrator wiring a policy up | ||
| // directly through the full admin API, which is not the expected shape for this policy type | ||
| if ("uma".equals(representation.getType()) && policy.getResources().size() > 1) { |
Comment on lines
+151
to
+152
| assertThrows(RuntimeException.class, () -> authzClient.protection(user, "password").policy(policyId).delete(policyId)); | ||
| assertThrows(RuntimeException.class, () -> authzClient.protection(user, "password").policy(policyId).findById(policyId)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
a user-managed permission is only ever created through the Protection API with a single resource attached. Multiple resources on a uma-type policy are only reachable by an administrator wiring one up directly through the full admin API, which is not the shape this policy type expects, and it is what let a policy span resources owned by different users. Creating or updating a uma-type policy with more than one resource is now rejected at that entry point instead. Existing policies already in this state are left as is.
findById(),delete()andupdate()in the Protection API still verify that the resolved policy is auma-typepermission owned by the caller, not just that the caller owns the associated resource. The resource-ownership check alone let a caller reach any policy associated with a resource it owns, including permissions of other types or owned by someone else, since the delegate used for these operations skips all administrative checks.Closes #55388