12 releases (stable)

3.1.0 Jun 20, 2024
2.0.0 Nov 24, 2023
1.2.1 Aug 17, 2023
1.2.0 May 11, 2023
0.1.2 Oct 14, 2021

#152 in Authentication

Download history 409/week @ 2024-08-18 489/week @ 2024-08-25 331/week @ 2024-09-01 440/week @ 2024-09-08 359/week @ 2024-09-15 577/week @ 2024-09-22 1419/week @ 2024-09-29 2226/week @ 2024-10-06 1394/week @ 2024-10-13 627/week @ 2024-10-20 364/week @ 2024-10-27 648/week @ 2024-11-03 837/week @ 2024-11-10 954/week @ 2024-11-17 908/week @ 2024-11-24 1129/week @ 2024-12-01

3,912 downloads per month
Used in 7 crates (6 directly)

MIT license

20KB
377 lines

diqwest

This crate extends reqwest to be able to send requests with digest auth flow.

When you send a request with digest auth flow this first request will be executed. In case the response is a 401 the www-authenticate header is parsed and the answer is calculated. The initial request is executed again with additional Authorization header. The response will be returned from send_with_digest_auth().

In case the first response is not a 401 this first response is returned from send_with_digest_auth() without any manipulation. In case the first response is a 401 but the www-authenticate header is missing the first reponse is returned as well.

diqwest is a lean crate and has nearly no dependencies:

  • reqwest, for sure, as diqwest is an extension to it. Without any enabled features and no default features.
  • digest_auth is used to calculate the answer. Without any enabled feature and no default features.
  • url is used to validate urls on type level. Without any enabled feature and no default features.

That's it. No other dependencies are used. Not even thiserror is used to not force it on you.

Examples

Async (default)

use diqwest::WithDigestAuth;
use reqwest::{Client, Response};

// Call `.send_with_digest_auth()` on `RequestBuilder` like `send()`
let response: Response = Client::new()
  .get("url")
  .send_with_digest_auth("username", "password")
  .await?;

Blocking (feature flag blocking has to be enabled in Cargo.toml)

use diqwest::blocking::WithDigestAuth;
use reqwest::blocking::{Client, Response};

// Call `.send_with_digest_auth()` on `RequestBuilder` like `send()`
let response: Response = Client::new()
  .get("url")
  .send_with_digest_auth("username", "password")?;

Dependencies

~5–16MB
~201K SLoC