Replies: 1 comment 2 replies
-
|
@cgurtshaw Thank you very much for the detailed implementation plan, it’s greatly appreciated. Would you be interested in contributing this feature to Keycloak by collaborating with the Keycloak OAuth SIG? We believe your proposal would be a valuable feature, and we would be happy to support you through the contribution process. You can find more details about the Keycloak OAuth SIG here: https://github.com/keycloak/keycloak-oauth-sig |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Implementation Plan: Global Read-Only Admin Role for All Realms
Issue: #39616 - Global Read-Only Admin Role for All Realms (Including Future Realms)
Summary
This proposal introduces a new global admin role
global-view-adminthat grants read-only access to all existing and future realms. The feature will be opt-in via a feature flag to allow community members to enable it based on their security and operational requirements.Problem Statement
Currently, Keycloak does not provide a mechanism to grant users read-only administrative access to all realms (current and future) without manual intervention. Organizations need this for:
Current Workaround: Manually assign
view-*roles for each realm'srealm-managementclient, repeated for every new realm.Proposed Solution
1. New Global Role:
global-view-adminAdd a new role to the master realm that automatically grants view-only permissions across all realms.
Role Capabilities:
Scope:
2. Feature Flag Implementation
Feature will be disabled by default and can be enabled via:
--features=global-readonly-admin # or --feature-global-readonly-admin=enabledWhen disabled:
global-view-adminrole will not be created during master realm setupTechnical Design
Role Overview
Key Components to Modify
1. Feature Flag Definition
File:
common/src/main/java/org/keycloak/common/Profile.javaAdd new feature flag:
Rationale for DISABLED_BY_DEFAULT:
2. Admin Role Constants
File:
server-spi-private/src/main/java/org/keycloak/models/AdminRoles.javaAdd new constant:
3. Master Realm Role Creation
File:
services/src/main/java/org/keycloak/services/managers/RealmManager.javaMethod:
createMasterAdminManagement()Changes:
4. Automatic Role Grant on Realm Creation/Import
File:
services/src/main/java/org/keycloak/services/resources/admin/RealmsAdminResource.javaMethod:
grantPermissionsToRealmCreator()Changes:
5. Permission Checking Logic
File:
services/src/main/java/org/keycloak/services/resources/admin/fgap/MgmtPermissions.javaCurrent logic already handles composite roles correctly, so no changes needed. The method checks:
This will automatically include users with
global-view-adminsince it contains the view roles as composites.Verify: No changes needed to individual permission checks like:
canViewRealmDefault()- Already checks forVIEW_REALMrolecanViewUsersDefault()- Already checks forVIEW_USERSrole6. Database Migration (if needed)
For existing Keycloak installations upgrading with the feature enabled:
7. Internationalization (i18n)
Files to Update:
themes/src/main/resources/theme/base/admin/messages/admin-messages_en.properties8. Testing Requirements
Unit Tests
Test cases:
Integration Tests
Test scenarios:
Manual Test Scenarios
Fresh Installation:
global-view-adminrole exists in master realmUpgrade Scenario:
Feature Disabled:
Security Considerations
1. Privilege Escalation Prevention
2. Audit Trail
3. Opt-In Model
4. Composite Role Safety
5. Fine-Grained Authorization (V2) Compatibility
ADMIN_FINE_GRAINED_AUTHZ_V2featureMigration Strategy
For New Installations
global-view-adminrole during master realm setupFor Existing Installations
global-view-adminrole in master realmRollback Plan
If feature needs to be disabled:
Open Questions
1. Should global-view-admin have access to master realm itself?
Options:
Recommendation: Option A - consistency and transparency are valuable for audit use cases. Master realm view access doesn't expose sensitive credentials.
2. Should the role name be customizable?
Options:
global-view-admin(simpler, consistent)Recommendation: Option A - Keep it simple. Organizations can create additional custom roles if needed.
3. Should there be a separate permission for viewing audit events?
Options:
view-eventsin global-view-admin (complete read access)Recommendation: Option A - audit teams need complete visibility. Organizations requiring separation can use fine-grained authz v2.
Feedback and Iteration
This plan is open for community feedback. Key areas for input:
Beta Was this translation helpful? Give feedback.
All reactions