[#10782] feat(client-python): add authorization management support (User/Group/Role/Privilege CRUD)#10783
Open
sunyuhan1998 wants to merge 2 commits intoapache:mainfrom
Open
Conversation
…ort (User/Group/Role/Privilege CRUD) Add complete authorization management capabilities to the Python client, including User, Group, Role CRUD and permission grant/revoke operations. - Add User/Group/Role DTO, request/response classes with Builder pattern - Add authorization methods to GravitinoMetalake (add/get/remove/list users, groups, roles; grant/revoke roles and privileges) - Fix PrivilegeDTO enum serialization (tuple → lowercase string) to match Java server's WRITE_ENUMS_TO_LOWERCASE format - Add RemoveResponse for user/group deletion (server returns 'removed', not 'dropped') - Fix _GenericPrivilege/PrivilegeDTO __eq__ symmetry - Add unit tests (31) and integration tests (14)
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.
What changes were proposed in this pull request?
Add complete authorization management support to the Python client SDK, covering User, Group, Role, and Privilege CRUD operations. The implementation follows the existing Java SDK patterns and integrates with
GravitinoMetalakeas the entry point.Changes by layer:
API interfaces (
gravitino/api/authorization/):User,Group,Role— base interfaces with builder patternPrivilege/Privileges— privilege abstraction withNameenum (28 privilege types) andConditionenum (ALLOW/DENY)SecurableObject— securable object with metadata type, full name, and privilege listDTO layer (
gravitino/dto/authorization/):UserDTO,GroupDTO,RoleDTO,PrivilegeDTO,SecurableObjectDTO— immutable data transfer objects with builder, serialization, equality, andcan_bind_tosupportClient layer (
gravitino/client/):GravitinoMetalake— 20 new public methods covering the full authorization lifecycle:add_user,get_user,remove_user,list_users,list_user_namesadd_group,get_group,remove_group,list_groups,list_group_namescreate_role,get_role,delete_role,list_role_namesgrant_roles_to_user,revoke_roles_from_user,grant_roles_to_group,revoke_roles_from_group,grant_privileges_to_role,revoke_privileges_from_roleRequest/Response DTOs (
gravitino/dto/responses/):UserResponse,UserListResponse,GroupResponse,GroupListResponse,RoleResponse,RoleListResponse,RemoveResponseAuthorizationAddRequest,AuthorizationRemoveRequest,RoleCreateRequest,GrantRequest,RevokeRequest,PrivilegeGrantRequest,PrivilegeRevokeRequestWhy are the changes needed?
The Python SDK lacked authorization management capabilities. Users could not manage users, groups, roles, or privileges through the Python client, which is a core feature available in the Java SDK. This PR brings the Python SDK to feature parity with the Java SDK for authorization operations.
Does this PR introduce any user-facing change?
Yes. This PR adds 20 new public methods to
GravitinoMetalakeand several new public API/DTO classes. No existing methods or behaviors are changed.How was this patch tested?
Unit tests (31 test cases in
tests/unittests/):PrivilegeDTOand_GenericPrivilegeIntegration tests (14 test cases in
tests/integration/test_authorization.py):All code formatted with
ruffFix: #10782