-
Notifications
You must be signed in to change notification settings - Fork 6
feat: migrate org scope access forward and rollback from/to authz policies #249
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
Changes from 14 commits
6da5271
3251754
543c3d2
ba20d27
d369fe0
e255e0d
9f0a35c
e4b50c3
10b7c53
28791a6
666629f
7ad67d0
e4f4eee
df9f70f
4b08cf1
573ec57
8a8d271
04f62e0
10158ac
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -44,6 +44,7 @@ | |
| "get_subject_role_assignments", | ||
| "get_subject_role_assignments_for_role_in_scope", | ||
| "get_subject_role_assignments_in_scope", | ||
| "get_all_role_assignments_per_scope_type", | ||
| "unassign_role_from_subject_in_scope", | ||
| "unassign_subject_from_all_roles", | ||
| ] | ||
|
|
@@ -553,3 +554,23 @@ def unassign_subject_from_all_roles(subject: SubjectData) -> bool: | |
| """ | ||
| enforcer = AuthzEnforcer.get_enforcer() | ||
| return enforcer.remove_filtered_grouping_policy(GroupingPolicyIndex.SUBJECT.value, subject.namespaced_key) | ||
|
|
||
|
|
||
| def get_all_role_assignments_per_scope_type(scope_types: list[type[ScopeData]]) -> list[RoleAssignmentData]: | ||
| """Get all role assignments matching any of the given scope types. | ||
|
|
||
| Loads all grouping policies from the enforcer and filters in Python. Casbin policies | ||
| store full scope keys (e.g., 'course-v1^course-v1:Org+Course+Run'), so there is no | ||
| way to query by scope type directly so the filtering must happen here. | ||
|
|
||
| Args: | ||
| scope_types: A list of ScopeData subclasses (not instances). Assignments matching | ||
| any of the given types are returned. | ||
|
|
||
| Returns: | ||
| list[RoleAssignmentData]: All assignments whose scope is an instance of any of the given scope types. | ||
| """ | ||
| return [ | ||
| role_assignment for role_assignment in get_role_assignments() | ||
| if isinstance(role_assignment.scope, tuple(scope_types)) | ||
|
mariajgrimaldi marked this conversation as resolved.
Outdated
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: I think the tuple cast could be moved above the return to avoid casting on each iteration. Alternatively, this function could accept a tuple directly, and the caller would pass it as such.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Totally! Thanks
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| ] | ||
Uh oh!
There was an error while loading. Please reload this page.