pub struct TokenAuthenticator { /* private fields */ }Expand description
A static bearer-token → Principal map: the first-cut authenticator.
A fine dev/test authenticator; real OIDC/JWT is JwtAuthenticator, and both
slot behind the same Authenticator trait. An empty map denies every
request — zero trust out of the box.
Tokens are indexed by their SHA-256 digest, never stored or compared in clear: the lookup keys on the digest, so a timing side-channel over the map leaks only digest bytes (which are pre-image-resistant — useless for forging a token), and no bearer secret ever sits in process memory.
Implementations§
Source§impl TokenAuthenticator
impl TokenAuthenticator
Sourcepub fn new() -> TokenAuthenticator
pub fn new() -> TokenAuthenticator
A new, empty authenticator. On its own it rejects everything.
Sourcepub fn with_token(
self,
token: impl Into<String>,
principal: Principal,
) -> TokenAuthenticator
pub fn with_token( self, token: impl Into<String>, principal: Principal, ) -> TokenAuthenticator
Register one token → principal, builder-style. The token is stored as
its SHA-256 digest, not in clear.
Trait Implementations§
Source§impl Authenticator for TokenAuthenticator
impl Authenticator for TokenAuthenticator
Source§impl Clone for TokenAuthenticator
impl Clone for TokenAuthenticator
Source§fn clone(&self) -> TokenAuthenticator
fn clone(&self) -> TokenAuthenticator
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Default for TokenAuthenticator
impl Default for TokenAuthenticator
Source§fn default() -> TokenAuthenticator
fn default() -> TokenAuthenticator
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Forget for TokenAuthenticator
impl Freeze for TokenAuthenticator
impl Move for TokenAuthenticator
impl RefUnwindSafe for TokenAuthenticator
impl Send for TokenAuthenticator
impl Sync for TokenAuthenticator
impl Unpin for TokenAuthenticator
impl UnsafeUnpin for TokenAuthenticator
impl UnwindSafe for TokenAuthenticator
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more