Repository navigation
feat(auth): Add mocked service account APIs - #127588
Merged
Merged
Conversation
gricha
marked this pull request as ready for review
October 15, 2026 21:13
trevor-e
approved these changes
Oct 15, 2026
gricha
force-pushed
the
feat/service-account-api-mocks
branch
from
October 16, 2026 16:36
d7e97e0 to
3a2a0cd
Compare
gricha
changed the base branch from
master
to
feat/service-account-control-silo-urls
October 16, 2026 16:36
gricha
force-pushed
the
feat/service-account-api-mocks
branch
from
October 16, 2026 16:36
3a2a0cd to
8251400
Compare
Base automatically changed from
feat/service-account-control-silo-urls
to
master
October 16, 2026 16:44
gricha
added a commit
that referenced
this pull request
Oct 16, 2026
Lists the service account management routes in the control silo URL patterns, so the frontend sends them to control. Frontend half of #127588, split out because frontend and backend deploy separately. It lands first: the patterns are harmless before the backend routes exist, and #127588's `test_no_missing_urls` passes once this is in.
gricha
force-pushed
the
feat/service-account-api-mocks
branch
from
October 16, 2026 16:45
8251400 to
42f1c5d
Compare
Contributor
Sentry Snapshot Testing
|
gricha
changed the base branch from
master
to
fix/backfill-watermark-test-order
October 16, 2026 17:58
gricha
force-pushed
the
feat/service-account-api-mocks
branch
from
October 16, 2026 17:58
b65aaab to
5634591
Compare
Add the service account management endpoints and the Seer-only viewer context endpoint behind organizations:service-accounts. They validate input and return canned data with the final response shape so Seer can integrate against the contract while the real implementation is built.
Split create and update request serializers so updates are optional in the schema, type the validated request data, and return real datetimes so the spec carries date-time formats.
Management endpoints live in the control silo with the service accounts. The Seer-only viewer context endpoint stays in the cell, since Seer only reaches its region's Sentry, and moves to its own module. Its response now mirrors agent token minting by including scopes, and OIDC scopes are no longer grantable.
Send the service account management routes to control in the API gateway and list them as control silo URLs. The Seer-only viewer context route stays on the cell.
gricha
force-pushed
the
feat/service-account-api-mocks
branch
from
October 16, 2026 18:36
5634591 to
023e40d
Compare
Service accounts take an optional projectIds list that limits project access when the organization doesn't have open membership, mirroring team membership for people. Callers can only grant projects in their organization that they can access.
Contributor
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit a2b6fb0. Configure here.
RpcBackedAccess.accessible_project_ids only covers team projects, so owners and managers couldn't grant projects outside their teams.
RudraPatel2003
pushed a commit
that referenced
this pull request
Oct 19, 2026
Lists the service account management routes in the control silo URL patterns, so the frontend sends them to control. Frontend half of #127588, split out because frontend and backend deploy separately. It lands first: the patterns are harmless before the backend routes exist, and #127588's `test_no_missing_urls` passes once this is in.
RudraPatel2003
pushed a commit
that referenced
this pull request
Oct 19, 2026
Mocked service account APIs behind `organizations:service-accounts`.
They return canned, fully typed responses and persist nothing, so Seer
can build against the contract while the real implementation lands
behind it.
- **Management** (control silo): `GET/POST
/organizations/{org}/service-accounts/` and `GET/PUT/DELETE .../{id}/`.
Reads need `org:read`, writes need `org:admin`. An optional `projectIds`
limits project access when the org doesn't have open membership (ignored
when it does, like team membership for people). You can only grant
scopes and projects you have.
- **Viewer context** (cell silo, Seer only): `POST
.../{id}/viewer-context/`. This is the service account counterpart of
agent token minting. Seer sends its org-only ViewerContext and gets back
`{viewerContext, expiresAt, scopes}`. It lives in the cell because Seer
only reaches its region's Sentry. Until the service account actor
exists, it returns Seer's own ViewerContext.
`owner` is a placeholder until the owning team has a tag.
Design: [Service
accounts](https://app.notion.com/p/sentry/Service-accounts-3ca8b10e4b5d81c88869fc35039c1cf8),
[build
order](https://app.notion.com/p/3f98b10e4b5d813596a8c966e8ff67db).
Depends on #127716 (control silo URL patterns, frontend), which lands
first.
---------
Co-authored-by: getsantry[bot] <66042841+getsantry[bot]@users.noreply.github.com>
This was referenced Oct 20, 2026
skaasten
added a commit
that referenced
this pull request
Oct 21, 2026
) This adds a new `sentry.service_accounts` Django app with the two control-silo tables that will back the mocked service account APIs from #127588. Nothing reads or writes them yet. The cell lookup and real endpoints come in follow-up PRs, and #128257 moves the mocked endpoints into the same app. - `ServiceAccount` holds the org, the name (unique per org, at most 64 characters), `scope_list`, `is_active` and `created_by`. Scopes are validated against `SENTRY_SCOPES` minus the OIDC scopes. - `ServiceAccountProject` holds the `projectIds` the API accepts. `project_id` is a `HybridCloudForeignKey`, so the tombstone cascade removes a link after its project is deleted. The app gets its own migration history (`service_accounts/0001_initial`) and app-prefixed tables (`service_accounts_serviceaccount`, `service_accounts_serviceaccountproject`), so it no longer competes for `sentry` migration numbers. Cells won't keep a replica table. They'll read accounts through a cached RPC to control, the same way they read users, and a `SERVICE_ACCOUNT_UPDATE` outbox (organization scope) will clear that cache. Both models are `ControlOutboxProducingModel`s and write that outbox for the account: `ServiceAccount` on every change, and `ServiceAccountProject` when links are added or removed. That includes the manager's bulk methods and the per-instance tombstone cascade. Nothing consumes the outbox yet; cache clearing lands with the RPC. Review notes: - Both models use `RelocationScope.Organization`. They're in the exhaustive backup fixtures, whose round-trip tests also check that `project_id` is remapped to the imported project instead of being copied. - `User.merge_to` now moves `created_by`. The user-merge coverage test requires this for every org-scoped model that references `User`. - The migration only creates new tables. Refs ENG-8829 <!-- junior-request-attribution:start --> via **shaun.kaasten**. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:slack%3AD0BAS2BU2TC%3A1792416182.597029 --> -- [View Junior Session](https://junior-prod.sentry.dev/conversations/slack%3AD0BAS2BU2TC%3A1792416182.597029) [[Sentry]](https://sentry.sentry.io/explore/conversations/slack%3AD0BAS2BU2TC%3A1792416182.597029/?project=4510944073809921) <!-- junior-session-footer:end --> --------- Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> Co-authored-by: shaun.kaasten <[email protected]>
2 tasks done
skaasten
added a commit
that referenced
this pull request
Oct 23, 2026
…se (#128239) Step 4 of the service accounts database design: the list, create, retrieve, update and delete endpoints from #127588 now read and write `ServiceAccount` and `ServiceAccountProject` instead of returning canned data. The request and response contract doesn't change, because Seer builds against it. - Create stores the account with `created_by` and its projects in one transaction. A duplicate name in the org returns 400, and the unique constraint covers the race between the check and the insert. - Update is partial. Sending `projectIds` replaces the set, and `null` or `[]` clears it. Leaving it out keeps the set. The account is saved even when only its projects change, because the account's outbox is what clears the cell's cached copy. - Delete is a hard delete. The project rows cascade, and the outbox clears the cell cache. - An account in another org returns 404. - The existing rules stay as they were: callers can only grant scopes they hold and projects they can access. - New audit log events: `SERVICE_ACCOUNT_ADD` (223), `SERVICE_ACCOUNT_EDIT` (224) and `SERVICE_ACCOUNT_REMOVE` (225). Review notes: - `Factories.create_service_account` lands here instead of in step 7, because the endpoint tests need it. - The viewer-context endpoint is still mocked. Its canned scopes moved into that module and are replaced in step 5. Stacked on #128182. Refs ENG-8829 <!-- junior-request-attribution:start --> via **shaun.kaasten**. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:slack%3AC0CA89MBDQB%3A1792514692.009019 --> -- [View Junior Session](https://junior-prod.sentry.dev/conversations/slack%3AC0CA89MBDQB%3A1792514692.009019) [[Sentry]](https://sentry.sentry.io/explore/conversations/slack%3AC0CA89MBDQB%3A1792514692.009019/?project=4510944073809921) <!-- junior-session-footer:end --> --------- Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> Co-authored-by: Shaun Kaasten <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Mocked service account APIs behind
organizations:service-accounts. They return canned, fully typed responses and persist nothing, so Seer can build against the contract while the real implementation lands behind it.GET/POST /organizations/{org}/service-accounts/andGET/PUT/DELETE .../{id}/. Reads needorg:read, writes needorg:admin. An optionalprojectIdslimits project access when the org doesn't have open membership (ignored when it does, like team membership for people). You can only grant scopes and projects you have.POST .../{id}/viewer-context/. This is the service account counterpart of agent token minting. Seer sends its org-only ViewerContext and gets back{viewerContext, expiresAt, scopes}. It lives in the cell because Seer only reaches its region's Sentry. Until the service account actor exists, it returns Seer's own ViewerContext.owneris a placeholder until the owning team has a tag.Design: Service accounts, build order.
Depends on #127716 (control silo URL patterns, frontend), which lands first.