Repository navigation
Conversation
…entity federation When WORKOS_API_KEY and --api-key are unset and the CLI runs in GitHub Actions with WORKOS_CLIENT_ID and an OIDC token request URL, exchange the workflow's GitHub OIDC token at WORKOS_WIF_TOKEN_URL for a short-lived WorkOS access token and use it as the Bearer for REST calls, sending x-url-environment-id when WORKOS_ENVIRONMENT_ID is set. The token is cached in memory only and refreshed inside the expiry margin.
A failed WIF token refresh inside the SDK's fetch is already reported; re-throw it instead of printing a second 'Unexpected error'.
nicknisi
marked this pull request as ready for review
October 28, 2026 13:50
[Critical impact] The latest changes appear safe to merge and fix the earlier test-order issue. SummaryAdds GitHub Actions workload identity federation for REST commands without an API key.
|
Clear registered secrets before every test and give the leak test its own token values, so each case only echoes values the CLI has already handled.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Decided
no_api_keyseewif_id_token_unavailablewhen WORKOS_CLIENT_ID is se… → A: Publish it as asked (the author's answer)no_api_keyseewif_id_token_unavailablewhen WORKOS_CLIENT_ID is se… → A: Refuse verify-login on WIF tokens (the author's answer)Proven
if git rev-parse -q --verify MERGE_HEAD >/dev/null; then B=HEAD; else B=$(git merge-base origin/HEAD HEAD 2>/dev/null || git merge-base main HEAD) && git diff --quiet HEAD --; fi && test -f src/lib/wif.ts && test -f src/lib/wif.spec.ts && test -f examples/wif-github-actions/.github/workflows/wif-test.yml && test -f examples/wif-github-actions/README.md && git grep -q -F "never leaks either token" -- src/lib/wif.spec.ts && git grep -q -F "id-token: write" -- src/lib/wif.ts && git grep -q -F "WORKOS_WIF_TOKEN_URL" -- src/lib/wif.ts examples/wif-github-actions/README.md && git grep -q -F "WORKOS_WIF_AUDIENCE" -- src/lib/wif.ts && git grep -q -F "x-url-environment-id" -- src && git grep -q -F "urn:ietf:params:oauth:grant-type:jwt-bearer" -- src/lib/wif.ts examples/wif-github-actions/.github/workflows/wif-test.yml && git grep -q -F "token.actions.githubusercontent.com" -- examples/wif-github-actions/README.md && git diff --quiet $B -- package.json bun.lock src/cli.config.ts && (bun install --frozen-lockfile >/dev/null 2>&1 || bun install --frozen-lockfile --prefer-offline >/dev/null 2>&1) && node -e 'const y=require("yaml");const d=y.parse(require("fs").readFileSync("examples/wif-github-actions/.github/workflows/wif-test.yml","utf8"));const p=d.permissions||{};const ok=d.on&&("workflow_dispatch" in (typeof d.on==="string"?{[d.on]:1}:d.on))&&p["id-token"]==="write"&&p.contents==="read"&&Object.keys(d.jobs||{}).length>=2;process.exit(ok?0:1)' && bun run typecheck && bun run lint && bun run format:check && NODE_OPTIONS=--no-warnings /opt/homebrew/bin/timeout 480 bunx vitest run src/lib/wif.spec.ts src/lib/api-key.spec.ts src/lib/workos-client.spec.ts src/commands/apipassed on fba0bd8 (run 1).if git rev-parse -q --verify MERGE_HEAD >/dev/null; then B=HEAD; else B=$(git merge-base origin/HEAD HEAD 2>/dev/null || git merge-base main HEAD) && git diff --quiet HEAD --; fi && test -f src/lib/wif.ts && test -f src/lib/wif.spec.ts && test -f examples/wif-github-actions/.github/workflows/wif-test.yml && test -f examples/wif-github-actions/README.md && git grep -q -F "never leaks either token" -- src/lib/wif.spec.ts && git grep -q -F "id-token: write" -- src/lib/wif.ts && git grep -q -F "WORKOS_WIF_TOKEN_URL" -- src/lib/wif.ts examples/wif-github-actions/README.md && git grep -q -F "WORKOS_WIF_AUDIENCE" -- src/lib/wif.ts && git grep -q -F "x-url-environment-id" -- src && git grep -q -F "urn:ietf:params:oauth:grant-type:jwt-bearer" -- src/lib/wif.ts examples/wif-github-actions/.github/workflows/wif-test.yml && git grep -q -F "token.actions.githubusercontent.com" -- examples/wif-github-actions/README.md && git diff --quiet $B -- package.json bun.lock src/cli.config.ts && (bun install --frozen-lockfile >/dev/null 2>&1 || bun install --frozen-lockfile --prefer-offline >/dev/null 2>&1) && node -e 'const y=require("yaml");const d=y.parse(require("fs").readFileSync("examples/wif-github-actions/.github/workflows/wif-test.yml","utf8"));const p=d.permissions||{};const ok=d.on&&("workflow_dispatch" in (typeof d.on==="string"?{[d.on]:1}:d.on))&&p["id-token"]==="write"&&p.contents==="read"&&Object.keys(d.jobs||{}).length>=2;process.exit(ok?0:1)' && bun run typecheck && bun run lint && bun run format:check && NODE_OPTIONS=--no-warnings /opt/homebrew/bin/timeout 480 bunx vitest run src/lib/wif.spec.ts src/lib/api-key.spec.ts src/lib/workos-client.spec.ts src/commands/apipassed on fba0bd8 merged onto main at a3cb418 (run 2).Not checked
wif-test-<run id>.Opened as a draft by Riker (job 239).