Skip to content

added basic provisioner refresh on jwks cache miss - #2769

Open
APWHY wants to merge 1 commit into
smallstep:masterfrom
APWHY:jwks-reload-on-unknown-kid
Open

APWHY wants to merge 1 commit into
smallstep:masterfrom
APWHY:jwks-reload-on-unknown-kid

Conversation

@APWHY

@APWHY APWHY commented Aug 20, 2026

Copy link
Copy Markdown

step-ca only refetches the JWKS from the issuer once the cached set has expired (which comes from the JWKS endpoint's Cache-Control: max-age). This means if the issuer rotates keys all future requests through the affected provisioners will fail until the cache expires naturally.

This PR adds a refresh mechanism that runs at most once every minute if there is an unfamiliar received kid, following the recommendation at: https://openid.net/specs/openid-connect-core-1_0.html#RotateSigKeys . Concurrent reload requests are grouped as well.

go-oidc has done something similar where they've completely removed the Cache-control checks entirely, but I wanted to minimise the changes this PR made so I've left them in for now.

An additional fix has been added to getKeysFromJWKsURI so it rejects non 2xx/3xx codes and returns an error. Previously, if the error had a decodeable JSON body it would attempt to do so and empty the keystore (and error out otherwise). It's not entirely related and I can split this out into a separate PR if needed.

@github-actions github-actions Bot added the needs triage Waiting for discussion / prioritization by team label Aug 20, 2026
@APWHY
APWHY force-pushed the jwks-reload-on-unknown-kid branch 2 times, most recently from 37eb0e8 to 8afa09b Compare August 25, 2026 15:31
@APWHY
APWHY force-pushed the jwks-reload-on-unknown-kid branch from c450413 to afa67d5 Compare September 7, 2026 11:08
Adds a refresh mechanism to the cached JWK Set if an unknown key id is recieved. An additional fix has been added to getKeysFromJWKsURI so it rejects non 2xx/3xx codes and returns an error.
@APWHY
APWHY force-pushed the jwks-reload-on-unknown-kid branch from afa67d5 to b94f7bd Compare September 7, 2026 11:11
@APWHY
APWHY marked this pull request as ready for review September 7, 2026 11:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs triage Waiting for discussion / prioritization by team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants