-
Notifications
You must be signed in to change notification settings - Fork 192
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit adds the Roles API to the authentication module, enabling role-based access control features. - Added APIs to create, update, delete, get, and list roles. - Added Unit and Integration tests. Signed-off-by: Ryan Koo <[email protected]> Co-authored-by: Ryan Koo <[email protected]> Co-authored-by: Abhishek Gaikwad <[email protected]>
- Loading branch information
1 parent
6702cfa
commit b15826e
Showing
14 changed files
with
920 additions
and
105 deletions.
There are no files selected for viewing
This file contains 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,52 @@ | ||
# | ||
# Copyright (c) 2024, NVIDIA CORPORATION. All rights reserved. | ||
# | ||
|
||
from enum import IntFlag | ||
|
||
|
||
class AccessAttr(IntFlag): | ||
""" | ||
AccessAttr defines permissions as bitwise flags for access control (for more details, refer to the Go API). | ||
""" | ||
|
||
GET = 1 << 0 | ||
OBJ_HEAD = 1 << 1 | ||
PUT = 1 << 2 | ||
APPEND = 1 << 3 | ||
OBJ_DELETE = 1 << 4 | ||
OBJ_MOVE = 1 << 5 | ||
PROMOTE = 1 << 6 | ||
OBJ_UPDATE = 1 << 7 | ||
BCK_HEAD = 1 << 8 | ||
OBJ_LIST = 1 << 9 | ||
PATCH = 1 << 10 | ||
BCK_SET_ACL = 1 << 11 | ||
LIST_BUCKETS = 1 << 12 | ||
SHOW_CLUSTER = 1 << 13 | ||
CREATE_BUCKET = 1 << 14 | ||
DESTROY_BUCKET = 1 << 15 | ||
MOVE_BUCKET = 1 << 16 | ||
ADMIN = 1 << 17 | ||
|
||
ACCESS_RO = GET | OBJ_HEAD | LIST_BUCKETS | BCK_HEAD | OBJ_LIST | ||
ACCESS_RW = ACCESS_RO | PUT | APPEND | OBJ_DELETE | OBJ_MOVE | ||
ACCESS_CLUSTER = LIST_BUCKETS | CREATE_BUCKET | DESTROY_BUCKET | MOVE_BUCKET | ADMIN | ||
ACCESS_ALL = ( | ||
ACCESS_RW | ||
| ACCESS_CLUSTER | ||
| PROMOTE | ||
| OBJ_UPDATE | ||
| PATCH | ||
| BCK_SET_ACL | ||
| SHOW_CLUSTER | ||
) | ||
ACCESS_NONE = 0 | ||
|
||
@staticmethod | ||
def describe(perms: int) -> str: | ||
""" | ||
Returns a comma-separated string describing the permissions based on the provided bitwise flags. | ||
""" | ||
access_op = {v.value: v.name for v in AccessAttr} | ||
return ",".join(op for perm, op in access_op.items() if perms & perm) |
This file contains 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 was deleted.
Oops, something went wrong.
This file contains 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
Oops, something went wrong.