Skip to content

ref(core): Narrow request.user in org, project and team endpoints - #129416

Merged
gricha merged 1 commit into
ref/sa-narrow-explorefrom
ref/sa-narrow-core
Nov 3, 2026
Merged

gricha merged 1 commit into
ref/sa-narrow-explorefrom
ref/sa-narrow-core

Conversation

@gricha

@gricha gricha commented Oct 31, 2026 •

Copy link
Copy Markdown
Member

Organization, project, team and SCIM endpoints read the caller through sentry.auth.principal: "my projects" and own-membership lookups use owned_by_acting_user(), "is this mine?" uses is_acting_user(), nullable actor ids use acting_user_id(), and org creation, the owner-only org list and username/email reads use require_user().

  • A service account gets an empty "my projects" (is_member:1, project counts) instead of 403. Requesting a closed team for a member still needs a user: master now refuses a service account with 403 before writing anything (feat(auth): Base service account access on allProjects #129343). A project PUT with isBookmarked saves the update and skips the bookmark, as it always did for token callers; before, it saved part of the update and then returned 403. New tests cover both.
  • Token callers no longer count teamless projects or invited (null-user) members as theirs.
  • Users and agents see no change.

Member management (member details PUT/DELETE, member invites, invite requests, get_allowed_org_roles) is deliberately unchanged: whether a service account may manage members is still open, so it keeps getting 403 user-required and those files stay on #129402's 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
@gricha
gricha removed this pull request from stack #129364 November 1, 2026 04:24
@gricha
gricha force-pushed the ref/sa-narrow-core branch from 7bae012 to 138bfdc Compare November 1, 2026 04:24
@gricha
gricha added this pull request to stack #129440 November 1, 2026 04:24
@gricha
gricha force-pushed the ref/sa-narrow-core branch from 138bfdc to b98b96b Compare November 1, 2026 04:57
@sentry

sentry Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Sentry Snapshot Testing

Name Added Removed Changed Renamed Unchanged Skipped Status
sentry-frontend
sentry-frontend
0 0 0 0 780 0 ✅ Unchanged

⚙️ sentry-frontend Snapshot Settings

@gricha
gricha force-pushed the ref/sa-narrow-core branch from b98b96b to d07a7d5 Compare November 2, 2026 19:55
@gricha
gricha force-pushed the ref/sa-narrow-core branch 2 times, most recently from dc98f14 to 1d1b750 Compare November 2, 2026 20:29
@gricha
gricha marked this pull request as ready for review November 2, 2026 20:57
@gricha
gricha requested review from azulus and skaasten November 2, 2026 20:57
@gricha
gricha requested review from a team as code owners November 2, 2026 20:57
@gricha
gricha removed this pull request from stack #129440 November 2, 2026 21:45
@gricha
gricha added this pull request to stack #129572 November 2, 2026 21:45
@gricha
gricha force-pushed the ref/sa-narrow-core branch from 1d1b750 to 0fc8e9b Compare November 2, 2026 22:08
@gricha
gricha force-pushed the ref/sa-narrow-core branch 3 times, most recently from e8cb365 to a097225 Compare November 2, 2026 23:18
@gricha
gricha force-pushed the ref/sa-narrow-core branch from a097225 to cb7cadd Compare November 2, 2026 23:31
@gricha
gricha requested a review from cvxluo November 2, 2026 23:35
@gricha
gricha force-pushed the ref/sa-narrow-core branch from cb7cadd to 483dfe6 Compare November 3, 2026 00:27
@gricha
gricha removed this pull request from stack #129572 November 3, 2026 06:52
@gricha
gricha added this pull request to stack #129650 November 3, 2026 06:52
@gricha
gricha force-pushed the ref/sa-narrow-core branch from 483dfe6 to 4afa863 Compare November 3, 2026 19:53
@gricha
gricha removed this pull request from stack #129650 November 3, 2026 19:53
@gricha
gricha added this pull request to stack #129747 November 3, 2026 19:54
@gricha
gricha force-pushed the ref/sa-narrow-core branch from 4afa863 to 2afca15 Compare November 3, 2026 20:09

@azulus azulus left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

owned_by_acting_user is a name which can read as a noun (i.e. which user owns this?) I'd consider broadly naming this is_owned_by_acting_user which more clearly states that it's a truthy check and/or query filters

gricha added a commit that referenced this pull request Nov 3, 2026
…29770)

Renames `owned_by_acting_user` to `is_owned_by_acting_user`, as
suggested in review on #129416. The old name can read as a noun ("which
user owns this?"); the new one reads as a condition. It still returns
the same `Q`.

This is a mechanical rename of all 40 uses in 13 files, including the
`src/AGENTS.md` guidance. No behavior change. getsentry doesn't use it.

The service-account stack rebases onto this once it lands.
Organization, project, team and SCIM endpoints read the caller through `sentry.auth.principal`: "my projects" and own-membership lookups use `owned_by_acting_user()`, "is this mine?" uses `is_acting_user()`, nullable actor ids use `acting_user_id()`, and org creation, the owner-only org list and username/email reads use `require_user()`.

- A service account gets an empty "my projects" (`is_member:1`, project counts) instead of 403. Requesting a closed team for a member now files an access request with no requester; before, it wrote the row and then returned 403. A project PUT with `isBookmarked` saves the update and skips the bookmark, as it always did for token callers; before, it saved part of the update and then returned 403. New tests cover all three.
- Token callers no longer count teamless projects or invited (null-user) members as theirs.
- Users and agents see no change.
@gricha
gricha force-pushed the ref/sa-narrow-core branch from 2afca15 to 559678b Compare November 3, 2026 20:51
@gricha
gricha merged commit 12d35f5 into master Nov 3, 2026
81 of 121 checks passed
@gricha
gricha deleted the ref/sa-narrow-core branch November 3, 2026 21:09
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.

3 participants