Skip to content

Add identity RPC bindings and runtime caller verification - #8121

Draft
irvinebroque wants to merge 41 commits into
mainfrom
codex/workers-oidc
Draft

irvinebroque wants to merge 41 commits into
mainfrom
codex/workers-oidc

Conversation

@irvinebroque

@irvinebroque irvinebroque commented Oct 31, 2026 •

Copy link
Copy Markdown
Collaborator

Add protected identity RPC bindings, argument-free ctx.identity.caller() and checked immutable workload/signed/delegated results. Keep native service-binding precedence and safe structured error transport. Configure no customer verifier or replay binding.

Public declarations retain no-argument configured client metadata/assertions, optional singleton WAG AS selection, structural IdentityConnectionError fields and the sole signatureAgent URL. The companion configuration now uses flat callerIdentity with accountTokens; the runtime handler API is unchanged.

Runtime head 40cc7a73dae239b870aa80b9e631d92d1bb3eb8f is unchanged by the configuration naming pass. Previous just generate-types and bazel test //types:test/types/oidc results remain recorded at this head. Current local SDK integration passes all 34 tests using the recorded companion executable built from afef2a9e2ac452cad7661e6db3f4358d2103630b; executable C++ sources match. This does not qualify the native production host channel or released runtime.

Companions: runtime #8121, SDK #16455, cf #465.

Experimental draft. Local testing is the acceptance basis; production/hosted provenance, interoperability/security, cross-colo replay, capacity and rollout qualification remain separate. Production enablement remains off.

Expose ctx.oidc.getToken() on ExecutionContext and DurableObjectState.
Forward bounded audience and subject options through the current trusted
I/O channel; standalone workerd rejects issuance without a host signer.
Share strict UTF-8 and JWT StringOrURI validation with embedding hosts.

Compatibility: keep the API behind the experimental workers_oidc flag
with no enable date, so existing Workers retain their API surface.

Validate native audience parsing, API option handling, execution-context
isolation, Durable Object subjects, flag gating, and generated types.
The string wrappers copied customer input before enforcing audience
and subject limits. Keep GC-safe references until type and string
length checks succeed, then copy only bounded input into native memory.

Exercise oversized ASCII and Unicode values, exact UTF-8 limits, and
objects that must be rejected without coercion. Keep malformed UTF-8
checks at the native host boundary and lone-surrogate API coverage.

Compatibility: preserve the experimental workers_oidc API, accepted
string values, and TypeScript declarations.
Add an explicit per-Worker broker channel with bounded requests, responses and cancellation. Local Durable Objects share the development getter and reject explicit cloud subject modes.

Compatibility: retain the experimental workers_oidc flag with no automatic enable date. The broker requires explicit host configuration and adds no JavaScript API surface.

Validation: OIDC unit and runtime tests; local callback default, all-compat-flags and all-autogates variants on macOS; Linux callback repeated five times.
Verify that a 2048-byte audience survives JSON expansion and the protected native callback without truncation. The default, all-compat-flags and all-autogates variants pass.
Map broker status codes and two fixed hints to corrective messages.
Keep arbitrary response bodies and headers out of Worker exceptions.
Cover each category through Worker and Durable Object getters.

Use current header and declaration conventions required by clang-tidy.
The API surface and compatibility gates are unchanged; these messages
apply only when the local OIDC callback is explicitly configured.

Validated all workerd test variants and production clang-tidy targets.
Replace the unreleased workers_oidc singleton with assignment-backed env bindings. This intentionally changes the experimental API before release; the workers_oidc flag remains opt-in. Resolve execution evidence at each call and forward only the fixed assignment, optional audience, and fresh boolean to the host.
Allocate workers_oidc after current compatibility flags and regenerate type snapshots through //types. The native capability forwarding and identity type tests pass on this revision.
Extend the existing workers_oidc-gated wrapper without new native APIs. Preserve protected parent authority and transport customer selection only through fetchForCustomer; strip caller-supplied internal selectors from ordinary fetch. Regenerate public types and exercise forwarded capabilities.
@irvinebroque irvinebroque changed the title Route Workers identity bindings through protected Worker RPC Expose Workers identity through direct protected JSRPC Oct 31, 2026
Expose ctx.identity.caller() with invocation-local memoization, original-request body handling and private verifier RPC. Preserve Access and sender JSRPC APIs. Compatibility: gate the namespace with enable_workload_identity_context, enabled on 2026-10-31. Validate native receiver, Access and sender tests plus receiver union type checks.
@irvinebroque irvinebroque changed the title Expose Workers identity through direct protected JSRPC Add identity RPC bindings and runtime caller verification Oct 31, 2026
Keep the real signer integration in workers-oidc and the runtime
receiver, public type, and generic RPC tests. The removed fixture
implemented its own signer API and could not detect signer regressions.
Let runtime-generated types follow the compatibility flag instead of\nforcing identity properties into disabled contexts.
Expose required readonly originVersionId only on JWT callers and retain credential authority through forwarding. Align signed-request facts and fixtures with signatureAgent. Regenerate snapshots and cover discriminated-union and immutability checks.

