Setting of custom HTTP header while invoking JWK URL
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)
-
-
It will definitely help. Thank you very much Vladimir. Let me try above one.
-
- changed status to wontfix
Closing, work around available.
-
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 calledsetHeader(Map<String, String>)
?I think that it is not a big change. I can do it if you are ok with the change.
-
- changed status to open
Yes, please, that would it helpful it looks.
-
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?
-
That’s great, thanks!
Can you generate a patch from your IDE and post / attach it here?
-
Just now I got an email from support. Looks like they fix my account. I’m going to create a proper PR.
-
Thanks, I just registered the PR!
-
- changed status to resolved
Just pushed your patch as v8.20 to Maven Central.
Thanks for contributing!
- Log in to comment
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?