Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

feat: allow for Authorization header override with raw parameter #2432

Merged
merged 1 commit into from
May 25, 2023

Conversation

kristian1108
Copy link
Contributor

This PR creates a Raw Authorization type which allows the user to set the full Authorization header in a websocket request if the server they are connecting to does not conform to Bearer or Basic auth.

Motivation

Solution

PR Checklist

  • [trivial change ] Added Tests
  • [x ] Added Documentation
  • [ no] Breaking changes

@kristian1108 kristian1108 changed the title allow for Authorization header override with raw parameter feat: allow for Authorization header override with raw parameter May 25, 2023
Copy link
Collaborator

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

this is reasonable imo

@kristian1108
Copy link
Contributor Author

I'm not sure what these test failures are ... is it possible they're flaky? Or maybe I missed something...

Copy link
Collaborator

@DaniPopes DaniPopes left a comment

Choose a reason for hiding this comment

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

Thanks! Don't worry about the CI

@DaniPopes DaniPopes merged commit 007c58b into gakonst:master May 25, 2023
@weezy20
Copy link

weezy20 commented Aug 21, 2023

I have an issue where I cannot get this enum variant to work as intended. My WSS endpoint expects a custom header and an api key, and if I provide it using Authroization::raw, I just get a HTTP 403. The reason this is strange is because on an equivalent js app using web3-providers-ws, we are able to instantiate the ws connection correctly using our custom headers :

const customWsProvider = new WebSocketProvider(WS_URL, {
  headers: {
    'KEY' : val
  },
})

in my experience the equivalent ethers-rs code is not totally equivalent:

let api_key = // .. ;
let auth = Authorization::raw(format!("KEY {api_key}"));
let provider = Provider::<Ws>::connect_with_auth(url, auth).await?

Any help would be appreciated.

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.

4 participants