-
Notifications
You must be signed in to change notification settings - Fork 77
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
Create permissions for a locked down user role #314
Conversation
docs/users.md
Outdated
|
||
This role names are considered stable, and will continue to work in the future. | ||
|
||
User permissions are then split in more fine-grained permissions: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
User permissions are then split in more fine-grained permissions: | |
User permissions are then split into more fine-grained permissions: |
@@ -158,14 +158,14 @@ def __call__(self, user: User = Depends(current_user)): | |||
default_roles = [ | |||
role.strip() for role in auth_default_roles.split(",") | |||
] | |||
all_user_roles = list(set(user_roles + default_roles)) | |||
all_roles = list(set(user_roles + default_roles)) | |||
all_roles = sum((expand_role(role) for role in all_roles), []) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just making sure that the sum
is here used on purpose? The usage looks super weird to me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, this is basically concat (summing all the given lists). The idea is to get, well, list of all applicable permissions, instead a list of expanded permissions.
For example:
>>> test = [[1, 2, 3], [4, 5, 6], [7, 8]]
>>> sum(test, [])
[1, 2, 3, 4, 5, 6, 7, 8]
I'm not aware of a better idiom for concat in python. If that's unclear I can rewrite it to explicit for loop, or a bit complex list comprehension - I think this will work in this case too:
[perm for role in all_roles for perm in expand(role)]
Co-authored-by: Michał Praszmo <[email protected]>
Co-authored-by: Michał Praszmo <[email protected]>
Co-authored-by: Michał Praszmo <[email protected]>
Co-authored-by: Michał Praszmo <[email protected]>
Co-authored-by: Michał Praszmo <[email protected]>
Co-authored-by: Michał Praszmo <[email protected]>
Co-authored-by: Sharon Yankovich <[email protected]>
Your checklist for this pull request
What is the current behaviour?
There is no way to give more fine-grained permissions - everyone is
either an admin or a regulra user.
What is the new behaviour?
As documented in docs/users.md, the user role now is split into four sub-roles
can_view_queries
: Can view a query with a given ID, and matched files.can_manage_queries
: Can create, stop, and delete queries.can_list_queries
: Can list queries (for "recent jobs" tab).can_download_files
: Can download matched file contents.That list of sub-permissions is not considered stable yet - in future PR
I may decide to rename, remove or add some of them.
Test plan
Closing issues
fixes #302