pub struct DpopRetry {
pub header: Header,
pub claims: Claims,
pub key_data: KeyData,
pub check_response_body: bool,
}
Expand description
Retry middleware for handling DPoP nonce challenges in HTTP requests.
This struct implements the Chainer
trait to automatically retry requests
when the server responds with a “use_dpop_nonce” error, adding the required
nonce to the DPoP proof before retrying.
Fields§
§header: Header
The JWT header for the DPoP proof.
claims: Claims
The JWT claims for the DPoP proof.
key_data: KeyData
The cryptographic key data used to sign the DPoP proof.
check_response_body: bool
Whether to check the response body for DPoP errors in addition to headers.
Implementations§
Source§impl DpopRetry
impl DpopRetry
Sourcepub fn new(
header: Header,
claims: Claims,
key_data: KeyData,
check_response_body: bool,
) -> Self
pub fn new( header: Header, claims: Claims, key_data: KeyData, check_response_body: bool, ) -> Self
Creates a new DpopRetry instance with the provided header, claims, and key data.
§Arguments
header
- The JWT header for the DPoP proofclaims
- The JWT claims for the DPoP proofkey_data
- The cryptographic key data for signing
Trait Implementations§
Source§impl Chainer for DpopRetry
Implementation of the Chainer
trait for handling DPoP nonce challenges.
impl Chainer for DpopRetry
Implementation of the Chainer
trait for handling DPoP nonce challenges.
This middleware intercepts HTTP responses with 400/401 status codes and “use_dpop_nonce” errors, extracts the DPoP-Nonce header, and retries the request with an updated DPoP proof containing the nonce.
This does not evaluate the response body to determine if a DPoP error was returned. Only the returned “WWW-Authenticate” header is evaluated. This is the expected and defined behavior per RFC7235 sections 3.1 and 4.1.
Source§fn chain<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
result: Result<Response, Error>,
_state: &'life1 mut Self::State,
request: &'life2 mut Request,
) -> Pin<Box<dyn Future<Output = Result<Option<Response>, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn chain<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
result: Result<Response, Error>,
_state: &'life1 mut Self::State,
request: &'life2 mut Request,
) -> Pin<Box<dyn Future<Output = Result<Option<Response>, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Handles the retry logic for DPoP nonce challenges.
§Arguments
result
- The result of the HTTP request_state
- Unused state (unit type)request
- The mutable request to potentially retry
§Returns
Ok(Some(response))
- Original response if no retry neededOk(None)
- Retry the request with updated DPoP proofErr(error)
- Error if retry logic fails