Repository navigation
ref(api): Narrow request.user in token, app, auth and broadcast endpoints - #129414
Conversation
6443968 to
6a1400a
Compare
Sentry Snapshot Testing
|
6a1400a to
7213368
Compare
7213368 to
c74c6bd
Compare
| unseen_queryset = queryset.exclude( | ||
| id__in=queryset.filter(broadcastseen__user_id=request.user.id).values("id") | ||
| id__in=queryset.filter( | ||
| owned_by_acting_user(request.user, "broadcastseen__user_id") |
There was a problem hiding this comment.
should this string be a const or linted somewhere? is that a thing?
4f15d46 to
02a0ff5
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 02a0ff5. Configure here.
| ): | ||
| warnings.append( | ||
| f"Your account ({request.user.email}) is not a member of the " | ||
| f"Your account ({require_user(request).email}) is not a member of the " |
There was a problem hiding this comment.
Login config 403s non-user callers
Low Severity
require_user is used only to interpolate an email into a warning on this public GET. For an authenticated caller with no user, such as a service account, that raises user-required and fails the whole login-config response instead of returning empty personal state.
Reviewed by Cursor Bugbot for commit 02a0ff5. Configure here.
| def get(self, request: Request) -> Response: | ||
| if request.user.is_authenticated: | ||
| user = User.objects.get(id=request.user.id) | ||
| user = User.objects.get(id=require_user(request).id) |
There was a problem hiding this comment.
API index 403s non-user reads
Low Severity
The API index GET treats a missing acting user as a hard require_user failure. An authenticated service account now gets 403 instead of {user: null} plus auth scopes, which is the empty personal state this read already returns for anonymous callers.
Reviewed by Cursor Bugbot for commit 02a0ff5. Configure here.
02a0ff5 to
1e44633
Compare
…ints Reads of `request.user` in 14 API endpoints (API tokens, applications, authorizations, auth index, assistant, broadcasts, invites, project transfer, attachments, internal mail) go through `sentry.auth.principal`: - "Mine" lookups (apps, authorizations, guides, seen broadcasts) use `owned_by_acting_user()`. - Logs, analytics and the nullable Activity/Broadcast creator use `acting_user_id()`. - Personal writes and user-only reads (tokens, assistant state, invite accept, transfer, email, 2FA) use `require_user()`. Users, agents and token callers see no change. A service account gets empty personal state on reads and 403 `user-required` on personal writes; most of these endpoints are control-silo, where service accounts don't authenticate yet.
1e44633 to
7eff818
Compare


Reads of
request.userin 14 API endpoints (API tokens, applications, authorizations, auth index, assistant, broadcasts, invites, project transfer, attachments, internal mail) go throughsentry.auth.principal:owned_by_acting_user().acting_user_id().require_user().Users, agents and token callers see no change. A service account gets empty personal state on reads and 403
user-requiredon personal writes; most of these endpoints are control-silo, where service accounts don't authenticate yet.