Compatibility: accept the additive JWT result field under the existing experimental workload-identity API gate. This uses unchanged private verifier result transport. Coordinate matching verifier validation and types rollout; inventory supported issuers before requiring version_id in production.
Keep one unsupported actor check and the distinct Worker callers that prove request isolation. Two actor calls that both reject cannot establish isolation.
Use one Fetcher helper for caller classification in all tracing paths.
Refer to the reserved-channel count instead of repeating its value.
The refactor preserves the existing supported and unsupported paths.
Construct HTTP entrypoints inside the invocation identity scope so constructors and fetch handlers share the memoized caller result. Preserve actor construction before the retry claim and handler invocation.

Omit known-empty GET/HEAD streams from verifier copies so RPC Request reconstruction succeeds while the original body remains readable. Add regression coverage for native and signed constructor lookups and Content-Length: 0 GET/HEAD requests.

Validation: formatting and diff checks pass, and the regressions reproduce against the prior binary. Build and post-fix runtime tests were skipped.
Preserve upstream compatibility ordinals 202 and 203; move the unshipped opt-in identity flag to 204. Recompile earlier draft pipelines before switching runtime cohorts. Supply unsupported native provenance for hibernation and lazily resolve the test-fixture handler inside the identity scope.
Add opaque subject, pinned issuer and scope provenance for application checks before activation. This is additive to the draft identity binding; no native API or compatibility behavior changes. Regenerate snapshots with the official generator and matching runtime using cached build inputs because local Xcode discovery prevents the Bazel recipe.
Extend the existing argument-free ctx.identity.caller() result with
checked delegated facts and frozen account/scopes data. Preserve safe
DOMException response data through the asynchronous verifier bridge.
Reject unsupported private result schemas without returning identity.

Compatibility: retain the opt-in workload identity context API and add
an explicit enable_delegated_identity capability flag for matched
receiver compilers. Existing native caller precedence stays intact.

Native API and generated public-type tests pass with the documented
local Command Line Tools override. Hosted qualification remains open.
Use const references for checked delegated field names, as required by the clang-tidy range-copy check. No public API or compatibility flag changes.
@codecov-commenter

codecov-commenter commented Nov 4, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 82.77311% with 82 lines in your changes missing coverage. Please review.
✅ Project coverage is 68.83%. Comparing base (1336872) to head (40cc7a7).
⚠️ Report is 32 commits behind head on main.

Files with missing lines Patch % Lines
src/workerd/api/global-scope.c++ 80.19% 28 Missing and 32 partials ⚠️
src/workerd/api/http.c++ 81.81% 4 Missing and 2 partials ⚠️
src/workerd/io/io-channels.h 33.33% 4 Missing ⚠️
src/workerd/server/factory/worker-factory.c++ 88.23% 1 Missing and 3 partials ⚠️
src/workerd/api/global-scope.h 66.66% 0 Missing and 3 partials ⚠️
src/workerd/server/server/config.rs 88.46% 3 Missing ⚠️
src/workerd/api/actor-state.h 50.00% 0 Missing and 1 partial ⚠️
src/workerd/server/server/worker.rs 96.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8121      +/-   ##
==========================================
- Coverage   68.84%   68.83%   -0.02%     
==========================================
  Files         737      743       +6     
  Lines      193921   194997    +1076     
  Branches    30088    30250     +162     
==========================================
+ Hits       133513   134226     +713     
- Misses      42756    43028     +272     
- Partials    17652    17743      +91     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

2 participants