Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use cache when JWKS provider is down #826

Open
zilinjak opened this issue Aug 28, 2024 · 4 comments
Open

Use cache when JWKS provider is down #826

zilinjak opened this issue Aug 28, 2024 · 4 comments

Comments

@zilinjak
Copy link

Hey,
We are building an app that validated requests, we are using JWKS over HTTP. The problem here is:

  1. App starts
  2. Download keys from JWKS over HTTP
  3. The cache of JWKS is out of date
  4. Tries to get JWKS over HTTP
  5. The JWKS endpoint is down
  6. This means that the smallrye-jwt should try to use old keys from cache, but it ends with an error instead.

Can we make sure that the old keys will be used in case that the keys from OIDC endpoint can't be loaded ?

@sberyozkin
Copy link
Contributor

sberyozkin commented Aug 28, 2024

Hi @zilinjak
Is it an exception thrown directly from the Jose4j code itself due to its internal refresh call failing ? Would it be better just to disable this refresh and instead rely on smallrye-jwt refreshing only when it can't find a matching key ?

@sberyozkin
Copy link
Contributor

Hi @zilinjak

So, we need to have a new property to do:

https://bitbucket.org/b_c/jose4j/src/756257eb92352600d5dde08c2b8ed25db13a8952/src/main/java/org/jose4j/jwk/HttpsJwks.java#lines-93

Would be interested to open a PR ?

@sberyozkin
Copy link
Contributor

We have jwksRefreshInterval here. So another property like jwksCacheRetainOnErrorDuration, default 0, I guess also in mins, should be added, and then propagated via JWTAuthContextInfo to be set here

@sberyozkin
Copy link
Contributor

sberyozkin commented Aug 28, 2024

Or even lets call it jwksRetainOnErrorDuration since jwksRefreshInterval does not have Cache in its name, it is implied, ut can be clarified in the property 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

No branches or pull requests

2 participants