pub struct DigestAuthResponse {
pub username: String,
pub realm: String,
pub nonce: String,
pub uri: String,
pub qop: Option<String>,
pub nc: u32,
pub cnonce: String,
pub response: String,
pub algorithm: String,
pub opaque: Option<String>,
}Expand description
Built Digest authentication response ready for inclusion in an Authorization header
Contains all computed values needed to construct the Authorization header value.
Fields§
§username: StringUsername being authenticated
realm: StringRealm from the server’s challenge
nonce: StringNonce from the server’s challenge
uri: StringRequest URI (path portion)
qop: Option<String>Quality of protection (from challenge)
nc: u32Nonce count (hex, 8 digits)
cnonce: StringClient-generated nonce (hex string)
response: StringComputed response hash
algorithm: StringAlgorithm used (from challenge)
opaque: Option<String>Opaque value from challenge (must be returned unchanged)
Implementations§
Source§impl DigestAuthResponse
impl DigestAuthResponse
Sourcepub fn to_header_value(&self) -> String
pub fn to_header_value(&self) -> String
Build the complete Authorization header value string.
Returns the full header value in the format:
Digest username="...", realm="...", nonce="...", uri="...",
nc=XXXXXXXX, cnonce="...", qop="...", response="...",
algorithm="...", opaque="..."Sourcepub fn compute(
username: &str,
password: &str,
method: &str,
uri: &str,
challenge: &DigestAuthChallenge,
nc: u32,
) -> Self
pub fn compute( username: &str, password: &str, method: &str, uri: &str, challenge: &DigestAuthChallenge, nc: u32, ) -> Self
Compute a Digest authentication response per RFC 2617 section 3.2.2.1.
This method computes all necessary hashes and builds a complete response
that can be serialized via to_header_value.
§Algorithm (RFC 2617):
HA1 = MD5(username:realm:password)
HA2 = MD5(method:uri)
if qop is set:
response = MD5(HA1:nonce:nc:cnonce:qop:HA2)
else:
response = MD5(HA1:nonce:HA2)§Arguments
username- The username for authenticationpassword- The user’s password (plaintext)method- HTTP method (GET, POST, etc.)uri- The request URI pathchallenge- The parsed server challengenc- Nonce count (incremented per request with same nonce)
§Returns
A fully constructed DigestAuthResponse.
Trait Implementations§
Source§impl Clone for DigestAuthResponse
impl Clone for DigestAuthResponse
Source§fn clone(&self) -> DigestAuthResponse
fn clone(&self) -> DigestAuthResponse
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more