Skip to content

ref(api): Narrow request.user in prompts and dashboard edit checks - #129629

Open
gricha wants to merge 1 commit into
ref/sa-feature-actorfrom
ref/sa-personal-state
Open

gricha wants to merge 1 commit into
ref/sa-feature-actorfrom
ref/sa-personal-state

Conversation

@gricha

@gricha gricha commented Nov 3, 2026 •

Copy link
Copy Markdown
Member

Two personal-state checks go through sentry.auth.principal, which drops them from the request.user allowlist (12 → 10).

  • Prompt dismissal (PUT prompts-activity) is a personal write, so it calls require_user(). A legacy API key got 201 while nothing was saved (the insert with no user failed and the error was swallowed); it now gets 401. Production had no PUT without a user in the last 30 days (0 of 3,456 sampled). A service account still gets 403 user-required.
  • Dashboard edit permission reads the caller through acting_user_id(), the same value for users and token callers. A service account on a restricted dashboard still gets 403, now the generic permission error instead of user-required.

Data export stays on the allowlist here: callers with no user created exports nobody could get, which #129637 fixes on its own.

test_api_key_cannot_dismiss fails without this change:

E   assert 201 == 401
FAILED tests/sentry/api/endpoints/test_prompts_activity.py::PutPromptsActivityTest::test_api_key_cannot_dismiss

With it, the prompts and dashboards suites pass.

@gricha
gricha requested a review from a team as a code owner November 3, 2026 00:35
@gricha
gricha added this pull request to stack #129572 November 3, 2026 00:35
@gricha
gricha requested review from a team as code owners November 3, 2026 00:35
@gricha
gricha requested review from cvxluo and skaasten November 3, 2026 00:35
@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Nov 3, 2026
@sentry

sentry Bot commented Nov 3, 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 changed the title ref(api): Narrow request.user in prompts, dashboard edit checks and data export ref(api): Narrow request.user in prompts and dashboard edit checks Nov 3, 2026
@gricha
gricha force-pushed the ref/sa-personal-state branch from 91a525c to 52cf22b Compare November 3, 2026 00:40
@gricha
gricha force-pushed the ref/sa-personal-state branch from 52cf22b to 284c44f Compare November 3, 2026 04:03
@gricha
gricha force-pushed the ref/sa-personal-state branch from 284c44f to 367601e Compare November 3, 2026 04:41
@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-personal-state branch from 367601e to 0791b14 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 requested review from a team as code owners November 3, 2026 20:01
@gricha
gricha requested review from a team as code owners November 3, 2026 20:01
@gricha
gricha force-pushed the ref/sa-personal-state branch from 0791b14 to 0113aed Compare November 3, 2026 20:02
@gricha
gricha force-pushed the ref/sa-personal-state branch from 0113aed to a9b81ed Compare November 3, 2026 20:09
@gricha
gricha force-pushed the ref/sa-personal-state branch from a9b81ed to fc252e1 Compare November 3, 2026 20:51
- Prompt dismissal is a personal write, so it uses require_user(). A
  legacy API key used to get 201 while nothing was saved; it now gets
  401. No production PUT without a user in the last 30 days.
- Dashboard edit permission reads the caller through acting_user_id(),
  which is the same value for users and token callers.

Drops both files from the request.user allowlist.
@gricha
gricha force-pushed the ref/sa-personal-state branch from fc252e1 to 1b79aa7 Compare November 3, 2026 21:10

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.

2 participants