aegis-auth · session
Declared module signatures, types, configuration, and source documentation.
Source: aegis/aegis-auth/src/session.rs. SHA-256: a25c8ec6b3c94cbbd424956d697d6f5d9c1021be33374f4cb703c1857052ffe9.
This source reference follows declared modules and preserves feature attributes. It includes public declarations and implementation methods in those modules. Private-module exports and trait resolution still require the compiler; not every declaration is a crate-root import. Function bodies and constant values are omitted. Source comments describe their implementation context and are not a production deployment claim.
session::SessionManager
Session manager with in-memory storage.
Provides create, get, revoke, and cleanup operations for authentication sessions. Agent sessions are shorter-lived (1 hour default) than human sessions (24 hours default) per the AEGIS specification.
pub struct SessionManager {
/// Max lifetime for human sessions.
pub human_max_lifetime: Duration,
/// Max lifetime for agent sessions.
pub agent_max_lifetime: Duration
}Source line: 28.
session::SessionManager::new
Create a new session manager with default lifetimes.
- Human sessions: 24 hours
- Agent sessions: 1 hour
pub fn new() -> Self;Source line: 41.
session::SessionManager::with_lifetimes
Create a new session manager with custom lifetimes.
Arguments
human_max_lifetime- Maximum lifetime for human sessions.agent_max_lifetime- Maximum lifetime for agent sessions.
pub fn with_lifetimes(human_max_lifetime: Duration, agent_max_lifetime: Duration) -> Self;Source line: 55.
session::SessionManager::create_session
Create a new authenticated session.
Generates a UUID v7 session identifier and computes the expiry time based on the entity type (agent or human).
Arguments
did- DID of the authenticated entity.provider- Name of the auth provider that validated the credential.scope- List of authorized scopes for this session.is_agent- Whether the entity is an agent (shorter session lifetime).device_binding- Optional device fingerprint to bind this session to.
Returns
The newly created [Session].
Errors
Returns [AuthError::Internal] if the session lock is poisoned.
pub fn create_session(
&self,
did: &str,
provider: &str,
scope: Vec<String>,
is_agent: bool,
device_binding: Option<String>,
) -> Result<Session, AuthError>;Source line: 83.
session::SessionManager::get_session
Retrieve a session by ID.
Returns the session if it exists and has not expired. If the session
has expired, it is automatically removed and a SessionExpired error
is returned.
Arguments
session_id- The session identifier to look up.
Errors
Returns [AuthError::SessionExpired] if the session exists but has expired.
Returns [AuthError::InvalidCredential] if the session does not exist.
Returns [AuthError::Internal] if the session lock is poisoned.
pub fn get_session(&self, session_id: &str) -> Result<Session, AuthError>;Source line: 132.
session::SessionManager::revoke_session
Revoke a session by removing it from storage.
Arguments
session_id- The session identifier to revoke.
Errors
Returns [AuthError::InvalidCredential] if the session does not exist.
Returns [AuthError::Internal] if the session lock is poisoned.
pub fn revoke_session(&self, session_id: &str) -> Result<(), AuthError>;Source line: 164.
session::SessionManager::is_valid
Quick validity check for a session.
Returns true if the session exists and has not expired, false
otherwise. Does not modify state (does not remove expired sessions).
pub fn is_valid(&self, session_id: &str) -> bool;Source line: 182.
session::SessionManager::cleanup_expired
Remove all expired sessions from storage.
Returns the number of sessions removed. This should be called periodically to prevent unbounded memory growth.
pub fn cleanup_expired(&self) -> usize;Source line: 198.
session::SessionManager::session_count
Returns the number of active sessions (includes expired ones not yet cleaned).
pub fn session_count(&self) -> usize;Source line: 211.