diff --git a/.github/workflows/reusable-dispatch.yml b/.github/workflows/reusable-dispatch.yml index 3446df9384..d34d76ff86 100644 --- a/.github/workflows/reusable-dispatch.yml +++ b/.github/workflows/reusable-dispatch.yml @@ -24,6 +24,9 @@ # # Security: all user-controlled inputs (comment body, labels, usernames) # are passed via env: variables, not interpolated in run: blocks. +# The route and harness-dispatch jobs need OIDC for mint-backed identity +# lookup. Callers must grant id-token: write; keep the token within each job +# and never write it to workflow outputs, logs, or matrix data. name: Dispatch on: @@ -116,6 +119,7 @@ jobs: runs-on: ${{ inputs.runner_image }} permissions: contents: read + id-token: write issues: read pull-requests: read outputs: @@ -703,6 +707,7 @@ jobs: GITHUB_EVENT_NAME: ${{ github.event_name }} EVENT_ACTION: ${{ inputs.event_action }} ROUTE_AGENT: ${{ steps.cel-opt-in.outputs.agent }} + FULLSEND_MINT_URL: ${{ inputs.mint_url }} run: | set -euo pipefail # gha_text makes a value safe inside a ::notice::/::warning::/::error:: @@ -1849,6 +1854,7 @@ jobs: permissions: actions: write contents: read + id-token: write pull-requests: read outputs: matrix: ${{ steps.dispatch.outputs.matrix }} @@ -1984,6 +1990,7 @@ jobs: GH_TOKEN: ${{ github.token }} GITHUB_EVENT_NAME: ${{ github.event_name }} EVENT_ACTION: ${{ inputs.event_action }} + FULLSEND_MINT_URL: ${{ inputs.mint_url }} run: | set -euo pipefail if [[ "${{ steps.triggers.outputs.has_triggers }}" != "true" ]]; then diff --git a/docs/guides/user/custom-poller-example.md b/docs/guides/user/custom-poller-example.md index fdf2d9e5c2..cf6f7ee2bf 100644 --- a/docs/guides/user/custom-poller-example.md +++ b/docs/guides/user/custom-poller-example.md @@ -146,6 +146,16 @@ Required permissions: - `packages: read` - needed by code/fix agents - `actions: write`, `id-token: write`, `issues: write`, `pull-requests: write` - needed by all agents +`id-token: write` lets GitHub Actions issue the job a short-lived [OpenID +Connect (OIDC) token](how-fullsend-authenticates.md). Fullsend uses this token +to identify the calling workflow during dispatch and to mint short-lived +[GitHub App installation tokens](../../glossary.md#installation-token) for +agents. +Grant it in the caller workflow or on the job that calls +`reusable-dispatch.yml`; the reusable workflow cannot add permissions that the +caller did not grant. Keep the OIDC token inside the job. Do not copy it into +workflow outputs, the dispatch matrix, or logs. + ## Authorization When using a pre-computed matrix, the `.fullsend/config.yaml` agent-enablement checks are bypassed. The token mint service acts as the authorization boundary (see [mint-administration.md](../infrastructure/mint-administration.md)) - ensure your mint service is properly configured to control which agents external callers can invoke. diff --git a/internal/scaffold/workflow_call_alignment_test.go b/internal/scaffold/workflow_call_alignment_test.go index b20c6a17e8..8af39f7945 100644 --- a/internal/scaffold/workflow_call_alignment_test.go +++ b/internal/scaffold/workflow_call_alignment_test.go @@ -847,6 +847,65 @@ func TestReusableDispatchWorkflowContent(t *testing.T) { assert.Regexp(t, `(?s)ready-for-review"\s*\]\];\s*then\s*\n\s+if \[\[ "\$\{ISSUE_IS_PR\}"`, s) } +// TestReusableDispatchJobsReceiveMintOIDC validates permissions and mint URL +// wiring for both gha-event dispatch steps (#8814). The OIDC token remains +// job-local and is not copied into outputs, logs, or matrix data. +func TestReusableDispatchJobsReceiveMintOIDC(t *testing.T) { + type workflowStep struct { + Name string `yaml:"name"` + Run string `yaml:"run"` + Env map[string]string `yaml:"env"` + } + type workflowJob struct { + Permissions map[string]string `yaml:"permissions"` + Outputs map[string]string `yaml:"outputs"` + Steps []workflowStep `yaml:"steps"` + } + var workflow struct { + Jobs map[string]workflowJob `yaml:"jobs"` + } + + content, err := os.ReadFile(filepath.Join("..", "..", ".github", "workflows", "reusable-dispatch.yml")) + require.NoError(t, err) + require.NoError(t, yaml.Unmarshal(content, &workflow)) + + for _, tc := range []struct { + jobName string + stepName string + }{ + {jobName: "route", stepName: "Evaluate CEL route"}, + {jobName: "harness-dispatch", stepName: "Run fullsend dispatch"}, + } { + t.Run(tc.jobName, func(t *testing.T) { + job, ok := workflow.Jobs[tc.jobName] + require.True(t, ok, "job %q must exist", tc.jobName) + assert.Equal(t, "write", job.Permissions["id-token"], + "job %q must be able to request an OIDC token", tc.jobName) + + var dispatch workflowStep + for _, step := range job.Steps { + if step.Name == tc.stepName { + dispatch = step + break + } + } + require.NotEmpty(t, dispatch.Name, "job %q must include step %q", tc.jobName, tc.stepName) + assert.Contains(t, dispatch.Run, "--input-driver gha-event", + "step %q must use the GitHub event driver", tc.stepName) + assert.Equal(t, "${{ inputs.mint_url }}", dispatch.Env["FULLSEND_MINT_URL"], + "step %q must receive the configured mint URL", tc.stepName) + for name, value := range job.Outputs { + assert.NotContains(t, name, "ACTIONS_ID_TOKEN_REQUEST_TOKEN", + "job %q output names must not expose the OIDC request token", tc.jobName) + assert.NotContains(t, value, "ACTIONS_ID_TOKEN_REQUEST_TOKEN", + "job %q outputs must not expose the OIDC request token", tc.jobName) + } + }) + } + assert.NotContains(t, string(content), "ACTIONS_ID_TOKEN_REQUEST_TOKEN", + "the workflow must not copy the OIDC request token into logs or matrix data") +} + // TestCustomAppSetReviewBotWiring ensures every GitHub review/fix dispatch // path receives the configured app-set prefix and recognizes its exact review // bot identity.