File tree 6 files changed +55
-0
lines changed
6 files changed +55
-0
lines changed Original file line number Diff line number Diff line change @@ -347,6 +347,8 @@ yarn.lock @getsentry/owners-js-de
347
347
/static /app /views /settings /organizationAuth / @ getsentry/enterprise
348
348
/tests /sentry /api /endpoints /test_auth * .py @ getsentry/enterprise
349
349
350
+ /tests /sentry /api /test_data_secrecy.py @ getsentry/enterprise
351
+
350
352
/src /sentry /scim / @ getsentry/enterprise
351
353
/tests /sentry /api /test_scim * .py @ getsentry/enterprise
352
354
/src /sentry /tasks /integrations /github /pr_comment.py @ getsentry/enterprise @ AniketDas-Tekky
Original file line number Diff line number Diff line change @@ -85,6 +85,11 @@ class SuperuserRequired(SentryAPIException):
85
85
message = "You need to re-authenticate for superuser."
86
86
87
87
88
+ class DataSecrecyError (SentryAPIException ):
89
+ status_code = status .HTTP_401_UNAUTHORIZED
90
+ code = "data-secrecy"
91
+
92
+
88
93
class SudoRequired (SentryAPIException ):
89
94
status_code = status .HTTP_401_UNAUTHORIZED
90
95
code = "sudo-required"
Original file line number Diff line number Diff line change 5
5
from rest_framework import permissions
6
6
from rest_framework .request import Request
7
7
8
+ from sentry import features
8
9
from sentry .api .exceptions import (
10
+ DataSecrecyError ,
9
11
MemberDisabledOverLimit ,
10
12
SsoRequired ,
11
13
SuperuserRequired ,
@@ -122,6 +124,13 @@ def determine_access(
122
124
if org_context is None :
123
125
assert False , "Failed to fetch organization in determine_access"
124
126
127
+ if (
128
+ request .user
129
+ and request .user .is_superuser
130
+ and features .has ("organizations:enterprise-data-secrecy" , org_context .organization )
131
+ ):
132
+ raise DataSecrecyError ()
133
+
125
134
if request .auth and request .user and request .user .is_authenticated :
126
135
request .access = access .from_request_org_and_scopes (
127
136
request = request ,
Original file line number Diff line number Diff line change @@ -1371,6 +1371,8 @@ def SOCIAL_AUTH_DEFAULT_USERNAME() -> str:
1371
1371
"organizations:discover-basic" : True ,
1372
1372
# Enable discover 2 custom queries and saved queries
1373
1373
"organizations:discover-query" : True ,
1374
+ # Enables data secrecy mode
1375
+ "organizations:enterprise-data-secrecy" : False ,
1374
1376
# Enable archive/escalating issue workflow
1375
1377
"organizations:escalating-issues" : False ,
1376
1378
# Enable archive/escalating issue workflow in MS Teams
Original file line number Diff line number Diff line change 77
77
default_manager .add ("organizations:dashboards-import" , OrganizationFeature , FeatureHandlerStrategy .REMOTE )
78
78
default_manager .add ("organizations:discover" , OrganizationFeature , FeatureHandlerStrategy .INTERNAL )
79
79
default_manager .add ("organizations:discover-events-rate-limit" , OrganizationFeature , FeatureHandlerStrategy .REMOTE )
80
+ default_manager .add ("organizations:enterprise-data-secrecy" , OrganizationFeature , FeatureHandlerStrategy .INTERNAL )
80
81
default_manager .add ("organizations:grouping-stacktrace-ui" , OrganizationFeature , FeatureHandlerStrategy .REMOTE )
81
82
default_manager .add ("organizations:grouping-title-ui" , OrganizationFeature , FeatureHandlerStrategy .REMOTE )
82
83
default_manager .add ("organizations:grouping-tree-ui" , OrganizationFeature , FeatureHandlerStrategy .REMOTE )
Original file line number Diff line number Diff line change
1
+ from sentry .testutils import APITestCase
2
+ from sentry .testutils .helpers .features import with_feature
3
+
4
+
5
+ class SuperuserDataSecrecyTestCase (APITestCase ):
6
+ endpoint = "sentry-api-0-organization-details"
7
+ method = "get"
8
+
9
+ def setUp (self ):
10
+ super ().setUp ()
11
+ self .login_as (self .user )
12
+
13
+ @with_feature ("organizations:enterprise-data-secrecy" )
14
+ def test_superuser_no_access (self ):
15
+ """
16
+ Please contact the Enterprise team if your code change causes this test to fail
17
+ """
18
+ superuser = self .create_user (is_superuser = True )
19
+ self .login_as (superuser , superuser = True )
20
+
21
+ # superuser cannot access orgs with data secrecy
22
+ self .get_error_response (self .organization .slug , status_code = 401 )
23
+
24
+ def test_superuser_has_access (self ):
25
+ superuser = self .create_user (is_superuser = True )
26
+ self .login_as (superuser , superuser = True )
27
+
28
+ # superuser can access orgs without data secrecy
29
+ self .get_success_response (self .organization .slug )
30
+
31
+ def test_non_member_no_access (self ):
32
+ self .login_as (self .create_user ())
33
+ self .get_error_response (self .organization .slug , status_code = 403 )
34
+
35
+ def test_member_has_access (self ):
36
+ self .get_success_response (self .organization .slug )
You can’t perform that action at this time.
0 commit comments