Skip to content

Commit 709ef16

Browse files
authored
Authenticate Claude CI with workload identity (#9966)
Use workload identity to authenticate claude review requests
1 parent 96bd521 commit 709ef16

5 files changed

Lines changed: 29 additions & 16 deletions

File tree

‎.github/workflows/claude-review.yml‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@ name: Claude Code (Review)
33
# Setup
44
# - This workflow does not need the GitHub App private key.
55
# - Do not attach the `claude-automation` environment here.
6-
# - Store `CLAUDE_CODE_OAUTH_TOKEN` as a repository or organization Actions secret.
7-
# - Create a repository or organization Actions variable:
6+
# - Anthropic auth is workload identity federation, so there is no Anthropic secret.
7+
# - Create repository or organization Actions variables:
88
# - CLAUDE_APP_LOGIN
99
# Set this to the bot login for the GitHub App, usually `<app-slug>[bot]`.
10+
# - ANTHROPIC_ORGANIZATION_ID, ANTHROPIC_SERVICE_ACCOUNT_ID, ANTHROPIC_FEDERATION_RULE_CI
11+
# Identifiers, not credentials.
1012
# - It may use the default GITHUB_TOKEN to read repository data and post review
1113
# comments, but it must never be able to push commits or open branches.
1214
#
@@ -230,6 +232,8 @@ jobs:
230232
issues: write
231233
pull-requests: write
232234
actions: read
235+
# Requests the OIDC token exchanged for an Anthropic one. No repo access.
236+
id-token: write
233237
steps:
234238
- name: Checkout same-repo PR contents
235239
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
@@ -244,7 +248,11 @@ jobs:
244248
id: claude
245249
uses: anthropics/claude-code-action@fbda2eb1bdc90d319b8d853f5deb53bca199a7c1 # v1.0.140
246250
with:
247-
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
251+
# The `vortex-claude-ci` rule refuses any run off the default branch.
252+
anthropic_federation_rule_id: ${{ vars.ANTHROPIC_FEDERATION_RULE_CI }}
253+
anthropic_organization_id: ${{ vars.ANTHROPIC_ORGANIZATION_ID }}
254+
anthropic_service_account_id: ${{ vars.ANTHROPIC_SERVICE_ACCOUNT_ID }}
255+
248256
# This workflow deliberately uses the built-in token because it only needs
249257
# to read repository state and post review comments. It cannot write repo
250258
# contents, and it has no access to the GitHub App private key.

‎.github/workflows/claude-write.yml‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@ name: Claude Code (Write)
1010
# 4. Store these environment secrets in `claude-automation`:
1111
# - APP_ID
1212
# - APP_PRIVATE_KEY
13-
# - CLAUDE_CODE_OAUTH_TOKEN
14-
# 5. Create a repository or organization Actions variable:
13+
# 5. Create repository or organization Actions variables:
1514
# - CLAUDE_APP_LOGIN
1615
# Set this to the bot login for the GitHub App, usually `<app-slug>[bot]`.
16+
# - ANTHROPIC_ORGANIZATION_ID, ANTHROPIC_SERVICE_ACCOUNT_ID, ANTHROPIC_FEDERATION_RULE_WRITE
17+
# Identifiers, not credentials. The write rule matches only this workflow.
1718
#
1819
# Why this workflow exists separately
1920
# - This is the only workflow that can read the GitHub App private key.
@@ -197,7 +198,12 @@ jobs:
197198
id: claude
198199
uses: anthropics/claude-code-action@fbda2eb1bdc90d319b8d853f5deb53bca199a7c1 # v1.0.140
199200
with:
200-
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
201+
# The environment puts `environment:claude-automation` in the OIDC subject,
202+
# which is all the `vortex-claude-write` rule matches. Unreachable elsewhere.
203+
anthropic_federation_rule_id: ${{ vars.ANTHROPIC_FEDERATION_RULE_WRITE }}
204+
anthropic_organization_id: ${{ vars.ANTHROPIC_ORGANIZATION_ID }}
205+
anthropic_service_account_id: ${{ vars.ANTHROPIC_SERVICE_ACCOUNT_ID }}
206+
201207
github_token: ${{ steps.app-token.outputs.token }}
202208

203209
# Claude may inspect CI state on related PRs, but this workflow is otherwise

‎.github/workflows/fuzz.yml‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ jobs:
4949
branch: ${{ github.ref_name }}
5050
commit: ${{ github.sha }}
5151
secrets:
52-
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
5352
gh_token: ${{ secrets.GITHUB_TOKEN }}
5453
incident_io_alert_token: ${{ secrets.INCIDENT_IO_ALERT_TOKEN }}
5554

@@ -103,7 +102,6 @@ jobs:
103102
branch: ${{ github.ref_name }}
104103
commit: ${{ github.sha }}
105104
secrets:
106-
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
107105
gh_token: ${{ secrets.GITHUB_TOKEN }}
108106
incident_io_alert_token: ${{ secrets.INCIDENT_IO_ALERT_TOKEN }}
109107

@@ -141,7 +139,6 @@ jobs:
141139
branch: ${{ github.ref_name }}
142140
commit: ${{ github.sha }}
143141
secrets:
144-
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
145142
gh_token: ${{ secrets.GITHUB_TOKEN }}
146143
incident_io_alert_token: ${{ secrets.INCIDENT_IO_ALERT_TOKEN }}
147144

@@ -179,7 +176,6 @@ jobs:
179176
branch: ${{ github.ref_name }}
180177
commit: ${{ github.sha }}
181178
secrets:
182-
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
183179
gh_token: ${{ secrets.GITHUB_TOKEN }}
184180
incident_io_alert_token: ${{ secrets.INCIDENT_IO_ALERT_TOKEN }}
185181

@@ -217,7 +213,6 @@ jobs:
217213
branch: ${{ github.ref_name }}
218214
commit: ${{ github.sha }}
219215
secrets:
220-
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
221216
gh_token: ${{ secrets.GITHUB_TOKEN }}
222217
incident_io_alert_token: ${{ secrets.INCIDENT_IO_ALERT_TOKEN }}
223218

@@ -259,5 +254,4 @@ jobs:
259254
# branch: ${{ github.ref_name }}
260255
# commit: ${{ github.sha }}
261256
# secrets:
262-
# claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
263257
# gh_token: ${{ secrets.GITHUB_TOKEN }}

‎.github/workflows/fuzzer-fix-automation.yml‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,10 @@ jobs:
274274
ARTIFACT_URL: ${{ steps.extract.outputs.artifact_url }}
275275
uses: anthropics/claude-code-action@bf38e86e58df9ebf3420326d019f955bb3be64dd # v1
276276
with:
277-
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
277+
# Same `vortex-claude-ci` rule as the rest of the fuzz pipeline.
278+
anthropic_federation_rule_id: ${{ vars.ANTHROPIC_FEDERATION_RULE_CI }}
279+
anthropic_organization_id: ${{ vars.ANTHROPIC_ORGANIZATION_ID }}
280+
anthropic_service_account_id: ${{ vars.ANTHROPIC_SERVICE_ACCOUNT_ID }}
278281
# Use the App token (not GITHUB_TOKEN) so the committed fix branch and
279282
# its draft PR trigger normal pull_request CI workflows.
280283
github_token: ${{ steps.app-token.outputs.token }}

‎.github/workflows/report-fuzz-crash.yml‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ on:
3232
description: "The issue number that was created or commented on"
3333
value: ${{ jobs.report.outputs.issue_number }}
3434
secrets:
35-
claude_code_oauth_token:
36-
required: false
3735
gh_token:
3836
required: true
3937
# incident.io alert source token from Alerts > Alert sources > Custom HTTP.
@@ -120,7 +118,11 @@ jobs:
120118
continue-on-error: true
121119
uses: anthropics/claude-code-action@bf38e86e58df9ebf3420326d019f955bb3be64dd # v1
122120
with:
123-
claude_code_oauth_token: ${{ secrets.claude_code_oauth_token }}
121+
# A called workflow sees the caller's OIDC subject, so `vortex-claude-ci`
122+
# matches here too and no secret needs passing down.
123+
anthropic_federation_rule_id: ${{ vars.ANTHROPIC_FEDERATION_RULE_CI }}
124+
anthropic_organization_id: ${{ vars.ANTHROPIC_ORGANIZATION_ID }}
125+
anthropic_service_account_id: ${{ vars.ANTHROPIC_SERVICE_ACCOUNT_ID }}
124126
github_token: ${{ secrets.gh_token }}
125127
show_full_output: true
126128
prompt: |

0 commit comments

Comments
 (0)