-
Notifications
You must be signed in to change notification settings - Fork 81
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
741 permissions refactoring #1114
741 permissions refactoring #1114
Conversation
decorators are moved to separate folder
Regarding the code layout for the permissions module, here are some suggestions:
|
backend/dataall/core/permissions/services/tenant_policy_service.py
Outdated
Show resolved
Hide resolved
backend/dataall/core/permissions/services/tenant_policy_service.py
Outdated
Show resolved
Hide resolved
backend/dataall/core/permissions/services/tenant_policy_service.py
Outdated
Show resolved
Hide resolved
backend/dataall/core/permissions/services/tenant_policy_service.py
Outdated
Show resolved
Hide resolved
backend/dataall/core/permissions/services/tenant_policy_service.py
Outdated
Show resolved
Hide resolved
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.
Halfway reviewed!
backend/dataall/core/permissions/services/tenant_policy_service.py
Outdated
Show resolved
Hide resolved
backend/dataall/core/permissions/services/tenant_policy_service.py
Outdated
Show resolved
Hide resolved
backend/dataall/core/permissions/db/tenant/tenant_policy_repositories.py
Outdated
Show resolved
Hide resolved
backend/dataall/core/permissions/db/tenant/tenant_policy_repositories.py
Outdated
Show resolved
Hide resolved
backend/dataall/core/permissions/db/tenant/tenant_policy_repositories.py
Outdated
Show resolved
Hide resolved
def has_user_tenant_permission(session, username: str, groups: [str], tenant_name: str, permission_name: str): | ||
if not username or not permission_name: | ||
return False | ||
tenant_policy: models.TenantPolicy = ( |
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.
Input validation should happen in api/resolver
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.
This one is not fixed (line 42 and 43)
backend/dataall/core/permissions/db/resource_policy/resource_policy_models.py
Outdated
Show resolved
Hide resolved
backend/dataall/core/permissions/db/resource_policy/resource_policy_repositories.py
Show resolved
Hide resolved
backend/dataall/core/permissions/db/resource_policy/resource_policy_repositories.py
Outdated
Show resolved
Hide resolved
backend/dataall/core/permissions/db/resource_policy/resource_policy_repositories.py
Outdated
Show resolved
Hide resolved
backend/dataall/core/permissions/db/resource_policy/resource_policy_repositories.py
Outdated
Show resolved
Hide resolved
backend/dataall/core/permissions/db/resource_policy/resource_policy_repositories.py
Show resolved
Hide resolved
backend/dataall/core/permissions/db/permission/permission_repositories.py
Show resolved
Hide resolved
As a general comment, I'd split this in at least 2 PRs (maybe a third isn't possible)
By doing so I wouldn't even review n1 and n2 |
@petrkalos sorry, this one is already very mixed( |
|
@@ -1,14 +0,0 @@ | |||
import logging |
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.
How is this operation handled now? Is there any impact for newly deployed data.all infra?
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.
I moved the definition to the new class TenantPolicyService
, as it seems to belong there.
This function is called in backend/api_handler.py
and backend/local_graphql_server.py
as it was before.
Hi @SofiaSazonova thanks for updating the PR. How have you tested that everything works as expected? This PR is pretty packed, but I think there are 2 improvements that we should implement once it is merged:
|
|
It looks good, the only thing is the part of testing. Could you include how have you tested this PR? |
@dlpzx please have a look. The last commit is better to be reviewed separately as there are a lot of moving of files there |
@@ -28,7 +28,14 @@ | |||
NamingConventionPattern, | |||
) | |||
from dataall.core.organizations.api.resolvers import Context, exceptions, get_organization | |||
from dataall.core.permissions.services import core_permissions | |||
from dataall.core.permissions.services.permissions_constants.environment_permissions import ( |
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.
We should place the permissions of a module inside the module itself as we do in any other module. For example, take notebooks, we define notebook_permissions
in modules/notebooks/service/notebooks_permissions.py
. In the same way environment permissions should be defined in core/environments/service/environment_permissions.py
And the same applies to other core modules in this last commit
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.
Check comment
Performed checks
|
Morning @SofiaSazonova! Thanks for adding the tests :) :) Instead of |
@dlpzx Organizations, groups and environments permissions can be moved to its own module, but tenants, resources and networks not, so IMHO it will be confusing: half of permissions here, half there. |
So the thing is that if I am developing something related to
|
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.
Looks good. Approving, @SofiaSazonova clarified offline that moving permissions around was causing circular dependencies. If we want to "modularize" core modules further we can do it in a separate PR
Feature or Bugfix
Detail
Relates
Security
Please answer the questions below briefly where applicable, or write
N/A
. Based onOWASP 10.
Does this PR introduce or modify any input fields or queries - this includes
fetching data from storage outside the application (e.g. a database, an S3 bucket)?N/A
Does this PR introduce any functionality or component that requires authorization? N/A
Are you using or adding any cryptographic features? N/A
Are you introducing any new policies/roles/users? N/A
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.