Skip to main content

MemoryAuthBackend

Struct MemoryAuthBackend 

Source
pub struct MemoryAuthBackend { /* private fields */ }
Expand description

An in-memory AuthBackend and SessionValidator. See the module docs for its flows.

Implementations§

Source§

impl MemoryAuthBackend

Source

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.

Source

pub fn with_providers(self, providers: Vec<Provider>) -> Self

Replace the providers offered.

Source

pub fn with_user( self, username: &str, password: &str, principal: &str, name: Option<&str>, ) -> Self

A password user: username / password sign in as principal.

Source

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=…).

Source

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).

Source

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

Source§

fn providers(&self) -> Vec<Provider>

The ways in this server offers (auth.providers).
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,

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,

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,

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>

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,

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>

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

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

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,

Validate a cookie header value and return an AuthContext if valid. Read more
Source§

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 more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> MaybeSend for T
where T: Send,

Source§

impl<T> MaybeSendSync for T
where T: Send + Sync,

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more