Repository navigation
Conversation
…gement endpoints
The role/permission model (roles, permission points, resource scopes) was
only enforced by the web UI to decide which menus and buttons to render.
The single interceptor guarding every REST endpoint (PermissionInterceptor)
verified the login session but never looked at the caller's roles or
permission points, and no controller carried any permission annotation.
Consequently any authenticated user - even one restricted to a single
read-only permission point - could call the identity management REST API
directly and grant themselves the built-in administrator role or create a
hidden administrator account, taking over the platform and every Kafka
cluster it manages. The vendor's own Swagger annotation on the user-add
endpoint documented the gap ("用户新增接口,暂时没有考虑权限").
See didi#1263
This adds IdentityAuthorizationInterceptor, registered after the login
interceptor in WebConfig, which enforces the permission model server-side
for state-changing identity/config/resource-assignment endpoints:
- map "HTTP method + URL suffix -> required permission point" for the
user/role/dept/config endpoints of logi-security and the resource
permission assignment endpoints, using the permission ids seeded by
dml-logi.sql (1629 add user, 1637 create role, 1641 assign roles,
1623/1625/1627 config, 1595 system management for resource assignment)
- resolve the caller's permission points from their roles
(UserService -> UserRoleService -> RoleService.getPermissionTreeVO)
and reject with HTTP 403 when the required point is missing
- read-only endpoints keep their login-only behaviour so browsing is
unaffected; endpoints outside /logi-security/api/v1 are unchanged
- a missing or unknown operator is denied
Unit tests cover allow/deny for user and role management, role
assignment, resource permission assignment, unknown operators, read
endpoints and non-identity endpoints.
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.
Fixes #1263
Description
The role/permission model (roles, permission points, resource scopes) was only enforced by the web UI to decide which menus and buttons to render. The single interceptor guarding every REST endpoint (
PermissionInterceptor) verified the login session but never looked at the caller's roles or permission points, and no controller carried any permission annotation. Consequently any authenticated user — even one deliberately restricted to a single read-only permission point — could call the identity management REST API directly, grant themselves the built-in administrator role or create a hidden administrator account, and take over the platform and every Kafka cluster it manages. The vendor's own Swagger annotation on the user-add endpoint documented the gap directly ("用户新增接口,暂时没有考虑权限").Changes
IdentityAuthorizationInterceptor(km-rest), registered inWebConfigafterPermissionInterceptorso it runs once the login session is validated:UserService.getUserByUserName→UserRoleService.getRoleIdListByUserId→RoleService.getRoleDetailByRoleId().getPermissionTreeVO()) and rejects with HTTP 403 + a JSON error body when the required point is missing;/logi-security/api/v1are unchanged.km-persistence/src/main/resources/sql/dml-logi.sql, so no schema change is needed and custom roles created through the existing UI keep working.Test results
IdentityAuthorizationInterceptorTest(9 cases): allow/deny for user and role management writes, role assignment, resource permission assignment, unknown operators, read endpoints and non-identity endpoints. All pass.mvn -pl km-rest -am compileandmvn -pl km-rest -am test -Dtest=IdentityAuthorizationInterceptorTestpass on JDK 11.Signed-off-by: NUAAwqy 146524024+NUAAwqy@users.noreply.github.com