Skip to content

ref(api): Narrow request.user in token, app, auth and broadcast endpoints - #129414

Draft
gricha wants to merge 1 commit into
ref/typing-shared-principalfrom
ref/sa-narrow-api-a
Draft

gricha wants to merge 1 commit into
ref/typing-shared-principalfrom
ref/sa-narrow-api-a

Conversation

@gricha

@gricha gricha commented Oct 31, 2026

Copy link
Copy Markdown
Member

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.

The files leave the request.user mypy allowlist.

mypy allowlist: 161 → 147 files.

…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.

The files leave the `request.user` mypy allowlist.
@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Oct 31, 2026
@gricha
gricha added this pull request to stack #129364 October 31, 2026 02:27

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant