Skip to main content

KeyVerifier

Trait KeyVerifier 

Source
pub trait KeyVerifier: Send + Sync {
    // Required methods
    fn extract(
        &self,
        x_api_key: Option<&str>,
        authorization: Option<&str>,
    ) -> Option<String>;
    fn verify(&self, provided: Option<&str>, expected: &str) -> bool;
}
Expand description

Extracts and verifies the caller’s API key.

Required Methods§

Source

fn extract( &self, x_api_key: Option<&str>, authorization: Option<&str>, ) -> Option<String>

Pull the presented key out of the X-Api-Key / Authorization header values.

Source

fn verify(&self, provided: Option<&str>, expected: &str) -> bool

Constant-time comparison that fails closed: false when expected is blank or provided is missing/empty.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§