pub struct SessionManager { /* private fields */ }Expand description
Issues, validates, revokes, and lists guard sessions.
Implementations§
Source§impl SessionManager
impl SessionManager
Sourcepub fn new(pool: SqlitePool, config: Arc<GuardConfig>) -> Self
pub fn new(pool: SqlitePool, config: Arc<GuardConfig>) -> Self
Creates a session manager backed by the provided database pool.
Sourcepub async fn create_session(
&self,
agent_id: Uuid,
workspace_id: Uuid,
role: &str,
scopes: Vec<String>,
ttl_secs: u64,
) -> GuardResult<GuardSession>
pub async fn create_session( &self, agent_id: Uuid, workspace_id: Uuid, role: &str, scopes: Vec<String>, ttl_secs: u64, ) -> GuardResult<GuardSession>
Creates a new JWT-backed session and stores it in SQLite.
Sourcepub async fn validate_session(&self, token: &str) -> GuardResult<GuardSession>
pub async fn validate_session(&self, token: &str) -> GuardResult<GuardSession>
Validates a session JWT and confirms the backing row remains active.
Sourcepub async fn revoke_session(&self, session_id: Uuid) -> GuardResult<()>
pub async fn revoke_session(&self, session_id: Uuid) -> GuardResult<()>
Revokes a session row.
Sourcepub async fn list_active_sessions(
&self,
agent_id: Uuid,
opts: Option<ListOptions>,
) -> GuardResult<ListPage<SessionRecord>>
pub async fn list_active_sessions( &self, agent_id: Uuid, opts: Option<ListOptions>, ) -> GuardResult<ListPage<SessionRecord>>
Lists active sessions for an agent.
Sourcepub async fn assert_session_active(
&self,
session: &GuardSession,
) -> GuardResult<()>
pub async fn assert_session_active( &self, session: &GuardSession, ) -> GuardResult<()>
Confirms that a session row is still active.
Trait Implementations§
Source§impl Clone for SessionManager
impl Clone for SessionManager
Source§fn clone(&self) -> SessionManager
fn clone(&self) -> SessionManager
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for SessionManager
impl !RefUnwindSafe for SessionManager
impl Send for SessionManager
impl Sync for SessionManager
impl Unpin for SessionManager
impl UnsafeUnpin for SessionManager
impl !UnwindSafe for SessionManager
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request