Skip to content

feat: add support for cacheing JWKS - #579

Open
ianroberts wants to merge 3 commits into
openpubkey:mainfrom
ianroberts:jwks-cache
Open

feat: add support for cacheing JWKS#579
ianroberts wants to merge 3 commits into
openpubkey:mainfrom
ianroberts:jwks-cache

Conversation

@ianroberts

@ianroberts ianroberts commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

This PR builds on the work in openpubkey/openpubkey#364 - I've temporarily replace-d the openpubkey dep with the branch from that PR in order to make it build.

Add the option to configure a cache directory and max age settings in the server YAML config file, and feed these through to create a FilesystemDiscoveryCache used by the providers to cache JWKS entries. This avoids the providers having to fetch the JWKS from the .well-known discovery URL for every single SSH login.

Note this creates a bit of a race condition because

  • we can't parse the server config until the NewVerifyCmd has been created
  • NewVerifyCmd expects the verifier as a parameter
  • we can't create the verifier until we have parsed the server config file

So I've had to change the flow in main.go to create the VerifyCmd without a verifier, then parse the server config, then use the config to create a verifier, then assign that verifier to the right field of the VerifyCmd.

Testing

I've added a unit test for the FilesystemDiscoveryCache itself but I'm not sure how to wire in proper end to end testing.

Fixes #440

@ianroberts
ianroberts force-pushed the jwks-cache branch 2 times, most recently from 21e9f3a to d2436a9 Compare September 6, 2026 14:41
Add the option to configure a cache directory and max age settings in the server YAML config file, and feed these through to create a FilesystemDiscoveryCache used by the providers to cache JWKS entries.  This avoids the providers having to fetch the JWKS from the provider for every single SSH login.

Note this creates a bit of a race condition because

- we can't parse the server config until the NewVerifyCmd has been created
- NewVerifyCmd expects the verifier as a parameter
- we can't create the verifier until we have parsed the server config file

So I've had to change the flow in main.go to create the VerifyCmd without a verifier, then parse the server config, then use the config to create a verifier, then assign that verifier to the right field of the VerifyCmd.

Signed-off-by: Ian Roberts <ian@roberts.gb.net>
Until the relevant openpubkey changes are merged, this branch will only build against my fork.

Signed-off-by: Ian Roberts <ian@roberts.gb.net>
Signed-off-by: Ian Roberts <ian@roberts.gb.net>
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.

Support for caching JWKS

1 participant