Loading JWKS should not use URLConnection cache

Issue #195 closed
hamlaoui khaled created an issue

Hello,
inside the Get class and within the get method the URLConnection should not use cache.
it could be disabled by setUseCaches to false.

This could be critical if the IDP do key rotation and our URLConnection instance continue to use its cache.

Please let me know if I'm wrong in my analysis.

Regards

Comments (20)

  1. Brian Campbell

    The analysis seems generally correct. With HttpsJwks and HttpsJwksVerificationKeyResolver, the library does do some caching and forcing updates based on perceived key rotation. But that’s wouldn’t work if the underlying HttpsURLConnection is caching locally.

    Have you experienced an issue with this? Or is it a speculative concern?

    I wasn’t aware of the setUseCaches on Https/URLConnection. Does it actually use a local cache? I’ve never observed it doing so. And I’m not aware of anyone experiencing this issue.

    But adding aurlConnection.setUseCaches(false) to Get.get(...) seems reasonable.

  2. hamlaoui khaled reporter

    Thanks for you quick answer!

    No, did not get an issue with your lib, but in another contexte, yes !

    For me regarding the existing code, we don’t have the control on the caching over different system layers.
    In plus to setUseCaches to false we could also add setRequestProperty("Cache-Control", "no-cache").
    If you accepte PR, i could contribute.

  3. hamlaoui khaled reporter

    I forked the project and did the change, however i could not create PR, could you please give me the correct permission ?

  4. Brian Campbell repo owner

    No special permission should be needed. I don’t know why you can’t create a PR. But https://bitbucket.org/khamlaoui/jose4j/commits/4c73787c94e8f77f9ed1dec61eb6df20f7cd29fc has more changes in it than I’d accept, regardless.

    You can have HttpsJwks use your own SimpleGet implementation via https://javadoc.io/doc/org.bitbucket.b_c/jose4j/latest/org/jose4j/jwk/HttpsJwks.html#setSimpleHttpGet(org.jose4j.http.SimpleGet) if you really need/want all that.

  5. hamlaoui khaled reporter

    I could remove the disableServerSideCache option to keep it more simple.
    We could keep only the preventHttpCaching method.
    You could see my last commit (the http headers are really need to disable the servers/ proxies cache)

  6. Brian Campbell

    urlConnection.setUseCaches(false) is fine.

    I would be okay with setRequestProperty("Cache-Control", "no-cache")

    not more

  7. hamlaoui khaled reporter

    Thanks Brian for your support.
    Do you have an estimated date of the new version release ?

  8. hamlaoui khaled reporter

    I need this new changes for my projets, please let me know when you publish a new version!
    Thanks

  9. hamlaoui khaled reporter

    Hello Brian,
    Any idea about the next release date please ? i need the new version with recent changes please.

    Thanks

  10. Log in to comment