ethereum / remix-project

Remix is a browser-based compiler and IDE that enables users to build Ethereum contracts with Solidity language and to debug transactions.
https://remix-ide.readthedocs.io
MIT License
2.4k stars 911 forks source link

Support for Nodes with Basic Auth #137

Open dbryan0516 opened 5 years ago

dbryan0516 commented 5 years ago

I'm trying to connect Remix to a live Kaleido node. Kaleido nodes use Basic Authentication for communication to the Ethereum based nodes.

When selecting Web3 Provider as the Environment that I want to work with and inputting my RPC url as https://<username>:<password>@xxxxxxxx-xxxxxxxx-rpc.us-east-2.kaleido.io

I get the response: "Not possible to connect to the Web3 provider. Make sure the provider is running and a connection is open (via IPC or RPC)."

yann300 commented 5 years ago

what kind of error do you get in the javascript console?

dbryan0516 commented 5 years ago

I get a 401 Unauthorized error on the url with the credentials stripped out. So it seems like remix strips out the Basic Auth creds before making the request but it doesnt add them as a request header.

capture

capture2

dbryan0516 commented 5 years ago

I may get around to implementing this by the end of November but if someone else has time, that'd be great

dbryan0516 commented 5 years ago

Browser web3 version doesn't seem to match the package.json version? Browser = 0.20.6 package.json = 1.0.0-beta.27

But also, if I inject web3.setProvider(new web3.providers.HttpProvider("https://xxxxxxxx-xxxxxxxx-rpc.us-east-2.kaleido.io",0, "<username>", "<password>"))

It will connect to the node. It seems the web3.setProvider(endpoint) does not properly pass the basic auth in this version of web3

capture

yann300 commented 5 years ago

does 0.20.6 is supposed to work with basic auth? the remix terminal uses web3 1.0.0 but the rest of the app still uses web3 0.20.6 . Do you think switching to 1.0 will fix the issue? @dbryan0516

yann300 commented 5 years ago

try running a deployment script from the remix terminal, if that works, then we should quickly switch everything to web3 1.0

dbryan0516 commented 5 years ago

The terminal by default uses the Javascript VM or the injected provider. When trying to set the provider in the terminal using web3.setProvider(new web3.providers.HttpProvider(...)) it returns true but does not update the provider nor throws any errors in the JS console. So it just returns to the vm provider.

Basic Auth has been supported since at least this commit in web3.js

easeev commented 4 years ago

Any updates on this issue? Have the same problem using authenticated Ethereum node RPC on Chainstack.

yann300 commented 4 years ago

bumping an redirecting to @LianaHus @ryestew

easeev commented 4 years ago

Since HttpProvider is deprecated, perhaps it makes sense to switch to WebsocketProvider which works perfectly with basic auth?