Struct http_auth::PasswordClientBuilder[][src]

pub struct PasswordClientBuilder(_);
Expand description

Builds a PasswordClient from the supplied challenges; create via PasswordClient::builder.

Often you can just use PasswordClient’s TryFrom implementations to convert from a parsed challenge (crate::ChallengeRef) or unparsed challenges (str, http::header::HeaderValue, or http::header::GetAll).

The builder allows more flexibility. For example, if you are using a HTTP library which is not based on a http crate, you might need to create a PasswordClient from an iterator over multiple WWW-Authenticate headers. You can feed each to PasswordClientBuilder::challenges.

Prefers Digest over Basic, consistent with the RFC 7235 section 2.1 advice for a user-agent to pick the most secure auth-scheme it understands.

When there are multiple Digest challenges, currently uses the first, consistent with the RFC 7616 section 3.7 advice to “use the first challenge it supports, unless a local policy dictates otherwise”. In the future, it may prioritize by algorithm.

Ignores parse errors as long as there’s at least one parseable, supported challenge.

Example

use http_auth::PasswordClient;
let client = PasswordClient::builder()
    .challenges("UnsupportedSchemeA, Basic realm=\"foo\", UnsupportedSchemeB")
    .challenges("Digest \
                 realm=\"http-auth@example.org\", \
                 qop=\"auth, auth-int\", \
                 algorithm=MD5, \
                 nonce=\"7ypf/xlj9XXwfDPEoM4URrv/xwf94BcCAzFZH4GiTo0v\", \
                 opaque=\"FQhe/qaU925kfnzjCev0ciny7QMkPqMAFRtzCUYo5tdS\"")
    .build()
    .unwrap();
assert!(matches!(client, PasswordClient::Digest(_)));

Implementations

This is supported on crate feature http only.

Considers all challenges from the given http::HeaderValue challenge list.

Considers all challenges from the given &str challenge list.

Considers a single challenge.

Returns a new PasswordClient or fails.

Trait Implementations

Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

Should always be Self

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.