pub struct Config { /* private fields */ }
Expand description
Configuration for signing and verifying signatures
By default, the config is set up to create and verify signatures that expire after 10
seconds, and use the (created)
and (expires)
fields that were introduced in draft 11
Implementations§
Source§impl Config
impl Config
Sourcepub fn mastodon_compat(self) -> Self
pub fn mastodon_compat(self) -> Self
Enable mastodon compatibility
This is the same as disabling the use of (created)
and (expires)
signature fields,
requiring the Date header, and requiring the Host header
Sourcepub fn require_digest(self) -> Self
pub fn require_digest(self) -> Self
Require the Digest header be set
This is useful for POST, PUT, and PATCH requests, but doesn’t make sense for GET or DELETE.
Sourcepub fn dont_use_created_field(self) -> Self
pub fn dont_use_created_field(self) -> Self
Opt out of using the (created) and (expires) fields introduced in draft 11
Note that by not requiring the created field, the Date header becomes required. This is to prevent replay attacks.
Sourcepub const fn set_expiration(self, expires_after: Duration) -> Self
pub const fn set_expiration(self, expires_after: Duration) -> Self
Set the expiration to a custom duration
Sourcepub fn require_header(self, header: &str) -> Self
pub fn require_header(self, header: &str) -> Self
Mark a header as required
Sourcepub fn begin_sign(
&self,
method: &str,
path_and_query: &str,
headers: BTreeMap<String, String>,
) -> Result<Unsigned, RequiredError>
pub fn begin_sign( &self, method: &str, path_and_query: &str, headers: BTreeMap<String, String>, ) -> Result<Unsigned, RequiredError>
Perform the neccessary operations to produce an Unsigned
type, which can be used to
sign the header
Sourcepub fn begin_verify(
&self,
method: &str,
path_and_query: &str,
headers: BTreeMap<String, String>,
) -> Result<Unverified, PrepareVerifyError>
pub fn begin_verify( &self, method: &str, path_and_query: &str, headers: BTreeMap<String, String>, ) -> Result<Unverified, PrepareVerifyError>
Perform the neccessary operations to produce and Unverified
type, which can be used to
verify the header