-
Notifications
You must be signed in to change notification settings - Fork 848
[#11094] feat(client-python): add Group authorization management #11109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
jerryshao
merged 6 commits into
apache:main
from
sunyuhan1998:feature/python-sdk-auth-group
May 22, 2026
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
09535ce
[#11094] feat(client-python): add Group authorization management
sunyuhan1998 ef8fac3
[#11094] fix(client-python): Auto-enable authorization in group integ…
sunyuhan1998 8b22cf9
[#11094] fix(client-python): fix group IT config not applied in CI
sunyuhan1998 8872c19
[#11094] fix(client-python): remove unnecessary audit null check in G…
sunyuhan1998 ce1b20c
[#11094] fix(client-python): address review feedback for Group auth
sunyuhan1998 f8906f3
[#11094] fix(client-python): fix IT tearDown corrupting server config
sunyuhan1998 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
47 changes: 47 additions & 0 deletions
47
clients/client-python/gravitino/api/authorization/group.py
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| # Licensed to the Apache Software Foundation (ASF) under one | ||
| # or more contributor license agreements. See the NOTICE file | ||
| # distributed with this work for additional information | ||
| # regarding copyright ownership. The ASF licenses this file | ||
| # to you under the Apache License, Version 2.0 (the | ||
| # "License"); you may not use this file except in compliance | ||
| # with the License. You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, | ||
| # software distributed under the License is distributed on an | ||
| # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| # KIND, either express or implied. See the License for the | ||
| # specific language governing permissions and limitations | ||
| # under the License. | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| from abc import abstractmethod | ||
|
|
||
| from gravitino.api.auditable import Auditable | ||
|
|
||
|
|
||
| class Group(Auditable): | ||
| """The interface of a group. The group is a collection of users in the authorization system.""" | ||
|
|
||
| @abstractmethod | ||
| def name(self) -> str: | ||
| """ | ||
| The name of the group. | ||
|
|
||
| Returns: | ||
| str: The name of the group. | ||
| """ | ||
| raise NotImplementedError() | ||
|
|
||
| @abstractmethod | ||
| def roles(self) -> list[str]: | ||
| """ | ||
| The roles of the group. A group can have multiple roles. | ||
| Every role binds several privileges. | ||
|
|
||
| Returns: | ||
| list[str]: The role names of the group. | ||
| """ | ||
| raise NotImplementedError() |
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
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
91 changes: 91 additions & 0 deletions
91
clients/client-python/gravitino/dto/authorization/group_dto.py
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| # Licensed to the Apache Software Foundation (ASF) under one | ||
| # or more contributor license agreements. See the NOTICE file | ||
| # distributed with this work for additional information | ||
| # regarding copyright ownership. The ASF licenses this file | ||
| # to you under the Apache License, Version 2.0 (the | ||
| # "License"); you may not use this file except in compliance | ||
| # with the License. You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, | ||
| # software distributed under the License is distributed on an | ||
| # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| # KIND, either express or implied. See the License for the | ||
| # specific language governing permissions and limitations | ||
| # under the License. | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| from dataclasses import dataclass, field | ||
| from typing import Optional | ||
|
|
||
| from dataclasses_json import config, dataclass_json | ||
|
|
||
| from gravitino.api.authorization.group import Group | ||
| from gravitino.dto.audit_dto import AuditDTO | ||
|
|
||
|
|
||
| @dataclass_json | ||
| @dataclass | ||
| class GroupDTO(Group): | ||
| """Represents a Group Data Transfer Object (DTO).""" | ||
|
|
||
| _name: str = field(metadata=config(field_name="name")) | ||
| _roles: tuple[str, ...] = field( | ||
| default_factory=tuple, metadata=config(field_name="roles") | ||
| ) | ||
| _audit: Optional[AuditDTO] = field( | ||
| default=None, metadata=config(field_name="audit") | ||
| ) | ||
|
|
||
| def __eq__(self, other: object) -> bool: | ||
| if not isinstance(other, GroupDTO): | ||
| return False | ||
| return ( | ||
| self._name == other._name | ||
| and self._roles == other._roles | ||
| and self._audit == other._audit | ||
| ) | ||
|
|
||
| def __hash__(self) -> int: | ||
| return hash((self._name, tuple(self._roles), self._audit)) | ||
|
|
||
| @staticmethod | ||
| def builder() -> GroupDTO.Builder: | ||
| return GroupDTO.Builder() | ||
|
|
||
| def name(self) -> str: | ||
| return self._name | ||
|
|
||
| def roles(self) -> list[str]: | ||
| return list(self._roles) if self._roles else [] | ||
|
|
||
| def audit_info(self) -> Optional[AuditDTO]: | ||
| return self._audit | ||
|
|
||
| class Builder: | ||
| """Helper class to build a GroupDTO object.""" | ||
|
|
||
| def __init__(self) -> None: | ||
| self._name: str = "" | ||
| self._roles: tuple[str, ...] = () | ||
| self._audit: Optional[AuditDTO] = None | ||
|
|
||
| def with_name(self, name: str) -> GroupDTO.Builder: | ||
| self._name = name | ||
| return self | ||
|
|
||
| def with_roles(self, roles: list[str]) -> GroupDTO.Builder: | ||
| if roles is not None: | ||
| self._roles = tuple(roles) | ||
| return self | ||
|
|
||
| def with_audit(self, audit: AuditDTO) -> GroupDTO.Builder: | ||
| self._audit = audit | ||
| return self | ||
|
|
||
| def build(self) -> GroupDTO: | ||
| if not self._name: | ||
| raise ValueError("name cannot be null or empty") | ||
| return GroupDTO(self._name, self._roles, self._audit) | ||
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.