Skip to content

Enable Observability Pipelines via OAuth#520

Open
Jansen-w wants to merge 2 commits into
DataDog:mainfrom
Jansen-w:jansen-w/add-obs-pipelines-oauth-scopes
Open

Enable Observability Pipelines via OAuth#520
Jansen-w wants to merge 2 commits into
DataDog:mainfrom
Jansen-w:jansen-w/add-obs-pipelines-oauth-scopes

Conversation

@Jansen-w
Copy link
Copy Markdown

@Jansen-w Jansen-w commented May 20, 2026

⚠️ Blocked on server-side changes | Closes #521.

Summary

Two changes that, together with in-flight server-side work, will make pup obs-pipelines work via OAuth instead of requiring DD_API_KEY + DD_APP_KEY:

  1. src/commands/obs_pipelines.rs — switch the OP commands from make_api_no_auth! to make_api!, so the OAuth bearer token is sent when one is available (falling back to API-key headers otherwise). Same pattern as PR [NOT READY] Add OAuth support to remaining 6 commands #342, expressed via the macro that subsumed the old make_bearer_client helper.
  2. src/auth/types.rs — add observability_pipelines_read, observability_pipelines_deploy, and observability_pipelines_delete to default_scopes(), and observability_pipelines_read to read_only_scopes(), so pup auth login requests them on the consent screen. Updated test_default_scopes() count (85 → 88) and added containment assertions.

Why this was needed

Today pup obs-pipelines list (and every other OP subcommand) returns 401 Unauthorized for OAuth-authenticated users. Two reasons:

  • make_api_no_auth! was suppressing the bearer header on every OP call (the comment said "Observability Pipelines does not support OAuth — API key auth only"). API-key headers were the only auth ever sent.
  • Even if the bearer header had been sent, the OAuth consent screen never requested observability_pipelines_* scopes, so the token wouldn't have carried them anyway.

agents/observability-pipelines.md documents observability_pipelines_{read,deploy,delete} as required for these endpoints, but none of those scope names appeared anywhere in src/auth/types.rs. This PR closes both halves of that gap.

Test plan

  • cargo check --bin pup passes
  • cargo test --bin pup auth::types:: — all 9 tests pass with updated assertions
  • Built release binary locally; existing token store loads cleanly
  • Verified: with the patched binary + unchanged server side, OAuth login fails with invalid_scope (confirming the unsupported-scope hypothesis)
  • After server-side OAuth enablement deploys, and after pup's OAuth client gets the OP scopes: re-authenticate with this PR's binary and confirm pup obs-pipelines list returns pipelines instead of 401

Currently `pup obs-pipelines list` (and every other OP subcommand) returns
401 Unauthorized when called with OAuth credentials, because pup's default
scope set never requests any `observability_pipelines_*` scope. The CLI
side has `pup obs-pipelines …` wired up, and `agents/observability-pipelines.md`
already documents that the routes require `observability_pipelines_read`,
`observability_pipelines_deploy`, and `observability_pipelines_delete` —
this PR closes that gap by adding those scopes to the default consent set.

- `observability_pipelines_read` added to both `default_scopes()` and
  `read_only_scopes()`.
- `observability_pipelines_deploy` and `observability_pipelines_delete`
  added to `default_scopes()` only (write/destructive).
- Updated `test_default_scopes()` count from 85 to 88 and added
  containment assertions for all three new scopes.
@Jansen-w Jansen-w changed the title Add Observability Pipelines OAuth scopes to default consent set [BLOCKED] Add Observability Pipelines OAuth scopes to default consent set May 20, 2026
The `make_api!` macro sends the OAuth bearer token when one is available
and falls back to API-key headers otherwise. Previously the OP commands
used `make_api_no_auth!`, which suppressed the bearer header outright
because the OP routes did not accept `ValidOAuthAccessToken` on the
server side.

Server-side support for OAuth on the OP public routes is in flight
(DataDog/dd-source#426541 covers the Rapid-side authn list on
obs-pipelines-crud; DataDog/dd-go#238110 covers the Route Manager
allowlist on rc-api-proxy across staging/prod/gov). Once those land and
pup's OAuth client gets the OP scopes added, this change unblocks
`pup obs-pipelines` via OAuth without further client work.

Pattern copied from the prior attempt in PR DataDog#342, adapted to the
current `make_api!` macro (which subsumed the older `make_bearer_client`
helper used in that PR).
@Jansen-w Jansen-w changed the title [BLOCKED] Add Observability Pipelines OAuth scopes to default consent set feat(obs_pipelines): Add Observability Pipelines OAuth scopes to default consent set May 20, 2026
@Jansen-w Jansen-w changed the title feat(obs_pipelines): Add Observability Pipelines OAuth scopes to default consent set Enable Observability Pipelines via OAuth May 20, 2026
@Jansen-w Jansen-w marked this pull request as ready for review May 20, 2026 19:50
@Jansen-w Jansen-w requested a review from a team as a code owner May 20, 2026 19:50
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4fd71f3bed

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/auth/types.rs
Comment on lines +184 to +186
"observability_pipelines_read",
"observability_pipelines_deploy",
"observability_pipelines_delete",
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Gate new scopes until the OAuth server accepts them

When this binary is deployed before the server-side OAuth scope rollout reaches every supported site, a plain pup auth login resolves to default_scopes() and puts these new scopes in the authorization URL; the OAuth issuer rejects unknown scopes with invalid_scope before any token is issued. That blocks all users from logging in or refreshing an expired session, not just users of obs-pipelines, so these scopes need to remain opt-in/configured or be gated until the issuer accepts them everywhere.

Useful? React with 👍 / 👎.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

obs-pipelines commands return 401 with OAuth auth; docs reference scopes that aren't requested (and may not be valid OAuth scopes)

2 participants