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 moreAuto Trait Implementations§
impl Freeze for DigestAuthResponse
impl RefUnwindSafe for DigestAuthResponse
impl Send for DigestAuthResponse
impl Sync for DigestAuthResponse
impl Unpin for DigestAuthResponse
impl UnsafeUnpin for DigestAuthResponse
impl UnwindSafe for DigestAuthResponse
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more