8000 Introduce manage-organizations, view-organizations admin roles for Or… by vramik · Pull Request #47266 · keycloak/keycloak · GitHub
[go: up one dir, main page]

Skip to content

Introduce manage-organizations, view-organizations admin roles for Or… - #47266

Merged
pedroigor merged 1 commit into
keycloak:mainfrom
vramik:31641-manage-view-organizations-admin-roles
Apr 21, 2026
Merged

pedroigor merged 1 commit into
keycloak:mainfrom
vramik:31641-manage-view-organizations-admin-roles

Conversation

@vramik
@vramik vramik commented Mar 18, 2026
Copy link
Copy Markdown
8000
Contributor

…ganization management

Closes #45497
Closes #31641

@vramik
vramik force-pushed the 31641-manage-view-organizations-admin-roles branch 3 times, most recently from 2f25bf8 to e40bb9c Compare March 18, 2026 20:01
@vramik
vramik force-pushed the 31641-manage-view-organizations-admin-roles branch 2 times, most recently from 5bb4aee to 53ebe20 Compare April 9, 2026 08:26
@keycloak-github-bot keycloak-github-bot Bot left a comment
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Unreported flaky test detected, please review

@keycloak-github-bot
Copy link
Copy Markdown

Unreported flaky test detected

If the flaky tests below are affected by the changes, please review and update the changes accordingly. Otherwise, a maintainer should report the flaky tests prior to merging the PR.

org.keycloak.testsuite.model.session.UserSessionInitializerTest#testUserSessionPropagationBetweenSites

Keycloak CI - Store Model Tests

java.lang.AssertionError: 
threads didn't terminate in time: [main (RUNNABLE):
	at java.management@25.0.2/sun.management.ThreadImpl.dumpThreads0(Native Method)
	at java.management@25.0.2/sun.management.ThreadImpl.dumpAllThreads(ThreadImpl.java:505)
	at java.management@25.0.2/sun.management.ThreadImpl.dumpAllThreads(ThreadImpl.java:493)
...

Report flaky test

@keycloak-github-bot keycloak-github-bot Bot left a comment
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Unreported flaky test detected, please review

@keycloak-github-bot
Copy link
Copy Markdown

Unreported flaky test detected

If the flaky tests below are affected by the changes, please review and update the changes accordingly. Otherwise, a maintainer should report the flaky tests prior to merging the PR.

org.keycloak.testsuite.model.session.UserSessionProviderModelTest#testCreateUserSessionsParallel

Keycloak CI - Store Model Tests

java.lang.AssertionError: 
threads didn't terminate in time: [main (RUNNABLE):
	at java.management@25.0.2/sun.management.ThreadImpl.dumpThreads0(Native Method)
	at java.management@25.0.2/sun.management.ThreadImpl.dumpAllThreads(ThreadImpl.java:505)
	at java.management@25.0.2/sun.management.ThreadImpl.dumpAllThreads(ThreadImpl.java:493)
...

Report flaky test

org.keycloak.testsuite.model.session.UserSessionProviderModelTest#testStreamsMarshalling

Keycloak CI - Store Model Tests

java.lang.AssertionError: 
threads didn't terminate in time: [main (RUNNABLE):
	at java.management@25.0.2/sun.management.ThreadImpl.dumpThreads0(Native Method)
	at java.management@25.0.2/sun.management.ThreadImpl.dumpAllThreads(ThreadImpl.java:505)
	at java.management@25.0.2/sun.management.ThreadImpl.dumpAllThreads(ThreadImpl.java:493)
...

Report flaky test

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

Claude Code review:

All UI Issues in PR #47266
Bug 1 — manage-organizations-only users are invisible to the nav
PageNav.tsx:88-94 — showManage uses hasSomeAccess(..., "query-organizations", ...). Since manage-organizations is not a composite, these users have no role that matches, so the entire Manage nav group is hidden from them.

Fix: Add "manage-organizations" to hasSomeAccess.

Bug 2 — manage-organizations-only users can't see the Organizations feature
useIsFeatureEnabled.ts:34-38 — checks hasAny("manage-realm", "query-organizations"). A manage-organizations-only user has neither, so isFeatureEnabled(Feature.Organizations) returns false and the Organizations nav entry never renders.

Fix: Add "manage-organizations" to the hasAny call.

Bug 3 — manage-organizations-only users are blocked from the Edit Organization route
routes/EditOrganization.tsx:26 — access: "view-organizations". The server-side canView() explicitly accepts manage-organizations, but the UI access guard doesn't. A user with only manage-organizations gets blocked before the page even loads.

Fix: Change to access: ["view-organizations", "manage-organizations"].

All three bugs share the same root cause
manage-organizations was not wired as a composite role (unlike view-organizations → query-organizations). The UI checks were updated only for the query-organizations path, overlooking the case where someone is granted manage-organizations without the lower-privilege roles.


Stan's human thoughts: Although we do this in a lot of other places, I'm not sure if relying on composite roles is really the best solution. It's a bit brittle as we allow full editing of the roles in the UI. So if someone changes the composite structure, the UI guards will not work properly.

Maybe using composites is the best solution for now and we address this later throughout the code base? I'd really like to revamp the whole access strategy anyway.

@vramik
vramik commented Apr 20, 2026
Copy link
Copy Markdown
Contributor Author

@ssilvert thanks for the review! All three bugs share the same root cause and follow the same pattern: manage-organizations not including view-organizations or query-organizations as composites is consistent with how all other resource types work.

manage-users doesn't include view-users or query-users either — the only composite chain in the codebase is view-* → query-* (set up in RealmManager.addQueryCompositeRoles).

So user having only manage-users role is not able to access users section either
image

So this isn't an oversight specific to organizations. Taking your human thought into consideration: Do we want to change the behavior now for all realm resources or do you prefer to make it organization-specific or do we address this later during the "revamp of the whole access strategy"?

#48085 is related.

@vramik
vramik force-pushed the 31641-manage-view-organizations-admin-roles branch from 28ff68e to f982137 Compare April 20, 2026 14:22
@vramik
vramik requested review from pedroigor and ssilvert April 20, 2026 14:26
pedroigor
pedroigor previously approved these changes Apr 20, 2026
…ganization management

Closes keycloak#45497
Closes keycloak#31641

Signed-off-by: vramik <vramik@redhat.com>
@vramik
vramik force-pushed the 31641-manage-view-organizations-admin-roles branch from f982137 to 692f606 Compare April 21, 2026 07:58
@ssilvert
Copy link
Copy Markdown
Contributor

@ssilvert thanks for the review! All three bugs share the same root cause and follow the same pattern: manage-organizations not including view-organizations or query-organizations as composites is consistent with how all other resource types work.

manage-users doesn't include view-users or query-users either — the only composite chain in the codebase is view-* → query-* (set up in RealmManager.addQueryCompositeRoles).

So user having only manage-users role is not able to access users section either image

So this isn't an oversight specific to organizations. Taking your human thought into consideration: Do we want to change the behavior now for all realm resources or do you prefer to make it organization-specific or do we address this later during the "revamp of the whole access strategy"?

#48085 is related.

I guess we need to wait. I'll approve.

@pedroigor
pedroigor merged commit 1356013 into keycloak:main Apr 21, 2026
86 checks passed
@vramik
vramik deleted the 31641-manage-view-organizations-admin-roles branch May 3, 2026 08:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

3 participants

0