pub struct Config<Spawner = DefaultSpawner> { /* 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<Spawner> Config<Spawner>
impl<Spawner> Config<Spawner>
sourcepub fn set_host_header(self) -> Self
pub fn set_host_header(self) -> Self
Since manually setting the Host header doesn’t work so well in AWC, you can use this method to enable setting the Host header for signing requests without breaking client functionality
sourcepub fn spawner<S>(self, spawner: S) -> Config<S>where
S: Spawn,
pub fn spawner<S>(self, spawner: S) -> Config<S>where
S: Spawn,
Set the spawner for spawning blocking tasks
http-signature-normalization-actix offloads signing messages and generating hashes to a blocking threadpool, which can be configured by providing a custom spawner.
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 enabling this, the Date header becomes required on requests. This is to prevent replay attacks
sourcepub fn set_expiration(self, expires_after: Duration) -> Self
pub 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
Require a header on signed and verified requests
sourcepub fn begin_sign(
&self,
method: &Method,
path_and_query: Option<&PathAndQuery>,
headers: HeaderMap
) -> Result<Unsigned, PrepareSignError>
pub fn begin_sign( &self, method: &Method, path_and_query: Option<&PathAndQuery>, headers: HeaderMap ) -> Result<Unsigned, PrepareSignError>
Begin the process of singing a request
sourcepub fn begin_verify(
&self,
method: &Method,
path_and_query: Option<&PathAndQuery>,
headers: HeaderMap
) -> Result<Unverified, PrepareVerifyError>
pub fn begin_verify( &self, method: &Method, path_and_query: Option<&PathAndQuery>, headers: HeaderMap ) -> Result<Unverified, PrepareVerifyError>
Begin the proess of verifying a request