Skip to main content

SessionManager

Trait SessionManager 

Source
pub trait SessionManager {
    // Required methods
    async fn create_session(
        &self,
        identity: &AuthenticatedIdentity,
        lifetime_secs: u64,
    ) -> Result<Session, IdentityError>;
    async fn validate_session(&self, id: &str) -> Result<Session, IdentityError>;
    async fn refresh_session(
        &self,
        id: &str,
        extra_secs: u64,
    ) -> Result<Session, IdentityError>;
    async fn revoke_session(&self, id: &str) -> Result<(), IdentityError>;
}
Expand description

A trait for managing sessions.

§Examples

use secure_identity::session::InMemorySessionManager;

// InMemorySessionManager implements SessionManager.
let mgr = InMemorySessionManager::new();

Required Methods§

Source

async fn create_session( &self, identity: &AuthenticatedIdentity, lifetime_secs: u64, ) -> Result<Session, IdentityError>

Creates a new session for the given identity with the given lifetime in seconds.

Source

async fn validate_session(&self, id: &str) -> Result<Session, IdentityError>

Validates a session by ID, returning it if valid and not expired.

Source

async fn refresh_session( &self, id: &str, extra_secs: u64, ) -> Result<Session, IdentityError>

Refreshes a session by ID, extending it by extra_secs seconds.

Source

async fn revoke_session(&self, id: &str) -> Result<(), IdentityError>

Revokes a session by ID.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§