-
Notifications
You must be signed in to change notification settings - Fork 6
[FC-0099] refactor!: consider global scope as wildcard managed by ScopeData #132
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 4 commits
38a0573
5bc85e1
5e8453d
4c1577a
eb540c5
685ebb1
cf2fa62
e802390
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 |
|---|---|---|
|
|
@@ -181,6 +181,14 @@ def __call__(cls, *args, **kwargs): | |
| if cls is not ScopeData: | ||
| return super().__call__(*args, **kwargs) | ||
|
|
||
| # When working with global scopes, we can't determine subclass with an external_key since | ||
| # a global scope it's not attached to a specific resource type. So we only use * as an | ||
| # an external_key to mean generic scope which maps to base ScopeData class. | ||
| # The only remaining issue is that internally the namespace key used in policies will be | ||
| # The generic scope namespace (sc^*), so we need to handle that case here. | ||
| if kwargs.get("external_key") == GENERIC_SCOPE_WILDCARD: | ||
|
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. Generic or global?
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. If this is a question on naming, I think global is clearer.
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. I initially used generic scope cause this scope can be specialized into other scopes: content libraries, courses... But this might be too ambiguous. It might make sense making it global when not specialized?
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. Global makes more sense to me 👍 |
||
| return super().__call__(*args, **kwargs) | ||
|
|
||
| if "namespaced_key" in kwargs: | ||
| scope_cls = cls.get_subclass_by_namespaced_key(kwargs["namespaced_key"]) | ||
| return super(ScopeMeta, scope_cls).__call__(*args, **kwargs) | ||
|
|
@@ -303,6 +311,11 @@ class ScopeData(AuthZData, metaclass=ScopeMeta): | |
| 'sc^generic_scope' | ||
| """ | ||
|
|
||
| # The 'sc' namespace is used for generic scopes that aren't tied to a specific resource type. | ||
| # This base class supports: | ||
| # 1. Global scopes (external_key='*') that apply across all resource types | ||
| # 2. Custom generic scopes that don't map to specific domain objects | ||
| # Subclasses like ContentLibraryData ('lib') represent concrete resource types. | ||
| NAMESPACE: ClassVar[str] = "sc" | ||
|
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. @bmtcril: remember we talked about the usage of this generic scope? I think we found one! I was thinking of changing NAMESPACE to an empty string cause I'm not sure how descriptive is FYI @MaferMazu @BryanttV
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. What did "sc" stand for?
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. Maybe we could change it to something related to "anonymous", as if it's supposed to identify scopes that don't map to specific objects, then they are "anonymous"? Thinking on the usage of a namespaced key, it would look something like: "anon^*" Otherwise if we use an empty string, it woud be like "^*" right? Won't this cause confusion because of the "missing" namespace?
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.
I think it will! Considering what I said here, https://github.com/openedx/openedx-authz/pull/132/files#r2486208488, instead of anonymous, should we use
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. I think global makes the most sense, but whatever we use needs to be something that will never get a real value of the same name, right?
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. Exactly! What about these?
In all cases, having something like
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. My understanding here is that in the case of the But, if at some point we add some more generic permissions, like
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. The thing with can_create_libraries is that we can't actually evaluate it with a concrete library, but only against the instance (not sure how to call it) so it could be similar to can_create but only checked in context of libraries - hopefully I'm not getting all of this mixed up (so please correct me if I'm wrong!) 😅
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. Oh you are right, for can_create_libraries it doesn't make sense to specify a concrete library, so global makes sense there. It would make sense for something like can_edit_library instead. |
||
|
|
||
| @classmethod | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.