pub trait AuthProvider: Send + Sync {
// Required method
fn add_auth_headers(&self, headers: &mut HeaderMap);
// Provided methods
fn to_auth_headers(&self) -> HeaderMap { ... }
fn apply_auth(&self, request: Request) -> AuthProviderFuture<'_> { ... }
}Expand description
Applies authentication to API requests.
Header-only providers can implement add_auth_headers; providers that sign
complete requests can override apply_auth.
Required Methods§
Sourcefn add_auth_headers(&self, headers: &mut HeaderMap)
fn add_auth_headers(&self, headers: &mut HeaderMap)
Adds any auth headers that are available without request body access.
Implementations should be cheap and non-blocking. This method is also used by telemetry and non-HTTP request paths.
Provided Methods§
Sourcefn to_auth_headers(&self) -> HeaderMap
fn to_auth_headers(&self) -> HeaderMap
Returns any auth headers that are available without request body access.
Sourcefn apply_auth(&self, request: Request) -> AuthProviderFuture<'_>
fn apply_auth(&self, request: Request) -> AuthProviderFuture<'_>
Applies auth to a complete outbound request and returns the request to send.
The input request is moved into this method. Implementations may mutate
the owned request, or replace it entirely, before returning.
Header-only auth providers can rely on the default implementation. Request-signing providers can override this to inspect the final URL, headers, and body bytes before the transport sends the request.
Callers must always use the returned request as authoritative.
If this returns AuthError, the request should not be sent.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".