Repository navigation
Conversation
An oidc_tokens binding issues short-lived OpenID Connect tokens for the Worker's own identity, for one audience. Wrangler validates the audience and optional alg, uploads it as an oidc_token metadata binding, round-trips it through config pulls, supports it in previews, generates its OidcTokenBinding type and prints it in the bindings table. It's local-only and shows as not supported in wrangler dev: there's no local signer, and a remote proxy session would sign tokens for the proxy Worker rather than this one. @cloudflare/config gets bindings.oidcToken(), and the wrangler-to-cf codemod converts it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: d43549e The changes in this PR will be included in the next version bump. This PR includes changesets to release 13 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Codeowners approval required for this PR:
Show detailed file reviewers
|
There was a problem hiding this comment.
Superseded by the review of
d43549ee.
This review, of 8d172c28
💬 Approved with comments — One WARNING: wrangler types emits OidcTokenBinding before any published runtime types define it. There is also one INFO about tests missing for the preview and startup-profile paths. Nothing makes the change unsafe to merge.
Findings: 1 warning · 1 info (2 are inline comments on the diff)
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
🔧 Fix with your agent
Paste the following into your coding agent to investigate and fix these issues.
Fix the following code review issues found in pull request #17088.
Before making changes, review each issue and present a brief summary table:
- For each finding, state whether you agree, disagree, or need clarification
- If you disagree (e.g., the fix would require disproportionate changes
for minimal ROI, or the finding is factually incorrect), explain why
- If you need to clarify something before deciding, ask those questions
- Then share your plan for which issues to tackle and in what order
## WARNING (1)
### [Code Quality] `wrangler types` emits `OidcTokenBinding`, which no published runtime types define yet, so the generated `.d.ts` will not typecheck for users of `oidc_tokens` until workerd and workers-types ship it.
- **File:** packages/wrangler/src/type-generation/index.ts:2973
## INFO (1)
### [Code Quality] No tests cover the new `oidc_token` paths in preview-config `convertBinding`, preview `shared.ts`, or `startup-profile.ts`. The sibling VPC bindings have tests in each of these places.
- **File:** packages/wrangler/src/preview/preview-config.ts:765
📋 Code Quality: ⚠️ 1 warning · 1 info
The binding is wired through end to end. Generated types reference a type that isn't published yet, and the preview and startup-profile paths have no tests.
Recommendation: 📝 Minor Comments
- [WARNING]
wrangler typesemitsOidcTokenBinding, which no published runtime types define yet, so the generated.d.tswill not typecheck for users ofoidc_tokensuntil workerd and workers-types ship it. (packages/wrangler/src/type-generation/index.ts:2973) - [INFO] No tests cover the new
oidc_tokenpaths in preview-configconvertBinding, previewshared.ts, orstartup-profile.ts. The sibling VPC bindings have tests in each of these places. (packages/wrangler/src/preview/preview-config.ts:765)
View full review
Merge-order dependency on OidcTokenBinding. packages/wrangler/src/type-generation/index.ts:2973 and :4065 emit the type name OidcTokenBinding. The description says this type comes from a workerd change that has not landed yet. Until workerd and workers-types publish it, anyone who configures oidc_tokens and runs wrangler types gets a .d.ts that does not typecheck. The snapshot tests do not catch this because they never typecheck the output. Either gate the merge on that dependency, or emit the same structural fallback ({ getToken(): Promise<string> }) that packages/config/src/inference.ts already uses.
Missing tests. Three new paths have no tests: the oidc_token branch in convertBinding (packages/wrangler/src/preview/preview-config.ts), the preview binding extraction and formatting in packages/deploy-helpers/src/preview/shared.ts, and the unsupported-binding case in packages/deploy-helpers/src/startup-profile.ts. The sibling VPC bindings have tests in each of these places.
✅ All other checks passed
🚀 Release: ✅ LGTM
The changeset covers the new binding and the affected packages. Release risk is medium: this adds a security-sensitive deployment capability, but accounts must be enabled before they can deploy the binding.
🔒 Security: ✅ LGTM
No security issues found. Keeping the binding out of remote proxying, so a proxy session never signs tokens with the wrong Worker identity, is the right choice.
📖 AGENTS.md: ✅ LGTM
No AGENTS.md issues found.
⚡ Performance: ✅ LGTM
No performance issues found.
📝 Documentation: ✅ LGTM
No documentation issues found.
Reviewed commit: 8d172c28
| }); | ||
| } | ||
|
|
||
| addBinding(oidcToken.binding, "OidcTokenBinding", "oidc_tokens", envName); |
There was a problem hiding this comment.
wrangler types emits OidcTokenBinding, which no published runtime types define yet, so the generated .d.ts will not typecheck for users of oidc_tokens until workerd and workers-types ship it.
This emits OidcTokenBinding, but no published workerd or workers-types release defines it yet. The description says that type comes from a workerd change that should land first. Until it ships, anyone who configures oidc_tokens and runs wrangler types gets a generated file that fails to typecheck. Either hold the merge until that dependency is released, or emit a structural fallback such as { getToken(): Promise<string> }, matching what packages/config/src/inference.ts does.
| case "worker_loader": | ||
| config = { worker_loaders: [{ binding: name }] }; | ||
| break; | ||
| case "oidc_token": |
There was a problem hiding this comment.
ℹ️ INFO · Code Quality
No tests cover the new oidc_token paths in preview-config convertBinding, preview shared.ts, or startup-profile.ts. The sibling VPC bindings have tests in each of these places.
No test covers this new oidc_token case, including the branch that drops the binding when audience is undefined and the branch that discards an unrecognised alg. The new code in deploy-helpers/src/preview/shared.ts and startup-profile.ts is also untested, while the VPC bindings have tests in each of these places. One small test per path would guard these conversions.
| z.strictObject({ | ||
| type: z.literal("oidc-token"), | ||
| audience: z.string(), | ||
| alg: z.enum(["ES256", "RS256"]).optional(), | ||
| }), |
There was a problem hiding this comment.
🔍 Build Output skips audience constraints
For empty or whitespace-containing audiences, KnownBindingSchema accepts values that Wrangler's normalizer rejects. previewBuildOutput constructs configuration without that normalizer, so these values reach the preview API.
Was this helpful? React with 👍 or 👎 to provide feedback.
@cloudflare/autoconfig
@cloudflare/build-output-utils
@cloudflare/codemods
@cloudflare/config
@cloudflare/containers-shared
create-cloudflare
@cloudflare/deploy-helpers
@cloudflare/kv-asset-handler
miniflare
@cloudflare/pages-functions
@cloudflare/pages-shared
@cloudflare/runtime-types
@cloudflare/unenv-preset
@cloudflare/vite-plugin
@cloudflare/vitest-plugin
@cloudflare/workers-auth
@cloudflare/workers-editor-shared
@cloudflare/workers-utils
wrangler
commit: |
| oidc_tokens: [ | ||
| { | ||
| binding: name, | ||
| audience: binding.audience, |
There was a problem hiding this comment.
When Wrangler generates a missing previews block, this copies the production audience even though this conversion is explicitly meant not to copy production values. A preview deployment will then issue tokens for the production audience without requiring the user to opt in. Leave a placeholder so the generated config requires a Preview-safe audience.
| audience: binding.audience, | |
| audience: usePlaceholderValue ? REPLACE_ME : binding.audience, |
|
I'm Bonk, and I've done a quick review of your PR. PR #17088 adds OIDC token bindings across Wrangler configuration and deployment paths.
|
|
@efalcao could you address the CI failures and the AI review comments? 🙏 |
A verifier's trust policy names the subject worker:<tag>, and the tag appears nowhere else in wrangler's output. When the config has oidc_tokens, wrangler deploy now prints the issuer and subject after the deployed triggers. An existing Worker's tag comes from the pre-upload service lookup. A new Worker's comes from the upload response, because the first upload creates it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
| previewUrlsConfigAssignment: options.previewUrlsConfigAssignment, | ||
| }); | ||
|
|
||
| printOidcTokenIdentity(config.oidc_tokens, accountId, uploadedWorkerTag); |
There was a problem hiding this comment.
🟡 Missing OIDC identity for dispatch Workers
After a successful --dispatch-namespace upload, deployWorker returns before printing the OIDC identity. Operators get neither trust-policy value, even when the upload returns the Worker tag.
Learn more
wrangler deploy --dispatch-namespace deploys a Worker into a Workers for Platforms namespace instead of configuring ordinary Worker triggers. deployWorker already captures the tag from the upload response for this path. After upload, the dispatch completion branch prints its summary and returns without reaching the OIDC output.
Example: Deploy a Worker with oidc_tokens to customer-workers. The upload returns tag abc123, but the success output omits both the issuer and worker:abc123.
Recommended fix: Call printOidcTokenIdentity in the dispatch completion branch using uploadedWorkerTag and the authenticated account ID. Keep the dispatch return before trigger deployment. Add a dispatch deploy test that supplies an upload tag and checks the issuer and subject.
Was this helpful? React with 👍 or 👎 to provide feedback.
| previewUrlsConfigAssignment: options.previewUrlsConfigAssignment, | ||
| }); | ||
|
|
||
| printOidcTokenIdentity(config.oidc_tokens, accountId, uploadedWorkerTag); |
There was a problem hiding this comment.
🔍 OIDC output ignores binding overrides
printOidcTokenIdentity still prints trust values when CLI overrides replace every configured OIDC binding with a variable or secret.
Was this helpful? React with 👍 or 👎 to provide feedback.
| "oidc_tokens": [{ "binding": "API_TOKEN", "audience": "https://api.example.com" }] | ||
| ``` | ||
|
|
||
| `env.API_TOKEN.getToken()` returns a newly signed JWT. Set `"alg": "RS256"` for verifiers that don't accept the default, ES256. Wrangler validates the audience (1 to 2048 printable ASCII characters, no whitespace), uploads the binding, generates its `OidcTokenBinding` type, and prints it in the bindings table. After a deploy, `wrangler deploy` prints the issuer and subject to put in the verifier's trust policy. The subject contains the Worker's immutable ID, which no other output shows. The binding isn't available in local development yet. Accounts must be enabled for the binding before they can deploy it. |
There was a problem hiding this comment.
🔍 Structured output already includes Worker IDs
For existing Workers, structured deploy output already records the immutable ID as worker_tag when enabled.
Was this helpful? React with 👍 or 👎 to provide feedback.
There was a problem hiding this comment.
💬 Approved with comments — One WARNING is still open: wrangler types references OidcTokenBinding before published runtime types define it. There is also one INFO about missing tests. The new deploy-time issuer and subject output looks correct.
Findings: 1 warning · 1 info
Not opened by the correctness review: 2 changed files it was meant to read
packages/deploy-helpers/src/deploy/deploy.tspackages/deploy-helpers/src/deploy/helpers/oidc-tokens.ts
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
🔧 Fix with your agent
Paste the following into your coding agent to investigate and fix these issues.
Fix the following code review issues found in pull request #17088.
Before making changes, review each issue and present a brief summary table:
- For each finding, state whether you agree, disagree, or need clarification
- If you disagree (e.g., the fix would require disproportionate changes
for minimal ROI, or the finding is factually incorrect), explain why
- If you need to clarify something before deciding, ask those questions
- Then share your plan for which issues to tackle and in what order
## WARNING (1)
### [Code Quality] `wrangler types` emits `OidcTokenBinding`, which no published runtime types define yet, so the generated `.d.ts` will not typecheck for users of `oidc_tokens`. The changeset also claims Wrangler generates this type.
- **File:** packages/wrangler/src/type-generation/index.ts:2973
## INFO (1)
### [Code Quality] No tests cover the new `oidc_token` paths in preview-config `convertBinding`, preview `shared.ts` and `startup-profile.ts`.
- **File:** packages/wrangler/src/preview/preview-config.ts:765
📋 Code Quality: ⚠️ 1 warning · 1 info
The deploy-time OIDC identity output is correct; the unpublished OidcTokenBinding type reference and the missing preview and startup-profile tests are still open.
Recommendation: 📝 Minor Comments
- [WARNING]
wrangler typesemitsOidcTokenBinding, which no published runtime types define yet, so the generated.d.tswill not typecheck for users ofoidc_tokens. The changeset also claims Wrangler generates this type. (packages/wrangler/src/type-generation/index.ts:2973) - [INFO] No tests cover the new
oidc_tokenpaths in preview-configconvertBinding, previewshared.tsandstartup-profile.ts. (packages/wrangler/src/preview/preview-config.ts:765)
View full review
Unpublished OidcTokenBinding type. packages/wrangler/src/type-generation/index.ts:2973 (and :4065) emits the type name OidcTokenBinding. According to the description, that type comes from cloudflare/workerd#8739, which has not landed. Until workerd and workers-types publish it, anyone who configures oidc_tokens and runs wrangler types gets a .d.ts that does not typecheck. The snapshot tests don't typecheck the output, so they don't catch this. The changeset (.changeset/oidc-token-bindings.md) also says Wrangler generates this type, without noting the dependency. To fix it, either hold the merge and release until the type is published, or emit the structural fallback { getToken(): Promise<string> } that packages/config/src/inference.ts already uses.
Missing tests. Three new paths have no tests:
- the
oidc_tokencase inconvertBinding(packages/wrangler/src/preview/preview-config.ts). It silently drops the binding whenaudienceis missing and drops an unrecognisedalg. - preview binding extraction and formatting in
packages/deploy-helpers/src/preview/shared.ts. - the unsupported-binding case in
packages/deploy-helpers/src/startup-profile.ts.
The sibling VPC bindings have tests in each of these places.
Deploy output. printOidcTokenIdentity and its call in deploy.ts handle new and existing Workers correctly. Tests cover both cases and the case with no binding.
✅ All other checks passed
🚀 Release: ✅ LGTM
The changeset follows the repository's convention and lists the affected packages. Release risk is medium: this adds a security-sensitive deployment capability, but accounts must be enabled before they can deploy the binding. The types dependency covered in the code quality section also limits when this should be released.
🔒 Security: ✅ LGTM
No security issues found. The issuer and subject printed after deploy are identifiers, not secrets, and only appear in the account owner's own deploy output. The binding is still never remote-proxied, so a proxy session cannot sign tokens for the wrong Worker's identity.
📖 AGENTS.md: ✅ LGTM
No AGENTS.md issues found.
⚡ Performance: ✅ LGTM
No performance issues found. The deploy output makes no extra request: it reuses the pre-upload service lookup and the upload response.
📝 Documentation: ✅ LGTM
No separate documentation issues. The changeset's statement that Wrangler generates the OidcTokenBinding type is covered by the type-generation warning in the code quality section.
Reviewed commit: d43549ee
Fixes SECRETS-198.
Adds the
oidc_tokensbinding. It issues short-lived OpenID Connect tokens for the Worker's own identity, for one audience, so a Worker can exchange them for cloud credentials or send them to an API as a bearer token instead of storing long-lived secrets.Config and validation (
workers-utils):oidc_tokensis non-inheritable. The audience must be 1 to 2048 printable ASCII characters with no whitespace, andalgmust beES256orRS256if it's set. These match what the API accepts.Upload (
deploy-helpers): the binding is sent as{ type: "oidc_token", name, audience, alg? }metadata. Config pulls map it back, and it's included in config diffs and the remote secrets override check.Previews: it's allowed under
previews, and preview config converts it.Types:
wrangler typesemitsOidcTokenBinding. That type comes from Add OidcTokenBinding types for oidc_tokens bindings workerd#8739, which should land first.Bindings table: prints the audience, plus the alg when one is set.
Deploy output: when the config has
oidc_tokens,wrangler deployprints the issuer and subject to put in a verifier's trust policy, after the deployed triggers:The subject contains the Worker's immutable ID, which no other output shows. A new Worker's ID comes from the upload response.
Local dev: the binding is
local-onlyand shows as "not supported" inwrangler dev. It's never remote-proxied, because a proxy session would sign tokens for the proxy Worker's identity instead of this Worker's. The startup profile lists it as unsupported.@cloudflare/config: addsbindings.oidcToken({ audience, alg? }), and thewrangler-to-cfcodemod converts the binding. Inference uses a structural{ getToken(): Promise<string> }until workers-types publishesOidcTokenBinding.Accounts must be enabled for the binding before they can deploy it.
🤖 Generated with Claude Code