Skip to content

feat(seer-infra-telemetry): Add DatadogIdentityProvider for OAuth2#117035

Merged
srest2021 merged 58 commits into
masterfrom
srest2021/CW-1469
Jun 11, 2026
Merged

feat(seer-infra-telemetry): Add DatadogIdentityProvider for OAuth2#117035
srest2021 merged 58 commits into
masterfrom
srest2021/CW-1469

Conversation

@srest2021

@srest2021 srest2021 commented Jun 5, 2026

Copy link
Copy Markdown
Member

Depends on #117026

Adds DatadogIdentityProvider, an OAuth2 identity provider for Datadog using PKCE and DCR.

@linear-code

linear-code Bot commented Jun 5, 2026

Copy link
Copy Markdown

CW-1469

@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Jun 5, 2026
@srest2021 srest2021 changed the title add datadog identity provider feat(identity): Add Datadog identity provider (OAuth2 + PKCE) Jun 5, 2026
Comment thread src/sentry/identity/datadog/provider.py
@srest2021 srest2021 changed the title feat(seer-infra-telemetry): Add Datadog identity provider for OAuth2 feat(seer-infra-telemetry): Add DatadogIdentityProvider for OAuth2 Jun 10, 2026
Comment thread src/sentry/identity/datadog/provider.py Outdated
Comment thread tests/sentry/identity/datadog/test_provider.py Outdated
Comment thread tests/sentry/identity/datadog/test_provider.py Outdated
Comment thread src/sentry/identity/datadog/provider.py Outdated
Comment thread src/sentry/identity/datadog/provider.py Outdated
Comment thread src/sentry/identity/datadog/provider.py
…copes

Replace GET /api/v2/current_user with MCP datadog://mcp/whoami resource
for user identity resolution. Add resource-specific OAuth scopes alongside
mcp_read for tool access. Update tests to match new whoami response format.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@srest2021 srest2021 force-pushed the srest2021/CW-1469 branch from 6fe33f1 to b4d8533 Compare June 10, 2026 23:48
Comment thread src/sentry/identity/datadog/provider.py
Comment thread src/sentry/identity/datadog/provider.py Outdated

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 1b9dd17. Configure here.

json={"jsonrpc": "2.0", "id": 1, "method": "initialize", "params": {}},
)
init_resp.raise_for_status()
headers["Mcp-Session-Id"] = init_resp.headers["mcp-session-id"]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Missing MCP session header crash

Medium Severity

In get_user_info, the MCP initialize response uses subscript access on init_resp.headers["mcp-session-id"]. If the server returns HTTP 200 without that header (optional per discussion), linking raises an uncaught KeyError instead of a controlled identity error like the whoami body parsing below.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 1b9dd17. Configure here.

