-
Notifications
You must be signed in to change notification settings - Fork 399
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
feat: admin role will be scoped to workspaces #3115
feat: admin role will be scoped to workspaces #3115
Conversation
79d785d
to
acd03d8
Compare
…feat/admin-role-will-be-scoped-to-workspaces
…feat/admin-role-will-be-scoped-to-workspaces
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.
LGTM! just some small suggestions that can be applied
@@ -63,7 +63,7 @@ def create_dataset(self, user: User, dataset: CreateDatasetRequest) -> BaseDatas | |||
if not accounts.get_workspace_by_name(self._db, workspace_name=dataset.workspace): | |||
raise EntityNotFoundError(name=dataset.workspace, type=Workspace) | |||
|
|||
if not is_authorized(user, DatasetPolicy.create): | |||
if not is_authorized(user, DatasetPolicy.create(workspace_name=dataset.workspace)): | |||
raise ForbiddenOperationError( | |||
"You don't have the necessary permissions to create datasets. Only administrators can create datasets" |
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.
When we write administrators, we mean both the role of owner
and admin
, right?
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, we can see the owner role as an extended role from admin
Co-authored-by: Gabriel Martín Blázquez <gmartinbdev@gmail.com>
for more information, see https://pre-commit.ci
Description
This PR brings changed to support 3 kinds of roles:
owner
: full access (oldadmin
role)admin
: workspace-level operations (create/delete datasets, add records,...)annotator
: same as before. Just for annotation purposes.Most of the tests have been revisited regarding the
mocked_client
fixture. I've also added variations o tests to support most roles as possible for the tested functionality. Since a huge number of changes have been included here, I will add more details in future PRs.Refs #3094
Type of change
(Please delete options that are not relevant. Remember to title the PR according to the type of change)
How Has This Been Tested
(Please describe the tests that you ran to verify your changes. And ideally, reference
tests
)Tests have been updated
Checklist