mstange / symsrv

Download pdbs from symbol servers and cache locally, parse symbol paths from env vars
Apache License 2.0
20 stars 2 forks source link

Support basic authentication URL schema #9

Open DrChat opened 1 year ago

DrChat commented 1 year ago

URL basic authentication is used by us to pass in PAT credentials for Azure DevOps, so it'd be nice to see it implemented here so we can look at using this crate :)

Notably, symchk does not support this, so this feature is super useful.

Reference: https://github.com/microsoft/pdblister/blob/88c9f0dd4075be7adfbfdac0505dba2d63be068d/crates/symsrv/src/nonblocking.rs#L235-L253 Note that I'm pretty sure I implemented this incorrectly - the token should be base64("<user>:<password>") instead of what I had there.

mstange commented 1 year ago

I think you can even just use reqwest::Client::builder().basic_auth("", Some(token)) and have reqwest do the base64-ification for you.

Edit Feb 17, 2024: Er, basic_auth is a method on the RequestBuilder, not on the ClientBuilder, and it accepts user+password, not a token. RequestBuilder::bearer_auth is the one that accepts a token.

DrChat commented 1 year ago

Ah - unfortunately only a thing for building requests, not a client. That may be a better design choice on their end though.

mstange commented 1 year ago

Oh right. Yes I agree, you'd want it per request, because your symbol path may contain multiple URLs.

DrChat commented 8 months ago

So, looking at this a bit more: Some symbol servers use bearer token authentication, and basic authentication won't cover these scenarios.

Expanding the symsrv string format to cover this could be a solution, but:

1) There is currently no URL schema for encoding a bearer token into a URL (such as described here). 2) Bearer tokens usually have a short expiration time, so this will only work for a short-term use of SymbolCache.

Other potential solutions to think about: