Skip to content

feat(backend-auth): honor a per-connection audience - #267

Draft
alukach wants to merge 2 commits into
mainfrom
feat/per-connection-audience
Draft

alukach wants to merge 2 commits into
mainfrom
feat/per-connection-audience

Conversation

@alukach

@alukach alukach commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Implements the proxy side of ADR-012 §1 (per-connection audience for direct federation). A connection's s3_web_identity_role authentication may now carry an audience. When it is absent or sts.amazonaws.com, nothing changes. When it is scv1:conn:{id}, the connection's own subject, the proxy passes it to multistore as the new oidc_audience backend option, so the connection's assertions carry that aud. A role owner who registers exactly that client ID on their IAM OIDC provider then has STS reject tokens minted for any other connection before the trust policy is evaluated.

Any other value fails closed with InvalidAudience before credentials are minted and with no backend options set. An audience naming another connection would satisfy the one check a role owner registers it for, so the proxy only honours the connection's own.

Rollout is safe in either order. A proxy without this change ignores the field (serde skips unknown fields) and keeps sending sts.amazonaws.com, so a connection that sets scv1:conn:{id} before this deploys fails at STS rather than succeeding under the shared audience. The source.coop side, which adds the field and lets a connection's manager switch it, is a separate PR.

Depends on

developmentseed/multistore#167, which adds oidc_audience and scopes the credential cache by audience, so ADR-006's cache-key invariant holds without relying on aud being derived from sub. Cargo.toml patches the multistore crates to that branch; this stays a draft until it is released and the patch is replaced with the version.

Testing

  • cargo test (all suites) passes. New in tests/backend_auth.rs: deserializes_audience, default_audience_sets_no_audience_option (absent and sts.amazonaws.com), own_audience_is_passed_to_the_provider, and another_connections_audience_fails_closed (another connection's id, a suffixed subject, an arbitrary string; each errors with options left empty).
  • cargo clippy and cargo check for wasm32-unknown-unknown pass against the patched multistore.
  • Not yet run end to end: a connection with audience = scv1:conn:{id} against a role whose OIDC provider registers only that client ID. That needs the source.coop field and a staging deploy.

ADRs

ADR-012 §1 describes this decision and still holds; this implements its proxy half, so the ADR is left as is. ADR-006's requirement that aud stay a pure function of the cache key is met by multistore#167 keying on the audience directly.

🤖 Generated with Claude Code

A connection's `s3_web_identity_role` authentication may carry an `audience`. Absent or `sts.amazonaws.com` keeps today's behaviour. `scv1:conn:{id}`, the connection's own subject, is passed to multistore as `oidc_audience` so its assertions carry that `aud`. Any other value fails closed with `InvalidAudience` before credentials are minted, since an audience naming another connection would satisfy the check a role owner registers it for.

Depends on developmentseed/multistore#167, patched in from its branch until it is released.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XR9ZJnpPSJFK6LFSBxePNE
@claude

claude Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @alukach's task in 10s —— View job


✅ No blocking issues — safe to merge (once the multistore patch is swapped for a release, as the PR already states).

I read the diff and did not run the tests.

  • The audience check in src/backend_auth.rs fails closed. A missing audience or sts.amazonaws.com sets no option. The connection's own scv1:conn:{id} is passed through. Anything else returns InvalidAudience.
  • The error return comes before any options.insert, so options stay empty on failure. The new test asserts this.
  • The comparison is an exact string match, so scv1:conn:conn-1:extra is rejected.
  • The warn! logs only connection_id, not the rejected value, so nothing sensitive is logged.

Non-blocking notes

  • Cargo.toml patches [patch.crates-io] to a git branch. Merging before multistore#167 is released would leave an unpinned branch dependency. The PR is draft-gated on this, so it is not a code issue.
  • A caller that omits oidc_audience while the cache scopes by audience depends on multistore#167's behavior. This is outside the diff, so I did not check it.

Simplify (ponytail)

  • src/backend_auth.rs (audience match): the Some(aud) if aud == subject => Some(aud) arm followed by aud.to_string() is fine. It could be Some(a) if a == subject => Some(subject.clone()), but the gain is trivial.

💰 Estimated review cost: $0.10 · 0m10s · 4 turns

@github-actions

github-actions Bot commented Nov 8, 2026 •

Copy link
Copy Markdown

🚀 Latest commit deployed to https://source-data-proxy-pr-267.source-coop.workers.dev

  • Date: 2026-11-17T04:18:48Z
  • Commit: ac803b7

This branch was previously deployed

1 inactive deployment
preview — 7df485d6 Deployed Nov 17, 2026 by alukach via Deploy & Test / Deploy #493
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant