Skip to content

Add OIDC token broker specification and task authentication - #73261

Merged
pelikhan merged 9 commits into
mainfrom
copilot/implement-oidc-token-broker
Oct 30, 2026
Merged

pelikhan merged 9 commits into
mainfrom
copilot/implement-oidc-token-broker

Conversation

Copilot AI commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

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

    • Add token-broker: true; existing authentication remains unchanged when disabled.
    • Resolve GH_AW_TOKEN_BROKER_URL at runtime from organization/repository Actions variables or secrets; grant OIDC permissions only to consuming jobs.
  • Credential exchange

    • Support independent copilot-request and copilot-task exchanges with expiration validation, isolated in-memory caching, and renewal.
    • Fail closed on broker errors without credential fallback; sanitize failures and prevent credential persistence.
  • Task integration

    • Authenticate Copilot task creation and issue assignment at request time.
  • Server specification

    • Add a W3C-style draft beside the official specifications covering the wire contract, JWT verification, authorization, issuance, lifecycle, and conformance requirements.
    • Document enterprise configuration and compatibility.
  • Remaining blocker

    • Pinned AWF snapshots inference credentials and lacks a supported renewal interface. Reject broker-enabled GitHub-backed inference during compilation.
    • Full acceptance still requires inference integration and live end-to-end execution.

Copilot AI changed the title WIP: add OIDC token broker specification and task authentication Add OIDC token broker specification and task authentication Oct 30, 2026
Copilot AI requested a review from pelikhan October 30, 2026 18:14
@pelikhan

Copy link
Copy Markdown
Collaborator

@copilot user should be able enable each token type separately, not as a bundle

@pelikhan

Copy link
Copy Markdown
Collaborator

@copilot token-broker copilot-request is not compatible with permissions.copilot-request:write

@pelikhan

Copy link
Copy Markdown
Collaborator

@copilot must be supported in evals / detection jobs

Copilot AI commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor Author

@copilot token-broker copilot-request is not compatible with permissions.copilot-request:write

Added a compile-time error for combining brokered copilot-request authentication with permissions.copilot-requests: write. Commit: 202b80e.

@copilot must be supported in evals / detection jobs

Brokered request authentication is now wired into detection and evals jobs, including job-scoped OIDC permissions. Commit: 202b80e.

@pelikhan

Copy link
Copy Markdown
Collaborator

@copilot run pr-finisher skill

@pelikhan

Copy link
Copy Markdown
Collaborator

@copilot the request to the oidc endpoint should specify the "provider", as a string. The provider matches the LLM inference provider inference ids.

Copilot AI commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor Author

@copilot must be supported in evals / detection jobs

Brokered copilot-request is wired into both threat-detection and evals jobs, with job-scoped OIDC permissions, in 202b80e.

@copilot user should be able enable each token type separately, not as a bundle

Implemented independent token-broker.copilot-request and token-broker.copilot-task options in 534fbc2; either capability can be enabled without enabling the other.

@copilot run pr-finisher skill

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.

@pelikhan

Copy link
Copy Markdown
Collaborator

@copilot the token broker must support an invalidate token operation that gets executed as a unconditional post step in job

Copilot AI commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor Author

@copilot the request to the oidc endpoint should specify the "provider", as a string. The provider matches the LLM inference provider inference ids.

Added the inference provider ID to brokered copilot-request exchanges and documented/tested provider-specific handling in 437ccd2.

@copilot the token broker must support an invalidate token operation that gets executed as a unconditional post step in job

Added an if: always() broker invalidation post-step to broker-consuming safe outputs, detection, and evals jobs in 437ccd2.

@pelikhan

Copy link
Copy Markdown
Collaborator

@copilot merge main, fix ci failures

detectionAuthData.Model = model
}
brokeredInference := usesTokenBrokerInference(detectionAuthData)
steps = append(steps, c.buildTokenBrokerInvalidationStep(detectionAuthData)...)
Comment thread pkg/workflow/evals_job.go Outdated
perms.Set(PermissionIdToken, PermissionWrite)
}
permissions := perms.RenderToYAML()
steps = append(steps, c.buildTokenBrokerInvalidationStep(&evalsAuthData)...)
@pelikhan
pelikhan marked this pull request as ready for review October 30, 2026 20:04
Copilot AI adaptive review requested due to automatic review settings October 30, 2026 20:05
@github-actions

Copy link
Copy Markdown
Contributor

Comment Memory

Peek at saved memory (pr-code-quality-reviewer)
reviewed_at: 2026-10-30T20:08:06Z
review_event: COMMENT
top_themes: [broker capability scope for non-Copilot assignments]
files_reviewed: [pkg/workflow/token_broker.go, pkg/workflow/evals_job.go, pkg/workflow/threat_detection_job.go, actions/setup/js/token_broker.cjs, pkg/workflow/evals_steps.go]
comment_count: 1

Note

This comment is managed by comment memory.

Expand the saved memory block to view or edit the persistent context for this thread.
Edit only the text inside the backtick fences; workflow metadata and the footer are regenerated automatically.

Learn more about comment memory

🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt50 · ~4 AIC · ⌖ ~1 AIC · ⊞ 1.6K · ◷
Comment /review to run again

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 ||

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.yml for the detection: job: step order is Request → Execute → Invalidate (if: always()) — correct.
  • Wrote a targeted Go test against buildEvalsJob with the identical config used in the PR's own TestTokenBrokerSupportsEvalsInference test and asserted byte offsets of the two step names in the joined steps string: reqIdx=4469 comes before invIdx=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-docs practice, 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({

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[/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 = {}) {
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[/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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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
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) } = {}) {
Comment thread pkg/workflow/evals_job.go Outdated
perms.Set(PermissionIdToken, PermissionWrite)
}
permissions := perms.RenderToYAML()
steps = append(steps, c.buildTokenBrokerInvalidationStep(&evalsAuthData)...)
Comment on lines +23 to +24
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",
Comment on lines +90 to +108
" 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",
Comment on lines +229 to +230
if usesTokenBrokerInference(workflowData) {
env["COPILOT_GITHUB_TOKEN"] = tokenBrokerCopilotRequestOutput

Copilot AI commented Oct 30, 2026

Copy link
Copy Markdown
Contributor Author

@copilot merge main, fix ci failures

Merged main in 099db94f. Fixed the logged CJS failure by replacing unavailable Factory model pins and regenerating their locks in 76b60a2f; also fixed local Go lint findings and added broker cleanup-order regression checks.

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.

@pelikhan

Copy link
Copy Markdown
Collaborator

@copilot mark feature as experimental

Copilot AI commented Oct 30, 2026

Copy link
Copy Markdown
Contributor Author

@copilot mark feature as experimental

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: ae20051.

Comment thread actions/setup/js/token_broker.cjs Resolved
@pelikhan

Copy link
Copy Markdown
Collaborator

@copilot merge main, recompile
Fix ci failures
Assign error constants and use them in errors

Copilot AI commented Oct 30, 2026

Copy link
Copy Markdown
Contributor Author

@copilot merge main, recompile
Fix ci failures
Assign error constants and use them in errors

Merged main, recompiled workflows, fixed the Aider event-attribution and stale smoke-contract failures, and added named token-broker validation errors. Validation passes locally; commit: 3c209f0. CI for this commit is still running.

@pelikhan
pelikhan merged commit da4cc9d into main Oct 30, 2026
50 checks passed
@pelikhan
pelikhan deleted the copilot/implement-oidc-token-broker branch October 30, 2026 22:48
github-actions Bot added a commit that referenced this pull request Oct 31, 2026
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]>
@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v1.2.0

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.

4 participants