Repository navigation
Add OIDC token broker specification and task authentication - #73261
Conversation
… specification Co-authored-by: pelikhan <[email protected]>
|
@copilot user should be able enable each token type separately, not as a bundle |
|
@copilot token-broker copilot-request is not compatible with permissions.copilot-request:write |
|
@copilot must be supported in evals / detection jobs |
Co-authored-by: pelikhan <[email protected]>
Added a compile-time error for combining brokered
Brokered request authentication is now wired into detection and evals jobs, including job-scoped OIDC permissions. Commit: |
|
@copilot run pr-finisher skill |
|
@copilot the request to the oidc endpoint should specify the "provider", as a string. The provider matches the LLM inference provider inference ids. |
Brokered
Implemented independent
Ran the finisher pass. The three authentication requests are already implemented and replied to; no code changes or empty commit were needed. The PR remains draft, and the current CJS check has an unrelated reproducible model-pin test failure, so it is not merge-ready. |
|
@copilot the token broker must support an invalidate token operation that gets executed as a unconditional post step in job |
Co-authored-by: pelikhan <[email protected]>
Added the inference provider ID to brokered
Added an |
|
@copilot merge main, fix ci failures |
| detectionAuthData.Model = model | ||
| } | ||
| brokeredInference := usesTokenBrokerInference(detectionAuthData) | ||
| steps = append(steps, c.buildTokenBrokerInvalidationStep(detectionAuthData)...) |
| perms.Set(PermissionIdToken, PermissionWrite) | ||
| } | ||
| permissions := perms.RenderToYAML() | ||
| steps = append(steps, c.buildTokenBrokerInvalidationStep(&evalsAuthData)...) |
Comment MemoryPeek at saved memory (pr-code-quality-reviewer)Note This comment is managed by comment memory.Expand the saved memory block to view or edit the persistent context for this thread.
|
There was a problem hiding this comment.
Review comment
The broker integration has one non-blocking correctness concern: copilot-task is enabled for every assign-to-agent configuration, including non-Copilot assignments, which can replace their intended credentials with a Copilot-only token. Existing security-bot comments already cover the invalidation-step ordering issue.
🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt50 · ~4 AIC · ⌖ ~1 AIC · ⊞ 1.6K
Comment /review to run again
| return false | ||
| } | ||
| outputs := data.SafeOutputs | ||
| return outputs.AssignToAgent != nil || outputs.CreateAgentSessions != nil || |
There was a problem hiding this comment.
This enables the broker for every assign-to-agent configuration, including assignments whose target is not Copilot, so opting into copilot-task can silently replace a configured PAT/GITHUB_TOKEN with a Copilot-only credential and break non-Copilot agent assignments.
💡 Scope broker task authentication to Copilot operations
AssignToAgent != nil is not sufficient to establish that the handler will call the Copilot coding-agent API; this path supports arbitrary agent names. Determine whether the configured assignment target is Copilot (and preserve the existing credential path for other agents), or document/enforce that broker mode applies to all assignments and validate the broker capability accordingly.
Co-authored-by: pelikhan <[email protected]>
There was a problem hiding this comment.
Skills-Based Review 🧠
Applied /codebase-design and /tdd (triaged via pr-triage: new_feature, recommended /grill-with-docs + /codebase-design). No blocking issues; two actionable findings posted inline, plus a rebuttal of the existing bot comments.
📋 Key Themes & Highlights
GHAS bot comments on threat_detection_job.go:211 and evals_job.go:108 are false positives
Both bot comments claim the always()-conditioned invalidation step is appended before the token-exchange/execution steps, risking premature credential teardown. I verified this empirically rather than relying on code-order intuition:
- Compiled a real workflow (
token-broker.copilot-request: true+threat-detection.engine: copilot) and inspected the generated.lock.ymlfor thedetection:job: step order is Request → Execute → Invalidate (if: always()) — correct. - Wrote a targeted Go test against
buildEvalsJobwith the identical config used in the PR's ownTestTokenBrokerSupportsEvalsInferencetest and asserted byte offsets of the two step names in the joined steps string:reqIdx=4469comes beforeinvIdx=17627— also correct.
The apparent "invalidation before execution" reading comes from the step-builder function calls being interleaved in the Go source (buildDetectionJobSteps/buildEvalsJobSteps is invoked earlier in the function and internally nests the request step), not from the actual order they append to the steps slice. The compiled YAML confirms correct ordering in both jobs. Recommend resolving/dismissing both bot threads as false positives.
Test coverage gap for broker-enabled branches in action handlers (/tdd)
Five handlers (assign_to_agent.cjs, assign_copilot_to_created_issues.cjs, create_issue.cjs, create_pull_request.cjs, create_agent_session.cjs) each add an isTokenBrokerEnabled() branch that changes error-handling semantics (fail-fast vs. warn-and-continue, throw vs. swallow). None of these branches has a dedicated test, even though token_broker_github.test.cjs thoroughly covers the adapter itself. See inline comment for a concrete suggestion.
Inconsistent credential use on the failure-comment path (/codebase-design)
In assign_to_agent.cjs:670, the broker-enabled failure path swaps the handler's dedicated githubClient for the unrelated step-level github object when posting a failure comment — appearing to contradict the function's own docstring ("never falls back"). See inline comment.
Positive highlights
- ✅ Fail-closed design throughout
token_broker.cjs/token_broker_github.cjs: missing/invalid broker URL, malformed responses, and OIDC failures all throw typed errors rather than silently degrading to a weaker credential. - ✅
token_broker_github.cjs's request-time auth strategy (re-fetching the token per request rather than snapshotting an expiring one) is a good design choice, explicitly documented in a comment. - ✅ The spec doc's "Implementation status" section is unusually honest about partial integration (main-agent inference explicitly blocked, no end-to-end acceptance yet) — good
/grill-with-docspractice, avoids over-claiming. - ✅
TokenBrokerConfig's two independent boolean capabilities (copilot-request/copilot-task) map cleanly to the spec's "independent capabilities, not tiers" design goal.
Scope note
Given the diff size (32 files, ~2200 additions), I focused on the triaged high-impact files (token_broker.go, token_broker.cjs/token_broker_github.cjs, the 5 action handlers, frontmatter_types.go, the two flagged job builders) within the review's exploration budget. I did not do a line-by-line pass of the full 365-line spec document or the parser schema test file.
🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · copilot · sonnet50 · ~224 AIC · ⌖ ~16 AIC · ⊞ 10.2K
Comment /matt to run again
| // Post failure comment on the issue/PR so the user sees the failure in context | ||
| try { | ||
| await githubClient.rest.issues.createComment({ | ||
| await (brokerEnabled ? github : githubClient).rest.issues.createComment({ |
There was a problem hiding this comment.
[/codebase-design] When brokerEnabled, the failure-comment path silently swaps githubClient for the unrelated step-level github object. This is a different credential than the one used for the rest of the handler (find/assign/resolve calls all use githubClient), so a broker outage that fails assignment could also silently fail (or succeed with surprising permissions) to post the failure comment using a different identity than the docstring ('never falls back') promises.
💡 Suggestion
Either keep using githubClient here too (let the comment attempt fail closed and surface via the outer catch), or make the intentional fallback-to-step-token explicit with a comment explaining why the failure-reporting path is exempt from the 'never falls back' guarantee stated in the function docstring above.
@copilot please address this.
| @@ -331,6 +337,7 @@ async function main(config = {}) { | |||
| }); | |||
There was a problem hiding this comment.
[/tdd] None of the five new isTokenBrokerEnabled() branches added across assign_to_agent.cjs, assign_copilot_to_created_issues.cjs, create_issue.cjs, create_pull_request.cjs, and create_agent_session.cjs have a corresponding unit test. The broker-enabled control flow (fail-fast instead of ignore-if-error, throwing instead of warning, swapping clients) is a behavioral change from the non-broker path and is exactly the kind of branch /tdd says needs a red-green test before/alongside the implementation.
💡 Suggestion
Add at least one test per handler that sets GH_AW_SAFE_OUTPUTS_HANDLER_CONFIG={"_token_broker":{"copilot-task":true}} and asserts: (1) ignore-if-error is bypassed, (2) errors propagate/throw instead of being swallowed as warnings, and (3) the broker client factory is used instead of the PAT/step-token path. token_broker_github.test.cjs covers the adapter itself, but the call-sites' new branching logic is currently untested.
@copilot please address this.
There was a problem hiding this comment.
🟡 Changes recommended
Critical token-broker defects break credential exchange and cleanup, leave some jobs using legacy authentication, and persist credentials in step outputs despite the memory-only requirement.
8 open issues
When brokered assignment fails after an issue is created, this rethrow reaches the generic creation… · New Task handlers use this default masker, but setup deploys the scripts without@actions/core… · New With onlycopilot-requestselected, this early return also removes the legacy task-token… · NewevalsAuthDataretains the main workflow's task safe outputs, so task-only opt-in emits broker… · New A native-Claude main workflow with a GitHub-backed Claude or Codex detector passes validation and… · Newcore.setOutputwrites the broker credential to the runner'sGITHUB_OUTPUTfile and retains it… · New Setup copies JavaScript modules directly intoSetupActionDestination, so this nested require… · New Detection and evals receive one token snapshot, so the broker client's request-time renewal never… · New
What changed in this PR
Adds opt-in token brokering to gh-aw’s workflow compiler and safe-output runtime, allowing GitHub Actions identity tokens to obtain short-lived Copilot credentials. The draft integrates task authentication and secondary inference wiring while blocking main-agent GitHub-backed inference pending renewable credential support.
Changes:
- Adds independent request/task configuration, runtime endpoint resolution, and consumer-specific OIDC permissions.
- Implements credential exchange, caching, renewal checks, task authentication, and job cleanup.
- Adds protocol specifications, enterprise guidance, and compiler/runtime tests.
| File | Description |
|---|---|
pkg/workflow/workflow_data.go |
Tracks enabled broker capabilities. |
pkg/workflow/token_broker.go |
Adds broker selection, validation, exchange, and cleanup generation. |
pkg/workflow/token_broker_test.go |
Tests compiler integration and capability isolation. |
pkg/workflow/threat_detection_job.go |
Configures detection broker permissions and cleanup. |
pkg/workflow/threat_detection_inline_engine.go |
Adds inline detection credential exchange. |
pkg/workflow/threat_detection_external.go |
Propagates broker settings to external detection. |
pkg/workflow/safe_outputs_config_runtime.go |
Emits the task-authentication opt-in marker. |
pkg/workflow/permissions_compiler_validator.go |
Enforces broker permission and inference restrictions. |
pkg/workflow/frontmatter_types.go |
Defines typed broker configuration. |
pkg/workflow/frontmatter_serialization.go |
Preserves broker configuration during serialization. |
pkg/workflow/evals_steps.go |
Adds broker settings and exchange to eval execution. |
pkg/workflow/evals_job.go |
Adds eval broker permissions and cleanup. |
pkg/workflow/copilot_engine_execution.go |
Selects exchanged credentials for Copilot execution. |
pkg/workflow/compiler_safe_outputs_steps.go |
Configures task credentials and broker endpoint injection. |
pkg/workflow/compiler_safe_outputs_job.go |
Adds task-consumer OIDC permission and cleanup. |
pkg/workflow/compiler_orchestrator_workflow.go |
Loads broker capabilities from frontmatter. |
pkg/workflow/awf_env.go |
Excludes broker configuration from sandbox environments. |
pkg/parser/schemas/main_workflow_schema.json |
Validates capability-selection syntax. |
pkg/parser/schema_token_broker_test.go |
Tests accepted and rejected broker configurations. |
docs/src/content/docs/specs/token-broker-specification.md |
Defines the draft broker protocol and conformance requirements. |
docs/src/content/docs/specs/admission-service-specification.md |
Links the independent broker contract. |
docs/src/content/docs/reference/frontmatter.md |
Documents broker configuration and limitations. |
docs/src/content/docs/reference/enterprise-configuration.md |
Explains endpoint provisioning and enterprise prerequisites. |
actions/setup/js/token_broker.test.cjs |
Tests exchange validation, caching, failures, and invalidation. |
actions/setup/js/token_broker.cjs |
Implements the shared broker client. |
actions/setup/js/token_broker_github.test.cjs |
Tests request-time task authentication and failure handling. |
actions/setup/js/token_broker_github.cjs |
Adds renewable task authentication through Octokit. |
actions/setup/js/create_pull_request.cjs |
Applies broker authentication to fallback-issue assignment. |
actions/setup/js/create_issue.cjs |
Applies broker authentication to Copilot assignment. |
actions/setup/js/create_agent_session.cjs |
Uses broker authentication for task creation. |
actions/setup/js/assign_to_agent.cjs |
Integrates broker authentication and fail-closed handling. |
actions/setup/js/assign_copilot_to_created_issues.cjs |
Uses broker credentials for batch issue assignment. |
Review effort: Max (auto)
| } | ||
| } catch (error) { | ||
| core.warning(`Failed to assign copilot to issue #${issue.number}: ${getErrorMessage(error)}`); | ||
| if (isTokenBrokerEnabled()) throw error; |
| * with no fallback or retry. | ||
| * @param {BrokerOptions} [options] | ||
| */ | ||
| function createTokenBrokerClient({ env = process.env, fetchImpl = fetch, now = Date.now, mask = async token => (await import("@actions/core")).setSecret(token) } = {}) { |
| perms.Set(PermissionIdToken, PermissionWrite) | ||
| } | ||
| permissions := perms.RenderToYAML() | ||
| steps = append(steps, c.buildTokenBrokerInvalidationStep(&evalsAuthData)...) |
| if provider, known := resolveWorkflowEngineProvider(data, engineID); known { | ||
| return provider == LLMProviderGitHub |
| " with:\n", | ||
| " script: |\n", | ||
| " const { getBrokerToken } = require('"+SetupActionDestination+"/setup/js/token_broker.cjs');\n", | ||
| " core.setOutput('token', await getBrokerToken('copilot-request', { mask: token => core.setSecret(token) }, 'github'));\n", |
| " const { getBrokerToken } = require('"+SetupActionDestination+"/setup/js/token_broker.cjs');\n", | ||
| " core.setOutput('token', await getBrokerToken('copilot-request', { mask: token => core.setSecret(token) }, 'github'));\n", | ||
| ) | ||
| return step | ||
| } | ||
|
|
||
| func (c *Compiler) buildTokenBrokerInvalidationStep(data *WorkflowData) []string { | ||
| if !usesTokenBrokerInference(data) && !usesTokenBrokerTasks(data) { | ||
| return nil | ||
| } | ||
| return []string{ | ||
| " - name: Invalidate brokered Copilot credentials\n", | ||
| " if: always()\n", | ||
| " uses: " + getCachedActionPin("actions/github-script", data) + "\n", | ||
| " env:\n", | ||
| " " + tokenBrokerURLEnv + ": " + tokenBrokerURLExpression + "\n", | ||
| " with:\n", | ||
| " script: |\n", | ||
| " const { invalidateBrokerTokens } = require('" + SetupActionDestination + "/setup/js/token_broker.cjs');\n", |
| if usesTokenBrokerInference(workflowData) { | ||
| env["COPILOT_GITHUB_TOKEN"] = tokenBrokerCopilotRequestOutput |
Merged Focused tests, impacted tests, lint (after a timeout retry), and workflow drift checks pass. The broader CJS run still has 20 failures in unchanged areas (mostly timeouts, plus filesystem/fixture failures). CodeQL timed out without a result. CI on the pushed HEAD remains unverified and needs a maintainer re-trigger. |
|
@copilot mark feature as experimental |
Co-authored-by: pelikhan <[email protected]>
Marked token broker authentication experimental in the schema, configuration references, and specification. Enabling either capability now emits a compile-time experimental warning. Added regression coverage; final validation passes. Commit: |
|
@copilot merge main, recompile |
…c-token-broker Co-authored-by: pelikhan <[email protected]>
Co-authored-by: Copilot App <[email protected]>
Co-authored-by: pelikhan <[email protected]>
Merged |
Document three gaps found against v1.0.1 and its immediate follow-up commits: native Anthropic/OpenAI model-routing for Claude and Codex (#73052), the reserved pre-steps id: create-token wiring (#72932), and the new experimental token-broker: frontmatter field (#73261). Co-Authored-By: Claude Sonnet 5 <[email protected]>
|
🎉 This pull request is included in a new release. Release: |


Introduce opt-in exchange of GitHub Actions OIDC identity tokens for short-lived Copilot credentials through one centrally configured broker. This draft integrates task authentication; inference remains blocked on renewable credential support in AWF.
Configuration
token-broker: true; existing authentication remains unchanged when disabled.GH_AW_TOKEN_BROKER_URLat runtime from organization/repository Actions variables or secrets; grant OIDC permissions only to consuming jobs.Credential exchange
copilot-requestandcopilot-taskexchanges with expiration validation, isolated in-memory caching, and renewal.Task integration
Server specification
Remaining blocker