Skip to content

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

Closed
loganvolkers wants to merge 3 commits into
dependabot:mainfrom
loganvolkers:loganvolkers/gcp-sts-four-minute-threshold
Closed

loganvolkers wants to merge 3 commits into
dependabot:mainfrom
loganvolkers:loganvolkers/gcp-sts-four-minute-threshold

Conversation

@loganvolkers

Copy link
Copy Markdown

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.

loganvolkers and others added 3 commits October 16, 2026 15:54
Use a matching four-minute refresh buffer for direct GCP WIF tokens so newly accepted short-lived tokens remain reusable. Keep service-account impersonation and other providers unchanged, and cover lifetime and cache boundaries with a fake clock.

Fixes dependabot#262.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Explain why exchange latency requires a minimum below GitHub's five-minute OIDC lifetime, and why a five-minute refresh buffer immediately expires fresh direct WIF tokens. Reference the public issue and authentication documentation.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Keep the existing time.Add style when applying the provider-specific refresh buffer.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@loganvolkers
loganvolkers marked this pull request as ready for review October 16, 2026 23:17
@loganvolkers
loganvolkers requested a review from a team as a code owner October 16, 2026 23:17
Copilot AI balanced review requested due to automatic review settings October 16, 2026 23:17

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 changes align acceptance and caching behavior, with regression coverage and no unresolved findings.

No open issues 🎉

What changed in this PR

Fixes #262 by accepting short-lived direct GCP Workload Identity Federation tokens and aligning their cache refresh buffer.

Changes:

  • Lowers direct WIF acceptance and refresh thresholds to four minutes.
  • Preserves five-minute buffers for impersonation and other providers.
  • Adds boundary and cache-reuse tests and updates documentation.
File Description
internal/​oidc/​oidc_credential.go Applies the direct WIF refresh buffer.
internal/​oidc/​oidc_credential_test.go Tests token reuse, refresh boundaries, and impersonation behavior.
internal/​oidc/​actions_oidc.go Lowers the direct WIF minimum lifetime.
internal/​oidc/​actions_oidc_test.go Updates the exact-boundary rejection test.
.github/​copilot-instructions.md Documents the direct WIF buffer exception.

Review effort: Balanced

@v-thavaahariharangit

Copy link
Copy Markdown
Contributor

Covered here: #342

@loganvolkers

Copy link
Copy Markdown
Author

Thanks @v-thavaahariharangit -- although not sure why you duplicated my PR exactly including files and PR description 🤔

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