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

feat: Allow solvers to specify custom headers with their requests #2372

Closed
fleupold opened this issue Feb 6, 2024 · 2 comments
Closed

feat: Allow solvers to specify custom headers with their requests #2372

fleupold opened this issue Feb 6, 2024 · 2 comments
Labels
E:3.1 Driver Colocation See https://github.com/cowprotocol/pm/issues/14 for details help wanted Extra attention is needed

Comments

@fleupold
Copy link
Contributor

fleupold commented Feb 6, 2024

Problem

Solvers may have custom authentication logic based on HTTP headers which they need to configure for their solvers.

Suggested solution

The code has already been prepared with a comment here:

impl Solver {
pub fn new(config: Config, eth: Ethereum) -> Self {
let mut headers = reqwest::header::HeaderMap::new();
headers.insert(
reqwest::header::CONTENT_TYPE,
"application/json".parse().unwrap(),
);
headers.insert(reqwest::header::ACCEPT, "application/json".parse().unwrap());
// TODO(#907) Also add an auth header
Self {
client: reqwest::ClientBuilder::new()
.default_headers(headers)
.build()
.unwrap(),
config,
eth,
}
}

We should make the exact header name also configurable in the toml config cf:

[[solver]]
name = "mysolver" # Arbitrary name given to this solver, must be unique
endpoint = "http://0.0.0.0:7872"
absolute-slippage = "40000000000000000" # Denominated in wei, optional
relative-slippage = "0.1" # Percentage in the [0, 1] range
account = "0x0000000000000000000000000000000000000000000000000000000000000001" # The private key of the solver

Maybe we can add an optional headers list with key value pairs to this config object and pass it all the way through to the infra component above.

Acceptance criteria

  • Driver binary can be configured with arbitrary header values per solver
  • Headers are sent as part of both quote as well as solve requests
@fleupold fleupold added help wanted Extra attention is needed E:3.1 Driver Colocation See https://github.com/cowprotocol/pm/issues/14 for details labels Feb 6, 2024
@jhweintraub
Copy link
Contributor

Do you want to be able to support any arbitrary header which is included in the Reqwest library or just Authorization? I've implemented the logic for the auth header but allowing anything arbitrary will be a lot of work and should probably be specified in a different feature request?

This is my first PR to this repo and i'm still learning rust so feedback is appreciated. PR #2395

@fleupold
Copy link
Contributor Author

This has been completed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E:3.1 Driver Colocation See https://github.com/cowprotocol/pm/issues/14 for details help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants