tomusdrw / rust-web3

Ethereum JSON-RPC multi-transport client. Rust implementation of web3 library. ENS address: rust-web3.eth
MIT License
1.45k stars 471 forks source link

websocket infura secret support #567

Closed Mirko-von-Leipzig closed 2 years ago

Mirko-von-Leipzig commented 2 years ago

I'm not too clued up on websockets and authentication. Is it currently possible to utilise websockets along with password / username?

Creating a websocket currently takes in just url: &str which doesn't allow setting a username and password.

tomusdrw commented 2 years ago

Would wss://username:password@host/ work? If not we can easily add authorisation header support (AFAICT Infura is using basic auth).

Mirko-von-Leipzig commented 2 years ago

wss://username:password@host/ gets rejected -- unless I'm doing it wrong: wss://:<secret>@host (since there is no username)? This form gets rejected.

The example given in the docs is: wscat -c wss://mainnet.infura.io/ws/v3/YOUR-PROJECT-ID --auth ":YOUR-PROJECT-SECRET"