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

Feature Request: include credentials #3096

Closed
wants to merge 3 commits into from

Conversation

xinbenlv
Copy link

No description provided.

@ricmoo
Copy link
Member

ricmoo commented Jun 19, 2022

This is a potential security concern, since including the credentials can leak them to unauthorized third parties.

The current settings were all selected as they are they default for fetch.

@xinbenlv
Copy link
Author

Wow, that was a fast response, thank you @ricmoo . I further discuss this idea in the #3097

Yes, it's only a proof of concept. and I agree with you there are security concerns. We would like to check with you if you are open to allow this to be configurable at least. Given that even basic authentication is allowed allowInsecureAuthentication

@ricmoo
Copy link
Member

ricmoo commented Jun 19, 2022

It could be made a configurable option, but this would be a non-backwards compatible change and would be a bit more work than is likely to be prioritized in the near future for v5.

This change, while simple in the browser case, requires some additional code for the node case, where it would need to be implemented. I want to make sure the fetch api works identically in both node and browser, so an option like this needs to be added as the node http library isn’t a matter of a simple property.

In v6, the entire fetch library will be able to be swapped out in the same way the crypto library can, so there will be fewer options directly within the library, with the expectation that adding the new abilities is easier to do by replacing the fetch.

@xinbenlv
Copy link
Author

Can I describe my understanding of what you said in my own words, please check if it's correct:

  1. Due to this is non-backwards compatibile change, if we add this feature, it will have to fall into the V5 of ethers.js. But we aren't likely to prioritize this particular feature in V5.

  2. Because of the different behaviors between fetch API vs node-http API, if we want to introduce the includeCredentials, we need to also implement the node-http side to ensure the same option is honored in the same way for both browser and server-side.

  3. Looking ahead, V6 intends to be http API agnostic, i.e. be agnostic of whether it's using fetch, node-http or something else (e.g. axios). In that case, users will call the http library of their choice directly, hence the option to define whether to include credentials will not be defined by ethers.js v6 but rather the http library of users' choice.

This it a good understanding?

@xinbenlv
Copy link
Author

  1. Because of the different behaviors between fetch API vs node-http API, if we want to introduce the includeCredentials, we need to also implement the node-http side to ensure the same option is honored in the same way for both browser and server-side.

QQ: if my understanding of this sentence is correct, does it currently honor skipFetchSetup in the server-side?
Since the credentials being included is more of a browser-only concept, how we call it includeCredentialsInFetch to make it more obvious a browser-only option?

@xinbenlv
Copy link
Author

friendly ping to continue discussion~

@ricmoo
Copy link
Member

ricmoo commented Jun 29, 2022

The v6 branch won't need this, since you can just swap out the fetch operation and make any adjustments manually. If it is added to v5, it needs to occur in a minor version change. I am planning one though.

What I may opt for is a fetchOptions which would only affect browsers, then you could specify fetchOptions: { credentials: "include" }. And like skipFetchSetup, would only added browsers (i.e. fetch); which is a no-op in node.

I'll mark this for a minor bump to look more into it as I prepare that.

@ricmoo ricmoo added the minor-bump Planned for the next minor version bump. label Jun 29, 2022
@xinbenlv
Copy link
Author

That would work, thank you @ricmoo !

@ricmoo ricmoo added the on-deck This Enhancement or Bug is currently being worked on. label Jul 14, 2022
ricmoo added a commit that referenced this pull request Jul 14, 2022
@ricmoo ricmoo added the fixed/complete This Bug is fixed or Enhancement is complete and published. label Jul 14, 2022
@xinbenlv
Copy link
Author

With c309df8 merged this is PR is considered done

@xinbenlv xinbenlv closed this Aug 16, 2022
@ricmoo ricmoo added enhancement New feature or improvement. and removed on-deck This Enhancement or Bug is currently being worked on. labels Aug 19, 2022
@ricmoo
Copy link
Member

ricmoo commented Aug 19, 2022

The fetchOptions has been included in v5.7.0. Try it out and let me know if there are any problems. :)

Thanks! :)

@xinbenlv
Copy link
Author

That is great news!

Woodpile37 pushed a commit to Woodpile37/ethers.js that referenced this pull request Jan 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or improvement. fixed/complete This Bug is fixed or Enhancement is complete and published. minor-bump Planned for the next minor version bump.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants