[Feature] Implement role-based access control with ADMIN and READ_ONLY#4118
Open
xxubai wants to merge 4 commits intoapache:masterfrom
Open
[Feature] Implement role-based access control with ADMIN and READ_ONLY#4118xxubai wants to merge 4 commits intoapache:masterfrom
xxubai wants to merge 4 commits intoapache:masterfrom
Conversation
…n and role resolution
… and ConfigurationsTest.java
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.
Why are the changes needed?
Currently all authenticated Dashboard users have full admin privileges. This PR adds role-based access control (RBAC) to the Amoro Dashboard with two roles: ADMIN and READ_ONLY, allowing organizations to restrict write operations to authorized administrators.
Key motivations:
Close #4117
Brief change log
Backend —
amoro-amsRoleenum (authorization/Role.java) — DefinesADMINandREAD_ONLY.RoleResolver(authorization/RoleResolver.java) — Resolves user roles at login with priority: local users → admin-users whitelist → built-in admin → LDAP group → default-role.LdapGroupRoleResolver(authorization/LdapGroupRoleResolver.java) — Queries LDAP group membership via JNDI using a service account bind. Supports full DN lookup withContext.REFERRAL = "follow"for AD compatibility.LoginController— ReturnsroleinSessionInfo. Separates auth errors from role-resolution errors: auth failures show "invalid user or password", config errors show "server configuration error, contact administrator".DashboardServer— Enforces role-based API access;READ_ONLYusers receive HTTP 403 on write endpoints.LdapPasswdAuthenticationProvider— AddednormalizeUsername()to strip email domain suffix (xuba@cisco.com→xuba); added LDAP referral following.AmoroManagementConf— Added 10 new config options underhttp-server.authorization.*.Frontend —
amoro-webpermission.ts(utils/permission.ts) — Utility functionisReadOnly()that checks the user store.store/index.ts— Addedroleto user state.Sidebar.vue,Topbar.vue— Hide admin-only navigation for READ_ONLY users.request.ts— Store role from login response.login/index.vue— Pass role from login API response.Admin role UI

Read-only role UI

How was this patch tested?
Add some test cases that check the changes thoroughly including negative and positive cases if possible
RoleResolverTest— Tests role resolution priority: local users, admin-users whitelist, built-in admin, LDAP fallback, default role, authorization-disabled backward compatibility.LdapGroupRoleResolverTest— Tests member matching (DN-style, CN-style, uid-style, plain username, case-insensitive), LDAP error propagation, config validation.HttpAuthenticationFactoryTest— Tests authentication provider factory.Add screenshots for manual tests if appropriate
Run test locally before making a pull request
Documentation
ams-config.mdupdated with config reference and RBAC examples;config.yamltemplate includes commented-out examples)