pub trait TokenStore:
Send
+ Sync
+ 'static {
// Required method
fn resolve(&self, token: &CredentialsToken) -> Option<AuthenticatedPeer>;
}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§
Sourcefn resolve(&self, token: &CredentialsToken) -> Option<AuthenticatedPeer>
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".