Comment thread src/sentry/identity/datadog/provider.py Outdated
Comment thread tests/sentry/identity/datadog/test_provider.py
@srest2021 srest2021 merged commit 092af44 into master Jun 11, 2026
85 checks passed
@srest2021 srest2021 deleted the srest2021/CW-1469 branch June 11, 2026 18:21
shashjar added a commit that referenced this pull request Jun 16, 2026
…API endpoints (#117478)

Resolves
https://linear.app/getsentry/issue/CW-1499/monitoring-provider-connection-api-endpoints.

Adds API endpoints for listing, connecting, and disconnecting monitoring
providers (currently Datadog & GCP). These endpoints wrap the existing
identity pipeline to let users initiate the per-user OAuth flow for
connecting their monitoring provider accounts to Sentry. The identity
providers for Datadog & GCP were previously implemented in
#117035 &
#117279, respectively.

All endpoints are gated behind the `organizations:seer-infra-telemetry`
feature flag, which is enabled only internally in the Sentry org for
now. Note that monitoring provider connections are per-user (each user
links their own account via OAuth), not per-organization.

There is some provider-specific config baked into this implementation:
Datadog requires a `site` parameter in the POST body (e.g.
`datadoghq.com`) for site resolution, while GCP needs no extra config.
For Datadog, the `IdentityProvider` is not created in the POST endpoint;
it is auto-created by `IdentityPipeline.finish_pipeline()` using the
Datadog org UUID from the MCP whoami response as the external ID (see
#117491 &
#117705). For GCP, the
`IdentityProvider` is created upfront by the endpoint.

`GET /api/0/organizations/{org}/monitoring-providers/` lists the
available providers and the current user's connection status. This will
be used to inform the monitoring provider settings UI tracked in
https://linear.app/getsentry/issue/CW-1500/monitoring-providers-settings-page.

`POST /api/0/organizations/{org}/monitoring-providers/{provider}/`
represents a request to connect a given monitoring provider for a given
user. It initiates the OAuth flow and returns a redirect URL to the
provider's authorize page, based on the identity pipeline for that
provider.

`DELETE /api/0/organizations/{org}/monitoring-providers/{provider}/`
represents a request to disconnect/delete a given monitoring provider
for a given user. It deletes the current user's linked identity for that
provider, if one exists.

**Note on support for a single user connecting multiple Datadog orgs:**
- For v0, we're mainly considering the case where a user has a single
Datadog org connected, but in the future we will support multiple
- The GET endpoint currently collapses to one entry per provider type
(shows `connected: true` if _any_ exist
- The POST endpoint currently allows multiple connections to be created
- The DELETE endpoint currently deletes all identities for the provider
(`idp__type=provider_key`)

---------

Co-authored-by: getsantry[bot] <66042841+getsantry[bot]@users.noreply.github.com>
shashjar added a commit that referenced this pull request Jun 16, 2026
…API endpoints (#117854)

Recreated after reverting
#117478.

Depends on #117851.

Resolves
https://linear.app/getsentry/issue/CW-1499/monitoring-provider-connection-api-endpoints.

Adds API endpoints for listing, connecting, and disconnecting monitoring
providers (currently Datadog & GCP). These endpoints wrap the existing
identity pipeline to let users initiate the per-user OAuth flow for
connecting their monitoring provider accounts to Sentry. The identity
providers for Datadog & GCP were previously implemented in
#117035 &
#117279, respectively.

All endpoints are gated behind the `organizations:seer-infra-telemetry`
feature flag, which is enabled only internally in the Sentry org for
now. Note that monitoring provider connections are per-user (each user
links their own account via OAuth), not per-organization.

There is some provider-specific config baked into this implementation:
Datadog requires a `site` parameter in the POST body (e.g.
`datadoghq.com`) for site resolution, while GCP needs no extra config.
For Datadog, the `IdentityProvider` is not created in the POST endpoint;
it is auto-created by `IdentityPipeline.finish_pipeline()` using the
Datadog org UUID from the MCP whoami response as the external ID (see
#117491 &
#117705). For GCP, the
`IdentityProvider` is created upfront by the endpoint.

`GET /api/0/organizations/{org}/monitoring-providers/` lists the
available providers and the current user's connection status. This will
be used to inform the monitoring provider settings UI tracked in
https://linear.app/getsentry/issue/CW-1500/monitoring-providers-settings-page.

`POST /api/0/organizations/{org}/monitoring-providers/{provider}/`
represents a request to connect a given monitoring provider for a given
user. It initiates the OAuth flow and returns a redirect URL to the
provider's authorize page, based on the identity pipeline for that
provider.

`DELETE /api/0/organizations/{org}/monitoring-providers/{provider}/`
represents a request to disconnect/delete a given monitoring provider
for a given user. It deletes the current user's linked identity for that
provider, if one exists.

**Note on support for a single user connecting multiple Datadog orgs:**
- For v0, we're mainly considering the case where a user has a single
Datadog org connected, but in the future we will support multiple
- The GET endpoint currently collapses to one entry per provider type
(shows `connected: true` if _any_ exist
- The POST endpoint currently allows multiple connections to be created
- The DELETE endpoint currently deletes all identities for the provider
(`idp__type=provider_key`)

---------

Co-authored-by: getsantry[bot] <66042841+getsantry[bot]@users.noreply.github.com>
vgrozdanic pushed a commit that referenced this pull request Jun 16, 2026
…API endpoints (#117478)

Resolves
https://linear.app/getsentry/issue/CW-1499/monitoring-provider-connection-api-endpoints.

Adds API endpoints for listing, connecting, and disconnecting monitoring
providers (currently Datadog & GCP). These endpoints wrap the existing
identity pipeline to let users initiate the per-user OAuth flow for
connecting their monitoring provider accounts to Sentry. The identity
providers for Datadog & GCP were previously implemented in
#117035 &
#117279, respectively.

All endpoints are gated behind the `organizations:seer-infra-telemetry`
feature flag, which is enabled only internally in the Sentry org for
now. Note that monitoring provider connections are per-user (each user
links their own account via OAuth), not per-organization.

There is some provider-specific config baked into this implementation:
Datadog requires a `site` parameter in the POST body (e.g.
`datadoghq.com`) for site resolution, while GCP needs no extra config.
For Datadog, the `IdentityProvider` is not created in the POST endpoint;
it is auto-created by `IdentityPipeline.finish_pipeline()` using the
Datadog org UUID from the MCP whoami response as the external ID (see
#117491 &
#117705). For GCP, the
`IdentityProvider` is created upfront by the endpoint.

`GET /api/0/organizations/{org}/monitoring-providers/` lists the
available providers and the current user's connection status. This will
be used to inform the monitoring provider settings UI tracked in
https://linear.app/getsentry/issue/CW-1500/monitoring-providers-settings-page.

`POST /api/0/organizations/{org}/monitoring-providers/{provider}/`
represents a request to connect a given monitoring provider for a given
user. It initiates the OAuth flow and returns a redirect URL to the
provider's authorize page, based on the identity pipeline for that
provider.

`DELETE /api/0/organizations/{org}/monitoring-providers/{provider}/`
represents a request to disconnect/delete a given monitoring provider
for a given user. It deletes the current user's linked identity for that
provider, if one exists.

**Note on support for a single user connecting multiple Datadog orgs:**
- For v0, we're mainly considering the case where a user has a single
Datadog org connected, but in the future we will support multiple
- The GET endpoint currently collapses to one entry per provider type
(shows `connected: true` if _any_ exist
- The POST endpoint currently allows multiple connections to be created
- The DELETE endpoint currently deletes all identities for the provider
(`idp__type=provider_key`)

---------

Co-authored-by: getsantry[bot] <66042841+getsantry[bot]@users.noreply.github.com>
vgrozdanic pushed a commit that referenced this pull request Jun 16, 2026
…API endpoints (#117854)

Recreated after reverting
#117478.

Depends on #117851.

Resolves
https://linear.app/getsentry/issue/CW-1499/monitoring-provider-connection-api-endpoints.

Adds API endpoints for listing, connecting, and disconnecting monitoring
providers (currently Datadog & GCP). These endpoints wrap the existing
identity pipeline to let users initiate the per-user OAuth flow for
connecting their monitoring provider accounts to Sentry. The identity
providers for Datadog & GCP were previously implemented in
#117035 &
#117279, respectively.

All endpoints are gated behind the `organizations:seer-infra-telemetry`
feature flag, which is enabled only internally in the Sentry org for
now. Note that monitoring provider connections are per-user (each user
links their own account via OAuth), not per-organization.

There is some provider-specific config baked into this implementation:
Datadog requires a `site` parameter in the POST body (e.g.
`datadoghq.com`) for site resolution, while GCP needs no extra config.
For Datadog, the `IdentityProvider` is not created in the POST endpoint;
it is auto-created by `IdentityPipeline.finish_pipeline()` using the
Datadog org UUID from the MCP whoami response as the external ID (see
#117491 &
#117705). For GCP, the
`IdentityProvider` is created upfront by the endpoint.

`GET /api/0/organizations/{org}/monitoring-providers/` lists the
available providers and the current user's connection status. This will
be used to inform the monitoring provider settings UI tracked in
https://linear.app/getsentry/issue/CW-1500/monitoring-providers-settings-page.

`POST /api/0/organizations/{org}/monitoring-providers/{provider}/`
represents a request to connect a given monitoring provider for a given
user. It initiates the OAuth flow and returns a redirect URL to the
provider's authorize page, based on the identity pipeline for that
provider.

`DELETE /api/0/organizations/{org}/monitoring-providers/{provider}/`
represents a request to disconnect/delete a given monitoring provider
for a given user. It deletes the current user's linked identity for that
provider, if one exists.

**Note on support for a single user connecting multiple Datadog orgs:**
- For v0, we're mainly considering the case where a user has a single
Datadog org connected, but in the future we will support multiple
- The GET endpoint currently collapses to one entry per provider type
(shows `connected: true` if _any_ exist
- The POST endpoint currently allows multiple connections to be created
- The DELETE endpoint currently deletes all identities for the provider
(`idp__type=provider_key`)

---------

Co-authored-by: getsantry[bot] <66042841+getsantry[bot]@users.noreply.github.com>
billyvg pushed a commit that referenced this pull request Jun 17, 2026
…API endpoints (#117478)

Resolves
https://linear.app/getsentry/issue/CW-1499/monitoring-provider-connection-api-endpoints.

Adds API endpoints for listing, connecting, and disconnecting monitoring
providers (currently Datadog & GCP). These endpoints wrap the existing
identity pipeline to let users initiate the per-user OAuth flow for
connecting their monitoring provider accounts to Sentry. The identity
providers for Datadog & GCP were previously implemented in
#117035 &
#117279, respectively.

All endpoints are gated behind the `organizations:seer-infra-telemetry`
feature flag, which is enabled only internally in the Sentry org for
now. Note that monitoring provider connections are per-user (each user
links their own account via OAuth), not per-organization.

There is some provider-specific config baked into this implementation:
Datadog requires a `site` parameter in the POST body (e.g.
`datadoghq.com`) for site resolution, while GCP needs no extra config.
For Datadog, the `IdentityProvider` is not created in the POST endpoint;
it is auto-created by `IdentityPipeline.finish_pipeline()` using the
Datadog org UUID from the MCP whoami response as the external ID (see
#117491 &
#117705). For GCP, the
`IdentityProvider` is created upfront by the endpoint.

`GET /api/0/organizations/{org}/monitoring-providers/` lists the
available providers and the current user's connection status. This will
be used to inform the monitoring provider settings UI tracked in
https://linear.app/getsentry/issue/CW-1500/monitoring-providers-settings-page.

`POST /api/0/organizations/{org}/monitoring-providers/{provider}/`
represents a request to connect a given monitoring provider for a given
user. It initiates the OAuth flow and returns a redirect URL to the
provider's authorize page, based on the identity pipeline for that
provider.

`DELETE /api/0/organizations/{org}/monitoring-providers/{provider}/`
represents a request to disconnect/delete a given monitoring provider
for a given user. It deletes the current user's linked identity for that
provider, if one exists.

**Note on support for a single user connecting multiple Datadog orgs:**
- For v0, we're mainly considering the case where a user has a single
Datadog org connected, but in the future we will support multiple
- The GET endpoint currently collapses to one entry per provider type
(shows `connected: true` if _any_ exist
- The POST endpoint currently allows multiple connections to be created
- The DELETE endpoint currently deletes all identities for the provider
(`idp__type=provider_key`)

---------

Co-authored-by: getsantry[bot] <66042841+getsantry[bot]@users.noreply.github.com>
billyvg pushed a commit that referenced this pull request Jun 17, 2026
…API endpoints (#117854)

Recreated after reverting
#117478.

Depends on #117851.

Resolves
https://linear.app/getsentry/issue/CW-1499/monitoring-provider-connection-api-endpoints.

Adds API endpoints for listing, connecting, and disconnecting monitoring
providers (currently Datadog & GCP). These endpoints wrap the existing
identity pipeline to let users initiate the per-user OAuth flow for
connecting their monitoring provider accounts to Sentry. The identity
providers for Datadog & GCP were previously implemented in
#117035 &
#117279, respectively.

All endpoints are gated behind the `organizations:seer-infra-telemetry`
feature flag, which is enabled only internally in the Sentry org for
now. Note that monitoring provider connections are per-user (each user
links their own account via OAuth), not per-organization.

There is some provider-specific config baked into this implementation:
Datadog requires a `site` parameter in the POST body (e.g.
`datadoghq.com`) for site resolution, while GCP needs no extra config.
For Datadog, the `IdentityProvider` is not created in the POST endpoint;
it is auto-created by `IdentityPipeline.finish_pipeline()` using the
Datadog org UUID from the MCP whoami response as the external ID (see
#117491 &
#117705). For GCP, the
`IdentityProvider` is created upfront by the endpoint.

`GET /api/0/organizations/{org}/monitoring-providers/` lists the
available providers and the current user's connection status. This will
be used to inform the monitoring provider settings UI tracked in
https://linear.app/getsentry/issue/CW-1500/monitoring-providers-settings-page.

`POST /api/0/organizations/{org}/monitoring-providers/{provider}/`
represents a request to connect a given monitoring provider for a given
user. It initiates the OAuth flow and returns a redirect URL to the
provider's authorize page, based on the identity pipeline for that
provider.

`DELETE /api/0/organizations/{org}/monitoring-providers/{provider}/`
represents a request to disconnect/delete a given monitoring provider
for a given user. It deletes the current user's linked identity for that
provider, if one exists.

**Note on support for a single user connecting multiple Datadog orgs:**
- For v0, we're mainly considering the case where a user has a single
Datadog org connected, but in the future we will support multiple
- The GET endpoint currently collapses to one entry per provider type
(shows `connected: true` if _any_ exist
- The POST endpoint currently allows multiple connections to be created
- The DELETE endpoint currently deletes all identities for the provider
(`idp__type=provider_key`)

---------

Co-authored-by: getsantry[bot] <66042841+getsantry[bot]@users.noreply.github.com>
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