Skip to main content

SessionValidator

Trait SessionValidator 

Source
pub trait SessionValidator:
    Send
    + Sync
    + 'static {
    // Required method
    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;

    // Provided method
    fn alive(&self, ctx: &AuthContext) -> Result<(), String> { ... }
}

Required Methods§

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,

Validate a cookie header value and return an AuthContext if valid.

§Arguments
  • cookie_value - The raw Cookie header value (e.g., “session=abc123; path=/”)
§Returns
  • Some(AuthContext) if the cookie is valid and represents an authenticated session
  • None if the cookie is invalid, expired, or represents an anonymous session
§Implementation Notes
  • This is called during the WebSocket handshake (HTTP upgrade)
  • Validation should be fast to avoid blocking the connection
  • For JWT: verify signature, check expiration, extract claims
  • For session-based auth: lookup session in DB/Redis
  • Return None for invalid/expired credentials (connection proceeds as anonymous)

Provided Methods§

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.

Default: not past its EXPIRES_AT_KEY stamp. A validator whose sessions can end early (sign-out, revocation) must answer that here. Memory only: it is asked often.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

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§

impl SessionValidator for OidcSessionValidator