Skip to content

Lower the direct GCP WIF token lifetime threshold to four minutes - #342

Merged
v-thavaahariharangit merged 1 commit into
mainfrom
copilot/gcp-wif-four-minute-threshold
Oct 27, 2026
Merged

v-thavaahariharangit merged 1 commit into
mainfrom
copilot/gcp-wif-four-minute-threshold

Conversation

@v-thavaahariharangit

@v-thavaahariharangit v-thavaahariharangit commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

What are you trying to accomplish?

Lower the minimum remaining lifetime for direct GCP Workload Identity Federation tokens from five minutes to four minutes. Use the same four-minute refresh buffer so accepted, approximately five-minute tokens can be reused instead of immediately expiring in the cache.

Fixes #262.

Anything you want to highlight for special attention from reviewers?

Tokens with exactly four minutes or less remaining are still rejected. Service-account impersonation and other providers retain their five-minute refresh buffer. Comments link to the issue and the documented five-minute GitHub OIDC token lifetime to explain why this must remain below five minutes. This source change does not update GitHub's deployed proxy.

How will you know you've accomplished your goal?

Synthetic HTTP mocks and Go's fake clock cover 4m58s token reuse, refresh at the cache boundary, the exact four-minute rejection boundary, shorter and expired tokens, longer-lived tokens, and unchanged impersonation behavior. No cloud credentials or services are used by these regression tests.

Validation with Go 1.26.0:

  • go test -mod=vendor ./internal/oidc -run '^(TestGetOrRefreshGCPToken|TestGetGCPAccessToken)$' -count=1 - passed.
  • go test -mod=vendor -race -shuffle=on -count=2 ./internal/oidc - passed.
  • go test -mod=vendor -race -shuffle=on -count=2 ./... - passed.
  • go build -mod=vendor ./... - passed.
  • go vet -mod=vendor ./... - passed.
  • gofmt -l internal/oidc/actions_oidc.go internal/oidc/oidc_credential.go internal/oidc/actions_oidc_test.go internal/oidc/oidc_credential_test.go - clean.
  • git diff --check - passed.
  • script/test - blocked: Docker buildx is unavailable; the Docker daemon is also unavailable. The complete race-enabled Go test suite passed locally as listed above.

Checklist

  • I have run the complete test suite to ensure all tests and linters pass.
  • I have thoroughly tested my code changes to ensure they work as expected, including adding additional tests for new functionality.
  • I have written clear and descriptive commit messages.
  • I have provided a detailed description of the changes in the pull request, including the problem it addresses, how it fixes the problem, and any relevant details about the implementation.
  • I have ensured that the code is well-documented and easy to understand.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@v-thavaahariharangit
v-thavaahariharangit requested a review from a team as a code owner October 27, 2026 15:05
Copilot AI balanced review requested due to automatic review settings October 27, 2026 15:05

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

The narrow validation and caching changes are consistent, with focused regression coverage and no unresolved findings.

No open issues 🎉

What changed in this PR

Fixes #262 by allowing direct GCP Workload Identity Federation tokens with more than four minutes remaining and aligning their cache refresh buffer with that threshold.

Changes:

  • Lowers direct WIF validation and refresh buffers to four minutes, preserving five-minute behavior for impersonation and other providers.
  • Adds regression coverage for token reuse, refresh timing, rejected lifetimes, and unchanged impersonation behavior.
  • Documents the direct GCP WIF exception.
File Description
internal/​oidc/​oidc_credential.go Applies the four-minute cache buffer to direct GCP WIF.
internal/​oidc/​oidc_credential_test.go Tests lifetime boundaries, caching, refresh, and impersonation.
internal/​oidc/​actions_oidc.go Defines and applies the four-minute direct WIF threshold.
internal/​oidc/​actions_oidc_test.go Updates the exact rejection-boundary test to four minutes.
.github/​copilot-instructions.md Documents the provider-specific cache buffer.

Review effort: Balanced

@v-thavaahariharangit
v-thavaahariharangit merged commit af8b1c6 into main Oct 27, 2026
113 of 115 checks passed
@v-thavaahariharangit
v-thavaahariharangit deleted the copilot/gcp-wif-four-minute-threshold branch October 27, 2026 15:37
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.

GCP OIDC: direct resource access fails with "GCP STS token expires too soon"

3 participants