feat(ecosystem): Open permissions for code mappings to members#39176
feat(ecosystem): Open permissions for code mappings to members#39176
Conversation
| "POST": ["org:read", "org:write", "org:admin", "org:integrations"], | ||
| "PUT": ["org:read", "org:write", "org:admin", "org:integrations"], | ||
| "DELETE": ["org:read", "org:write", "org:admin", "org:integrations"], | ||
| } |
There was a problem hiding this comment.
For posterity, the current change of permissions would look like this:
"GET": ["org:read", "org:write", "org:admin", "org:integrations"],
- "POST": [ "org:write", "org:admin", "org:integrations"],
+ "POST": ["org:read", "org:write", "org:admin", "org:integrations"],
- "PUT": [ "org:write", "org:admin", "org:integrations"],
+ "PUT": ["org:read", "org:write", "org:admin", "org:integrations"],
- "DELETE": [ "org:admin", "org:integrations"],
+ "DELETE": ["org:read", "org:write", "org:admin", "org:integrations"],sentry/src/sentry/api/bases/organization.py
Lines 97 to 103 in c605f45
There was a problem hiding this comment.
As per @NisanthanNanthakumar the member role doesn't have org:write here
sentry/src/sentry/conf/server.py
Lines 1652 to 1666 in f617782
| from rest_framework.response import Response | ||
|
|
||
| from sentry.api.base import region_silo_endpoint | ||
| from sentry.api.bases.organization import OrganizationEndpoint, OrganizationIntegrationsPermission |
There was a problem hiding this comment.
This grants any organization member to read, write, update and delete the details of code mappings. Is this correct?
There was a problem hiding this comment.
that's the goal i believe
src/sentry/api/endpoints/organization_codeowners_associations.py
Outdated
Show resolved
Hide resolved
| def test_basic_edit_from_member_permissions(self): | ||
| self.login_as(user=self.user2) | ||
| resp = self.make_put({"sourceRoot": "newRoot"}) | ||
| assert resp.status_code == 200 |
There was a problem hiding this comment.
This is updating an existing code mapping:
source_root: "/source/root" -> "newRoot"
This is the code mapping:
| def test_basic_post_from_member_permissions(self): | ||
| self.login_as(user=self.user2) | ||
| response = self.make_post() | ||
| assert response.status_code == 201, response.content |
There was a problem hiding this comment.
This creates a new code mapping by a non-superuser user:
| def test_member_can_access(self): | ||
| """ | ||
| Tests that users without the 'org:integrations' scope (i.e. Members) cannot access this endpoint. | ||
| Tests that users without the 'org:read' scope (i.e. Members) can access this endpoint. |
There was a problem hiding this comment.
I would like to know the difference between org:read vs org:write to feel comfortable about giving org:read access to the endpoints.
| Tests that users without the 'org:read' scope (i.e. Members) can access this endpoint. | ||
| """ | ||
| member = self.create_user("hernando@life.com") | ||
| self.create_member(user=member, organization=self.organization, role="member") |
There was a problem hiding this comment.
The creation of users and members in here are slightly different than the other setUp methods I have looked at:
sentry/tests/sentry/api/endpoints/test_organization_code_mappings.py
Lines 23 to 28 in c605f45
This is just an observation. It probably does not matter.
NisanthanNanthakumar
left a comment
There was a problem hiding this comment.
needs a small change
src/sentry/api/bases/organization.py
Outdated
| "GET": ["org:read", "org:write", "org:admin", "org:integrations"], | ||
| "POST": ["org:read", "org:write", "org:admin", "org:integrations"], | ||
| "PUT": ["org:read", "org:write", "org:admin", "org:integrations"], | ||
| "DELETE": ["org:read", "org:write", "org:admin", "org:integrations"], |
There was a problem hiding this comment.
@scttcper DELETE should not have org:read or org:write. The permissions to delete does not need to be loosened
| "POST": ["org:read", "org:write", "org:admin", "org:integrations"], | ||
| "PUT": ["org:read", "org:write", "org:admin", "org:integrations"], | ||
| "DELETE": ["org:read", "org:write", "org:admin", "org:integrations"], | ||
| } |
There was a problem hiding this comment.
As per @NisanthanNanthakumar the member role doesn't have org:write here
sentry/src/sentry/conf/server.py
Lines 1652 to 1666 in f617782
Allow members to add repos. See related PR #39176
Loosens permissions to anyone with
org:readfor code owners, code mappings.fixes https://getsentry.atlassian.net/browse/WOR-2186