pub struct AuthenticatorChain { /* private fields */ }Expand description
An ordered set of Authenticators tried in turn.
The chain is what makes “idp is one authenticator among several” structural rather than aspirational: plexus-idp registers its bearer, cookie, and API-key authenticators into a chain, and a nostr gateway would push one more in without any of them knowing about each other.
§Ordering and short-circuiting
Authenticators are tried in insertion order. The first one whose
authenticate returns anything other than
Unsupported decides the outcome —
success or failure. A malformed JWT therefore does not fall through to
the API-key authenticator hoping it will be luckier.
Implementations§
Source§impl AuthenticatorChain
impl AuthenticatorChain
Sourcepub fn with(self, authenticator: Arc<dyn Authenticator>) -> Self
pub fn with(self, authenticator: Arc<dyn Authenticator>) -> Self
Append an authenticator.
Sourcepub fn try_with(
self,
authenticator: Arc<dyn Authenticator>,
) -> Result<Self, String>
pub fn try_with( self, authenticator: Arc<dyn Authenticator>, ) -> Result<Self, String>
Append an authenticator, refusing one whose name the chain already holds (IDENTITY-27): two providers of one name would mint one namespace. The error is the repeated name.
Sourcepub async fn authenticate(
&self,
presentation: &Presentation,
) -> Result<Authenticated, AuthnRejection>
pub async fn authenticate( &self, presentation: &Presentation, ) -> Result<Authenticated, AuthnRejection>
Try each authenticator in order.
Returns the first non-Unsupported outcome. If every authenticator
declines, the last Unsupported is returned (or a synthetic one for
an empty chain), so the caller can tell “nobody handles this” from
“somebody handled it and said no”.
Trait Implementations§
Source§impl Clone for AuthenticatorChain
impl Clone for AuthenticatorChain
Source§impl Debug for AuthenticatorChain
impl Debug for AuthenticatorChain
Source§impl Default for AuthenticatorChain
impl Default for AuthenticatorChain
Source§impl SessionValidator for AuthenticatorChain
Adapts a chain to the existing perimeter.
impl SessionValidator for AuthenticatorChain
Adapts a chain to the existing perimeter.
The cookie header a SessionValidator receives is offered to the chain as
a Presentation::Cookie; if no authenticator claims it, it is retried as
a Presentation::Bearer, because plexus-idp’s validator has always
accepted a bare token in the cookie position and callers depend on that.
Source§fn validate<'life0, 'life1, 'async_trait>(
&'life0 self,
cookie_value: &'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,
cookie_value: &'life1 str,
) -> Pin<Box<dyn Future<Output = Option<AuthContext>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn alive(&self, ctx: &AuthContext) -> Result<(), String>
fn alive(&self, ctx: &AuthContext) -> Result<(), String>
Err: why not, in words for the caller. Read more