1616
1717def has_replay_permission (organization : Organization , user : User | AnonymousUser | None ) -> bool :
1818 """
19- Check if a user has permission to access replay data for an organization. This
20- change is backwards compatible with the existing behavior and introduces the
21- ability to granularly control replay access for organization members, irrespective
22- of their role.
23-
24- Logic:
25- - If feature flag is disabled, return True (existing behavior, everyone has access)
26- - User must be authenticated and a member of the org
27- - If no allowlist records exist for org, return True for all members
28- - If allowlist records exist, check if user's org membership is in the allowlist
29- - Return True if user is in allowlist, False otherwise
19+ Determine whether a user has permission to access replay data for a given organization.
20+
21+ Rules:
22+ - User must be authenticated and an active org member.
23+ - If the 'organizations:granular-replay-permissions' feature flag is OFF, all users have access.
24+ - If the 'sentry:granular-replay-permissions' org option is not set or falsy, all org members have access.
25+ - If no allowlist records exist for the organization but the feature flag is on, no one has access.
26+ - If allowlist records exist, only users explicitly present in the OrganizationMemberReplayAccess allowlist have access.
27+ - Returns True if allowed, False otherwise.
3028 """
3129 if not features .has ("organizations:granular-replay-permissions" , organization ):
3230 return True
@@ -51,7 +49,7 @@ def has_replay_permission(organization: Organization, user: User | AnonymousUser
5149 ).exists ()
5250
5351 if not allowlist_exists :
54- return True
52+ return False
5553
5654 has_access = OrganizationMemberReplayAccess .objects .filter (
5755 organization = organization , organizationmember = member
0 commit comments