Skip to content

feat(client/cli): refresh OIDC token on the fly - #2026

Merged
tkircsi merged 5 commits into
mainfrom
feat/lazy-bearer
Aug 17, 2026
Merged

tkircsi merged 5 commits into
mainfrom
feat/lazy-bearer

Conversation

@tkircsi

@tkircsi tkircsi commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Closes #2022

@github-actions github-actions Bot added the size/M Denotes a PR that changes 200-999 lines label Aug 14, 2026
@tkircsi tkircsi self-assigned this Aug 14, 2026
@tkircsi tkircsi added kind/feature Categorizes issue or PR as related to a new feature. area/cli area/dir/client go Pull requests that update go code labels Aug 14, 2026
@akijakya
akijakya requested a balanced review from Copilot August 14, 2026 09:45

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.

Pull request overview

Adds renewable OIDC authentication for long-running dirctl operations.

Changes:

  • Resolves bearer tokens per RPC and refreshes cached tokens.
  • Adds GitHub Actions token minting and OIDC audience configuration.
  • Updates import workflows and documentation.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
client/oidc_grpc.go Adds lazy, renewable token sources.
client/oidc_grpc_test.go Tests per-request and cached-token refresh.
client/oidc_github.go Implements GitHub Actions token minting.
client/oidc_github_test.go Tests minting, renewal, and error handling.
client/config.go Adds client audience configuration.
client/config/config.go Propagates audience through configuration layers.
cli/config/config.go Maps the audience CLI override.
cli/cmd/options.go Adds the --oidc-audience flag.
cli/cmd/context/show.go Displays the resolved audience.
.github/workflows/import-records.yaml Switches imports to renewable tokens.
docs/content/dir/dir-component-oidc-authentication.md Documents GitHub Actions renewal.
docs/content/dir/dir-cli-reference.md Documents renewable-token usage.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread client/config/config.go Resolved
@tkircsi
tkircsi marked this pull request as ready for review August 14, 2026 12:43
@tkircsi
tkircsi requested a review from a team as a code owner August 14, 2026 12:44
@csirmazbendeguz

Copy link
Copy Markdown
Contributor

Can this refresh flow be generalized to other OIDC providers than GitHub as well? I would prefer avoiding GitHub Actions specific code

@tkircsi

tkircsi commented Aug 14, 2026

Copy link
Copy Markdown
Contributor Author

The refresh flow already is generic. What's GitHub-specific isn't refreshing a token, it's obtaining one in the first place, and that part has no cross-provider standard to generalize to.

The renewal mechanism in this PR is tokenSourceFunc — a function consulted on every RPC by oidcBearerCredentials. Nothing in it knows about any provider. Two sources plug into it, and both renew: cachedOIDCTokenSource does standard OIDC refresh against whatever issuer is in the token cache, using the refresh_token grant and the issuer's discovery document. That's already provider-neutral — Okta, Auth0, Keycloak, Entra all renew mid-run today with no additional code. Before this PR that path resolved once at dial and never refreshed, so generalized refresh for real IdPs is precisely what the PR adds.

githubIDTokenSource is a different category of thing. It isn't an OIDC provider adapter; it's a workload-identity token issuance API belonging to the CI platform, and there's no RFC for "ask my runner for an ID token".

@codecov

codecov Bot commented Aug 14, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 85.49618% with 19 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
client/oidc_github.go 83.9% 5 Missing and 5 partials ⚠️
client/oidc_grpc.go 87.5% 5 Missing and 2 partials ⚠️
client/config/config.go 75.0% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

@tkircsi
tkircsi merged commit 443c860 into main Aug 17, 2026
35 checks passed
@tkircsi
tkircsi deleted the feat/lazy-bearer branch August 17, 2026 12:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/cli area/dir/client go Pull requests that update go code kind/feature Categorizes issue or PR as related to a new feature. size/M Denotes a PR that changes 200-999 lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: dirctl never renews its OIDC token, so commands outliving it fail with Unauthenticated

3 participants