Skip to content

feat(data-connections): let a web-identity connection use its own audience - #744

Draft
alukach wants to merge 1 commit into
mainfrom
feat/per-connection-audience
Draft

alukach wants to merge 1 commit into
mainfrom
feat/per-connection-audience

Conversation

@alukach

@alukach alukach commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

An s3_web_identity_role connection can now set authentication.audience to scv1:conn:{data_connection_id}, its own subject, instead of the shared sts.amazonaws.com. AWS checks a token's aud against the client IDs registered on the role's IAM OIDC provider before it evaluates the trust policy, so a role owner who registers exactly that value accepts tokens for this connection and no other, whether or not their trust policy pins sub. This is the app half of data.source.coop ADR-012 §1; the proxy half is source-cooperative/data.source.coop#267.

The field is optional and absent means the shared audience, so existing connections are unchanged. DataConnectionSchema accepts only sts.amazonaws.com or the connection's own scv1:conn:{id}; any other value is a field error on authentication.audience, because an audience naming another connection would satisfy the check a role owner registers it for. The proxy refuses such a value as well.

The form gains an Audience select under the role ARN: Shared (sts.amazonaws.com) or This connection only. Its help names the client ID to register, and the trust policy shown below it conditions on the chosen audience. The form always submits the audience, so switching back to Shared clears a stored one on edit.

Order of deployment

  1. feat(oidc-provider): accept a per-bucket audience via oidc_audience developmentseed/multistore#167 (oidc_audience option), released.
  2. feat(backend-auth): honor a per-connection audience data.source.coop#267 (proxy honours the field), deployed.
  3. This PR.

Merging this before the proxy ships is not unsafe, only premature: a proxy without #267 ignores the field and keeps sending sts.amazonaws.com, so a connection set to its own audience fails at STS once its owner has removed the shared client ID, rather than succeeding under it. It stays a draft until #267 is deployed.

Stories

Screenshot to follow once the branch's Storybook deploy is up.

Testing

  • npx jest src/types/data-connection.test.ts src/components/features/data-connections/trust-policy.test.ts src/lib/operations/data-connections.test.ts: 67 passed. New: the schema accepts no audience, sts.amazonaws.com and the connection's own subject, and rejects another connection's subject, a suffixed subject and an arbitrary string with the error on authentication.audience; the trust policy conditions on the given audience.
  • npm run type-check: no errors in changed files. The run reports 20 errors, all missing-module errors from the local install, and main reports the same 20.
  • Not run end to end: needs Epic: Access Controls #267 on staging and a role whose OIDC provider registers only the connection's subject.

Docs and ADRs

  • data.source.coop ADRs: ADR-012 §1 describes this decision and still holds; this implements its app half, so no ADR change.
  • docs.source.coop bring-your-own-bucket: still accurate for the shared audience, which stays the default. The own-audience setup gets a section there once Epic: Access Controls #267 is deployed, so the docs never describe an option the proxy doesn't honour yet.
  • public/llms.txt: no change; no new endpoint, and the field is documented in the OpenAPI schema.

🤖 Generated with Claude Code

…ience

An `s3_web_identity_role` connection may set `audience` to `scv1:conn:{data_connection_id}`, its own subject, instead of the shared `sts.amazonaws.com`. The schema accepts only those two values; any other is a field error on `authentication.audience`, since an audience naming another connection would satisfy the check a role owner registers it for. The form offers the choice next to the role ARN, tells the owner which client ID to register on their OIDC provider, and the trust policy it shows conditions on the chosen audience.

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

vercel Bot commented Nov 8, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
source-coop-ui Building Building Preview Nov 8, 2026 11:35pm UTC
source-cooperative Ready Ready Preview Nov 8, 2026 11:35pm UTC

Request Review

@claude

claude Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

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


✅ No blocking issues — safe to merge (after the deployment order in the description: multistore#167, then data.source.coop#267, then this PR).

I read the diff only and did not run the tests.

Notes (non-blocking)

  • DataConnectionForm.tsx (hidden audience input): while derivedId is empty, choosing "This connection only" submits scv1:conn:. The schema rejects it with an error on authentication.audience, so nothing bad is stored. The user sees an audience error for what is really a missing ID. If the ID can be empty at submit time, send nothing for the audience until derivedId is set.
  • data-connection.ts: audience is typed z.optional(z.string()). The cross-field refine is what restricts it, which is correct because it needs the connection ID. A direct API caller who sends audience: "" gets the field error, since "" is neither allowed value. The form turns "" into undefined via || undefined, so the two paths treat empty differently. That is fine, but worth knowing.
  • redact.ts: audience is passed through to the browser. It is not a secret and the form needs it, so this is correct.

Simplify (ponytail)

  • DataConnectionForm.tsx hidden input and ownAudience state: the value ownAudience ? connectionSubject(...) : SHARED_AUDIENCE is computed twice, here and for the trust policy. Compute it once as const audience = ... and reuse it in both places.
  • trust-policy.ts: the audience default parameter duplicates the form's choice. It is a small thing, but the test already covers the explicit value, so you could make the parameter required and drop the default.

Docs

The description covers the docs. It names ADR-012 §1 (still holds, this is its app half), docs.source.coop bring-your-own-bucket (an own-audience section is deferred until #267 is deployed), and llms.txt (no change). Nothing is missing. Please link the docs PR once it exists.


💰 Estimated review cost: $0.11 · 0m13s · 4 turns

This branch was successfully deployed

2 active deployments
Preview – source-cooperative — e42c7ed7 Deployed Nov 8, 2026 by vercel[bot]
Preview – source-coop-ui — e42c7ed7 Deployed Nov 8, 2026 by vercel[bot]
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