Setting of custom HTTP header while invoking JWK URL

Issue #240 resolved
Former user created an issue

Hi Team,

We are using RemoteJWKSet to invoke JWK endpoint in our application. The JWK endpoint requries a custome HTTP header while invoke endpoint. is there a way we can set custom HTTP header in RemoteJWKSet.

Comments (10)

  1. Vladimir Dzhuvinov

    Hi there,

    I suggest you override com.nimbusds.jose.util.DefaultResourceRetriever.

    In particular, the com.nimbusds.jose.util.DefaultResourceRetriever#retrieveResource method. You can simply copy the existing code, adding con.setRequestProperty ("Header-Name", "Header-Value"); where required.

    The actual headers can be set via the constructor, or via a setter.

    Does this help?

  2. Angel Cervera Claudio

    I have the same issue with CloudFlare. It requires the “User-Agent" header.

    I can override com.nimbusds.jose.util.DefaultResourceRetriever#retrieveResource but then I will need to copy&paste all your code (around 30 lines of code duplicated) to add only one line.

    Why don’t modify the interface com.nimbusds.jose.util.RestrictedResourceRetriever adding a new method called setHeader(Map<String, String>)?

    I think that it is not a big change. I can do it if you are ok with the change.

  3. Angel Cervera Claudio

    I finished with the implementation, but my Bitbucket account is not working. I created a ticket and looks like support is working on that. At the moment, I can not create Projects, so I can not fork the repository, so I can not create a PR.

    Any other way to create a PR?

  4. Vladimir Dzhuvinov

    That’s great, thanks!

    Can you generate a patch from your IDE and post / attach it here?

  5. Angel Cervera Claudio

    Just now I got an email from support. Looks like they fix my account. I’m going to create a proper PR.

  6. Log in to comment