Skip to main content

TokenStore

Trait TokenStore 

Source
pub trait TokenStore:
    Send
    + Sync
    + 'static {
    // Required method
    fn resolve(&self, token: &CredentialsToken) -> Option<AuthenticatedPeer>;
}
Available on crate feature server only.
Expand description

Resolves an incoming credentials token to the platform that holds it.

The implementation decides where registrations live — a database, a config file, an in-memory map for a test. What it must do is compare tokens in constant time, which CredentialsToken’s PartialEq does; a naive String comparison leaks the token one byte at a time to anyone who can measure the response.

Required Methods§

Source

fn resolve(&self, token: &CredentialsToken) -> Option<AuthenticatedPeer>

Looks up the platform a token belongs to.

Returns None for a token this server does not know, which the caller turns into an HTTP 401 — “If the header is missing or the credentials token doesn’t match any known party then the server SHALL respond with an HTTP 401 - Unauthorized status code.”

Dyn Compatibility§

This trait is dyn compatible.

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

Implementations on Foreign Types§

Source§

impl<T: TokenStore> TokenStore for Arc<T>

Implementors§