Authenticate to Claude by Workload Identity Federation #44
No reviewers
Labels
No labels
accessibility
area:accounts
area:ai-evals
area:look
area:maps
area:platform
area:rides-progress
area:riding
area:today-plan-coach
area:ui-shell
bot:blocked
bot:failed
bot:pr
bot:waiting
bot:working
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
later
now
owner-check
parked
question
ready
session
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
ckreidl/trainer!44
Loading…
Reference in a new issue
No description provided.
Delete branch "session/anthropic-wif"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What changed
src/ai/client.ts:anthropic()uses Workload Identity Federation whenANTHROPIC_FEDERATION_RULE_IDis set. It passescredentials: oidcFederationProvider(...)withgetVercelOidcToken()as the identity token provider. The token is read fresh on each exchange because Vercel rotates it. The SDK caches the Claude token and refreshes it before expiry. A rule ID without the organization and service account IDs throws rather than falling back.ant auth loginprofile orANTHROPIC_API_KEY..env.example, README env table, PROGRESS, decisions, history.How it was checked
federationFromEnvunit tests (off / on / partial config); full suite 1308 pass; typecheck, lint, format check.bun run buildbundles the SDK'slib/credentialsimport and@vercel/functions/oidc.Before merging (owner)
Merging without this breaks AI calls in production (the old key has expired anyway).
https://oidc.vercel.com/<team-slug>(discovery); a rule with scopeworkspace:inference, audiencehttps://vercel.com/<team-slug>, subjectowner:<team-slug>:project:trainer:environment:production.ANTHROPIC_FEDERATION_RULE_ID,ANTHROPIC_ORGANIZATION_ID,ANTHROPIC_SERVICE_ACCOUNT_ID; removeANTHROPIC_API_KEY.environment:previewthat you archive afterwards. Try one coach message and one logged session, which runs a re-plan throughwaitUntil.Then run
prompts/92-review.mdin a fresh session.🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
antCLI profile; an API key remains supported.Documentation
6779d588-1a97-4abf-afed-989e7188df3dReviewing files that changed from the base of the PR and between
f3c32f5ddcand838d41f313..env.exampleREADME.mddocs/PROGRESS.mddocs/decisions.mddocs/history.mdsrc/ai/client.test.tssrc/ai/client.tsIncluded review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.
Walkthrough
Anthropic client creation now supports Vercel OIDC Workload Identity Federation when federation settings are configured. Local authentication and production environment requirements are documented, and tests cover federation configuration parsing.
Changes: Anthropic authentication
.env.example,README.md,docs/PROGRESS.md,docs/decisions.md,docs/history.mdant auth loginuse, production federation identifiers, and federation setup and verification steps.src/ai/client.ts,src/ai/client.test.tsfederationFromEnvreturnsnullwhen no rule ID is set and requires organization and service-account IDs when one is set.anthropic()creates a federation-backed client when configured and otherwise creates a plain client. Tests cover the helper’s configuration cases.Estimated code review effort: 3 (Moderate) | ~20 minutes
Sequence Diagram(s)
I’m a rabbit with a config to review,
Three IDs hop into the env view.
Vercel brings a token to the call,
Local profiles still work for all.
I nibble the tests, then bound away.
Closing as not planned: Workload Identity Federation isn't going to happen.
Pull request closed