pub struct MAuthInfo { /* private fields */ }
Expand description
This is the primary struct of this class. It contains all of the information required to sign requests using the MAuth protocol and verify the responses.
Note that it contains a cache of response keys for verifying response signatures. This cache makes the struct non-Sync.
Implementations§
Source§impl MAuthInfo
impl MAuthInfo
Sourcepub fn from_default_file() -> Result<MAuthInfo, ConfigReadError>
pub fn from_default_file() -> Result<MAuthInfo, ConfigReadError>
Construct the MAuthInfo struct based on the contents of the config file .mauth_config.yml
present in the current user’s home directory. Returns an enum error type that includes the
error types of all crates used.
Sourcepub fn from_config_section(
section: &ConfigFileSection,
) -> Result<MAuthInfo, ConfigReadError>
pub fn from_config_section( section: &ConfigFileSection, ) -> Result<MAuthInfo, ConfigReadError>
Construct the MAuthInfo struct based on a passed-in ConfigFileSection instance. The optional input_keystore is present to support internal cloning and need not be provided if being used outside of the crate.
Source§impl MAuthInfo
impl MAuthInfo
Sourcepub fn sign_request(&self, req: &mut Request) -> Result<(), SigningError>
pub fn sign_request(&self, req: &mut Request) -> Result<(), SigningError>
This method determines how to sign the request automatically while respecting the
v2_only_sign_requests
flag in the config file. It always signs with the V2 algorithm and
signature, and will also sign with the V1 algorithm, if the configuration permits.
Note that, as the request signature includes a timestamp, the request must be sent out shortly after the signature takes place.
Note that it will need to read the entire body in order to sign it, so it will not work properly if any of the streaming body types are used.
Sourcepub fn sign_request_v2(&self, req: &mut Request) -> Result<(), SigningError>
pub fn sign_request_v2(&self, req: &mut Request) -> Result<(), SigningError>
Sign a provided request using the MAuth V2 protocol. The signature consists of 2 headers
containing both a timestamp and a signature string, and will be added to the headers of the
request. It is required to pass a body_digest
computed by the
build_body_with_digest
method, even if the request is
an empty-body GET.
Note that, as the request signature includes a timestamp, the request must be sent out shortly after the signature takes place.
Also note that it will need to read the entire body in order to sign it, so it will not work properly if any of the streaming body types are used.
Sourcepub fn sign_request_v1(&self, req: &mut Request) -> Result<(), SigningError>
pub fn sign_request_v1(&self, req: &mut Request) -> Result<(), SigningError>
Sign a provided request using the MAuth V1 protocol. The signature consists of 2 headers
containing both a timestamp and a signature string, and will be added to the headers of the
request. It is required to pass a body
, even if the request is an empty-body GET.
Note that, as the request signature includes a timestamp, the request must be sent out shortly after the signature takes place.
Also note that it will need to read the entire body in order to sign it, so it will not work properly if any of the streaming body types are used.
Trait Implementations§
Source§impl Middleware for MAuthInfo
impl Middleware for MAuthInfo
Source§fn handle<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
req: Request,
extensions: &'life1 mut Extensions,
next: Next<'life2>,
) -> Pin<Box<dyn Future<Output = Result<Response>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn handle<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
req: Request,
extensions: &'life1 mut Extensions,
next: Next<'life2>,
) -> Pin<Box<dyn Future<Output = Result<Response>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
next.run(req, extensions)
. Read more