Skip to content

oidc: expire cached JWKS based on cache headers - #143401

Open
yashaggarwal85d wants to merge 1 commit into
kubernetes:masterfrom
yashaggarwal85d:oidc-expire-jwks-by-cache-headers
Open

yashaggarwal85d wants to merge 1 commit into
kubernetes:masterfrom
yashaggarwal85d:oidc-expire-jwks-by-cache-headers

Conversation

@yashaggarwal85d

Copy link
Copy Markdown

What type of PR is this?

/kind feature
/sig auth

What this PR does / why we need it:

go-oidc's RemoteKeySet keeps keys forever and only refetches when it sees an unknown kid, so a key the provider has removed is still trusted as long as tokens use its kid. This wraps the key set and starts over with a fresh one once the JWKS response's Cache-Control max-age (or Expires) has passed. Responses without cache headers behave like before. Short lifetimes are clamped to 1 minute so we stay under the existing JWKS rate limit.

Which issue(s) this PR is related to:

Fixes #142100

Special notes for your reviewer:

Only covers the JWKS metrics path (beta, on by default), since that's where we build the RemoteKeySet ourselves. After expiry the next request waits on the refetch, and if that fetch fails the token is rejected rather than falling back to the stale keys. Open to keeping stale keys on fetch errors if that's preferred.

Does this PR introduce a user-facing change?

The OIDC/JWT authenticator now refetches the issuer's JWKS once the Cache-Control max-age or Expires of the previous response has passed, instead of caching keys until an unknown key ID shows up.

AI usage disclosure:

YES. This PR was written in part with the assistance of generative AI (it helped draft the key set wrapper and tests). I reviewed and tested the change and I'm responsible for it.

@kubernetes-prow kubernetes-prow Bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. kind/feature Categorizes issue or PR as related to a new feature. sig/auth Categorizes an issue or PR as relevant to SIG Auth. labels Oct 26, 2026
@kubernetes-prow kubernetes-prow Bot added needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Oct 26, 2026
@kubernetes-prow

Copy link
Copy Markdown
Contributor

This issue is currently awaiting triage.

If a SIG or subproject determines this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@kubernetes-prow kubernetes-prow Bot added needs-priority Indicates a PR lacks a `priority/foo` label and requires one. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Oct 26, 2026
@kubernetes-prow

Copy link
Copy Markdown
Contributor

Hi @yashaggarwal85d. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@kubernetes-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: yashaggarwal85d
Once this PR has been reviewed and has the lgtm label, please assign liggitt for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubernetes-prow
kubernetes-prow Bot requested review from aramase and enj October 26, 2026 04:02
@kubernetes-prow kubernetes-prow Bot added area/apiserver sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. labels Oct 26, 2026
@enj enj moved this to Needs Triage in SIG Auth Oct 26, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/apiserver cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. sig/auth Categorizes an issue or PR as relevant to SIG Auth. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

Status: Needs Triage

Development

Successfully merging this pull request may close these issues.

OIDC token authenticator should expire cached JWKs based on server-provided cache headers

1 participant