pub struct MemoryAuthBackend { /* private fields */ }Expand description
An in-memory AuthBackend and SessionValidator. See the module
docs for its flows.
Implementations§
Source§impl MemoryAuthBackend
impl MemoryAuthBackend
Sourcepub fn new(login_url: impl Into<String>) -> Self
pub fn new(login_url: impl Into<String>) -> Self
A backend whose browser sign-in page is login_url (the service’s
own, e.g. http://127.0.0.1:4456/login). Offers a browser and a
key provider; Self::with_user adds password.
Sourcepub fn with_providers(self, providers: Vec<Provider>) -> Self
pub fn with_providers(self, providers: Vec<Provider>) -> Self
Replace the providers offered.
Sourcepub fn with_user(
self,
username: &str,
password: &str,
principal: &str,
name: Option<&str>,
) -> Self
pub fn with_user( self, username: &str, password: &str, principal: &str, name: Option<&str>, ) -> Self
A password user: username / password sign in as principal.
Sourcepub fn complete_browser(
&self,
state: &str,
principal: &str,
name: Option<&str>,
) -> Result<(String, String), AuthFailure>
pub fn complete_browser( &self, state: &str, principal: &str, name: Option<&str>, ) -> Result<(String, String), AuthFailure>
The service’s web sign-in, once the person behind state is through:
a one-time code for that state, and the loopback URL to send the
browser back to (<redirect>?code=…&state=…).
Sourcepub fn mint(
&self,
principal: &Principal,
name: Option<String>,
agent: Option<String>,
ttl_secs: Option<u64>,
layers: Vec<Vec<String>>,
) -> Session
pub fn mint( &self, principal: &Principal, name: Option<String>, agent: Option<String>, ttl_secs: Option<u64>, layers: Vec<Vec<String>>, ) -> Session
Mint a session (also what a service’s own web login would call).
Sourcepub fn context_of(&self, token: &str) -> Option<AuthContext>
pub fn context_of(&self, token: &str) -> Option<AuthContext>
The identity a token stands for, while it lasts.
Trait Implementations§
Source§impl AuthBackend for MemoryAuthBackend
impl AuthBackend for MemoryAuthBackend
Source§fn login<'life0, 'life1, 'async_trait>(
&'life0 self,
caller: Option<&'life1 AuthContext>,
flow: LoginFlow,
) -> Pin<Box<dyn Future<Output = Result<LoginAnswer, AuthFailure>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn login<'life0, 'life1, 'async_trait>(
&'life0 self,
caller: Option<&'life1 AuthContext>,
flow: LoginFlow,
) -> Pin<Box<dyn Future<Output = Result<LoginAnswer, AuthFailure>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Sign in by
flow (auth.login). caller is the connection’s
identity, if any: a LoginFlow::Session needs one (a key proof at
the upgrade, or a session) and must not widen it — the new
session’s ceiling lies within the caller’s (layer it). The browser
flow’s start and finish, the code’s single use and expiry, and the
session’s minting are the backend’s.Source§fn signup<'life0, 'life1, 'async_trait>(
&'life0 self,
caller: Option<&'life1 AuthContext>,
_via: Option<String>,
) -> Pin<Box<dyn Future<Output = Result<SignupAnswer, AuthFailure>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn signup<'life0, 'life1, 'async_trait>(
&'life0 self,
caller: Option<&'life1 AuthContext>,
_via: Option<String>,
) -> Pin<Box<dyn Future<Output = Result<SignupAnswer, AuthFailure>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
auth.signup where the activation’s own rule does not decide it:
an anonymous caller (create an account — or refuse: sign in first),
or one who already holds a membership. (A signed-in caller holding
none is put on the waiting list by AuthBackend::ask_access.)Source§fn ask_access<'life0, 'life1, 'async_trait>(
&'life0 self,
caller: &'life1 AuthContext,
via: Option<String>,
) -> Pin<Box<dyn Future<Output = Result<Waiting, AuthFailure>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn ask_access<'life0, 'life1, 'async_trait>(
&'life0 self,
caller: &'life1 AuthContext,
via: Option<String>,
) -> Pin<Box<dyn Future<Output = Result<Waiting, AuthFailure>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Put a signed-in caller who holds no membership on the waiting list
(asking again keeps the first
since).Source§fn waiting(&self) -> Vec<Waiting>
fn waiting(&self) -> Vec<Waiting>
Everyone who has asked for access. The activation shows an admin
only those still holding no membership.
Source§fn logout<'life0, 'life1, 'async_trait>(
&'life0 self,
caller: &'life1 AuthContext,
) -> Pin<Box<dyn Future<Output = Result<(), AuthFailure>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn logout<'life0, 'life1, 'async_trait>(
&'life0 self,
caller: &'life1 AuthContext,
) -> Pin<Box<dyn Future<Output = Result<(), AuthFailure>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
End the caller’s session (
auth.logout). A connection with no
session to end (a bare key proof) is not an error.Source§fn alive(&self, caller: &AuthContext) -> Result<(), String>
fn alive(&self, caller: &AuthContext) -> Result<(), String>
AUTH-11: whether a signed-in caller’s sign-in still stands — its
session not signed out, revoked or expired. The gate asks it before
every call it decides (
auth.* included), so a sign-in that ended
holds nothing from its next call on. Err: why not, in words for
the caller. Memory only: it is asked on every call. (The gate
refuses a caller past its expires_at stamp before asking.)Source§impl Debug for MemoryAuthBackend
impl Debug for MemoryAuthBackend
Source§impl SessionValidator for MemoryAuthBackend
impl SessionValidator for MemoryAuthBackend
Source§fn validate<'life0, 'life1, 'async_trait>(
&'life0 self,
credential: &'life1 str,
) -> Pin<Box<dyn Future<Output = Option<AuthContext>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn validate<'life0, 'life1, 'async_trait>(
&'life0 self,
credential: &'life1 str,
) -> Pin<Box<dyn Future<Output = Option<AuthContext>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Validate a cookie header value and return an AuthContext if valid. Read more
Source§fn alive(&self, ctx: &AuthContext) -> Result<(), String>
fn alive(&self, ctx: &AuthContext) -> Result<(), String>
AUTH-11: whether an identity this validator produced still stands —
asked while the connection it opened stays open, so a signed-out or
expired session’s socket is closed rather than left to its next
call.
Err: why not, in words for the caller. Read moreAuto Trait Implementations§
impl !Freeze for MemoryAuthBackend
impl Forget for MemoryAuthBackend
impl RefUnwindSafe for MemoryAuthBackend
impl Send for MemoryAuthBackend
impl Sync for MemoryAuthBackend
impl Unpin for MemoryAuthBackend
impl UnsafeUnpin for MemoryAuthBackend
impl UnwindSafe for MemoryAuthBackend
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