pub fn is_dpop_error(value: &str) -> boolExpand description
Parses the value of the “WWW-Authenticate” header and returns true if the inner “error” field is either “invalid_dpop_proof” or “use_dpop_nonce”.
This function parses DPoP challenge headers to determine if the server is requesting a DPoP proof or indicating that the provided proof is invalid.
§Arguments
value- The WWW-Authenticate header value to parse
§Returns
trueif the error field indicates a DPoP-related errorfalseif no DPoP error is found or the header format is invalid
§Examples
use atproto_oauth::dpop::is_dpop_error;
// Valid DPoP error: invalid_dpop_proof
let header1 = r#"DPoP algs="ES256", error="invalid_dpop_proof", error_description="DPoP proof required""#;
assert!(is_dpop_error(header1));
// Valid DPoP error: use_dpop_nonce
let header2 = r#"DPoP algs="ES256", error="use_dpop_nonce", error_description="Authorization server requires nonce in DPoP proof""#;
assert!(is_dpop_error(header2));
// Non-DPoP error
let header3 = r#"DPoP algs="ES256", error="invalid_token", error_description="Token is invalid""#;
assert!(!is_dpop_error(header3));
// Non-DPoP authentication scheme
let header4 = r#"Bearer error="invalid_token""#;
assert!(!is_dpop_error(header4));