Struct http_auth::digest::DigestClient[][src]

pub struct DigestClient { /* fields omitted */ }
This is supported on crate feature digest-scheme only.
Expand description

Client for a Digest challenge, as in RFC 7616.

Most of the information here is taken from the WWW-Authenticate or Proxy-Authenticate header. This also internally maintains a nonce counter.

Implementation notes

  • Recalculates H(A1) on each DigestClient::respond call. It’d be more CPU-efficient to calculate H(A1) only once by supplying the username and password at construction time or by caching (username, password) -> H(A1) mappings internally. DigestClient prioritizes simplicity instead.
  • There’s no support yet for parsing the Authentication-Info and Proxy-Authentication-Info header fields described by RFC 7616 section 3.5. PRs welcome!
  • Always responds using UTF-8, and thus doesn’t use or keep around the charset parameter. The RFC only allows that parameter to be set to UTF-8 anyway.
  • Supports RFC 2069 compatibility as in RFC 2617 section 3.2.2.1, even though RFC 7616 drops it. There are still RTSP cameras being sold in 2021 that use the RFC 2069-style calculations.
  • Supports RFC 7616 userhash, even though it seems impractical and only marginally useful. The server must index the userhash for each supported algorithm or calculate it on-the-fly for all users in the database.
  • The -sess algorithm variants haven’t been tested; there’s no example in the RFCs.

Security considerations

We strongly advise servers against implementing Digest:

  • It’s actively harmful in that it prevents the server from securing their password storage via salted password hashes. See RFC 7616 Section 5.2. When your server offers Digest authentication, it is advertising that it stores plaintext passwords!
  • It’s no replacement for TLS in terms of protecting confidentiality of the password, much less confidentiality of any other information.

For clients, when a server supports both Digest and Basic, we advise using Digest. It provides (slightly) more confidentiality of passwords over the wire.

Some servers only support Digest. E.g., ONVIF mandates the Digest scheme. It doesn’t prohibit implementing other schemes, but some cameras meet the specification’s requirement and do no more.

Implementations

Returns a string to be displayed to users so they know which username and password to use.

This string should contain at least the name of the host performing the authentication and might additionally indicate the collection of users who might have access. An example is registered_users@example.com. (See Section 2.2 of RFC 7235 for more details.)

Returns the domain, a space-separated list of URIs, as specified in RFC 3986, that define the protection space.

If the domain parameter is absent, returns an empty string, which is semantically identical according to the RFC.

Returns the nonce, a server-specified string which should be uniquely generated each time a 401 response is made.

Returns string of data, specified by the server, that SHOULD be returned by the client unchanged in the Authorization header field of subsequent requests with URIs in the same protection space.

Currently an empty opaque is treated as an absent one.

Returns a flag indicating that the previous request from the client was rejected because the nonce value was stale.

Returns true if using RFC 2069 compatibility mode as in RFC 2617 section 3.2.2.1.

If so, request-digest is calculated without the nonce count, conce, or qop.

Returns the algorithm used to produce the digest and an unkeyed digest.

Returns if the session style A1 will be used.

Returns the acceptable qop (quality of protection) values.

Returns the number of times the server-supplied nonce has been used by DigestClient::respond.

Responds to the challenge with the supplied parameters.

The caller should use the returned string as an Authorization or Proxy-Authorization header value.

Responds using a fixed cnonce for testing only.

In production code, use DigestClient::respond instead, which generates a new random cnonce value.

Trait Implementations

Formats the value using the given formatter. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

The type returned in the event of a conversion error.

Performs the conversion.

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.