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

Add optional headers for fetch_jwk #397

Merged
merged 5 commits into from Apr 26, 2022
Merged

Add optional headers for fetch_jwk #397

merged 5 commits into from Apr 26, 2022

Conversation

rolandzwaga
Copy link
Contributor

Similar to the agent option, this simply adds optional http headers to be sent with the fetch_wks http request.

@panva
Copy link
Owner

panva commented Apr 26, 2022

Why do you need this?

@rolandzwaga
Copy link
Contributor Author

Why do you need this?

In my current project I have the use-case where I need to send a custom header along with the request to the keystore otherwise it gets blocked.

Copy link
Owner

@panva panva left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Only push changes related to the feature. Reordering imports seems to have been done by the editor and makes reviewing difficult.
  • You also have to accommodate the browser runtime as well
  • Tests are needed

@rolandzwaga
Copy link
Contributor Author

rolandzwaga commented Apr 26, 2022

  • Only push changes related to the feature. Reordering imports seems to have been done by the editor and makes reviewing difficult.

You're absolutely right, I apologize and can fix that easily

  • You also have to accommodate the browser runtime as well

I followed the implementation of the agent option, which is also only implemented for the node runtime (AFAICS). I can still add it to the browser runtime though, but shall I add the agent option then as well while I'm at it?

  • Tests are needed

I followed the implementation of the agent option, and couldn't find any unit tests for this. I tried to grok the current unit test setup but didn't find it so easy to quickly grasp. Maybe I overlooked though, so if you can point me to the tests for the agent option, it will probably be easier for me to add tests for the headers.

@panva
Copy link
Owner

panva commented Apr 26, 2022

but shall I add the agent option then as well while I'm at it?

Is the node-specific http(s).agent option applicable to browser runtime using fetch? No.

Tests should be added in test/jwks/remote.test.mjs

@rolandzwaga
Copy link
Contributor Author

but shall I add the agent option then as well while I'm at it?

Is the node-specific http(s).agent option applicable to browser runtime using fetch? No.

This might be a poor text-to-real-language translation, but do I detect sarcasm here?

Tests should be added in test/jwks/remote.test.mjs

Yes, I had already found this file, but couldn't find a mention of the agent option here. As I said, I found the tests quite hard to grok, so having a test for the agent option there would probably make things easier for me to implement. I would really appreciate some guidance.

@panva
Copy link
Owner

panva commented Apr 26, 2022

but shall I add the agent option then as well while I'm at it?

Is the node-specific http(s).agent option applicable to browser runtime using fetch? No.

This might be a poor text-to-real-language translation, but do I detect sarcasm here?

A tiny bit, yeah. The agent option is defined and documented as

An instance of http.Agent or https.Agent to pass to the http.get or https.get method's options. Use when behind an http(s) proxy. This is a Node.js runtime specific option, it is ignored when used outside of Node.js runtime.

So it does not apply to the other runtime.

Tests should be added in test/jwks/remote.test.mjs

Yes, I had already found this file, but couldn't find a mention of the agent option here. As I said, I found the tests quite hard to grok, so having a test for the agent option there would probably make things easier for me to implement. I would really appreciate some guidance.

There are no agent specific tests. Don't worry about it then, just clean up the PR, add the option to the browser runtime and I'll add a simple test then.

@rolandzwaga
Copy link
Contributor Author

rolandzwaga commented Apr 26, 2022

but shall I add the agent option then as well while I'm at it?

Is the node-specific http(s).agent option applicable to browser runtime using fetch? No.

This might be a poor text-to-real-language translation, but do I detect sarcasm here?

A tiny bit, yeah. The agent option is defined and documented as

An instance of http.Agent or https.Agent to pass to the http.get or https.get method's options. Use when behind an http(s) proxy. This is a Node.js runtime specific option, it is ignored when used outside of Node.js runtime.

So it does not apply to the other runtime.

Ah, ok, now I see, this was a question of RTFM for me. So, the sarcasm was valid hehe, my apologies. ;)

Tests should be added in test/jwks/remote.test.mjs

Yes, I had already found this file, but couldn't find a mention of the agent option here. As I said, I found the tests quite hard to grok, so having a test for the agent option there would probably make things easier for me to implement. I would really appreciate some guidance.

There are no agent specific tests. Don't worry about it then, just clean up the PR, add the option to the browser runtime and I'll add a simple test then.

Ok, thank you ;)
I'll clean it up after my meeting. (and add the header option to the browser functionality as well)

Add optional headers to browser fetch as well
@rolandzwaga
Copy link
Contributor Author

Ok, I pushed my last changes. I hope everything is in order now.

@rolandzwaga rolandzwaga requested a review from panva April 26, 2022 09:32
@panva panva merged commit b4612f5 into panva:main Apr 26, 2022
@rolandzwaga rolandzwaga deleted the feat/add-request-headers-to-jwks-fetch branch April 26, 2022 10:12
@github-actions github-actions bot locked and limited conversation to collaborators Jul 27, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants