pub struct AuthSessionManager {
sessions: Arc<Mutex<HashMap<String, Session>>>,
process_refs: Arc<Mutex<ProcessRefs>>,
}Fields§
§sessions: Arc<Mutex<HashMap<String, Session>>>§process_refs: Arc<Mutex<ProcessRefs>>Implementations§
Source§impl AuthSessionManager
impl AuthSessionManager
pub fn new() -> Self
Sourcepub fn start_session(
&self,
provider_id: String,
exclusive_key: Option<String>,
) -> StartSessionResult
pub fn start_session( &self, provider_id: String, exclusive_key: Option<String>, ) -> StartSessionResult
Allocate a new session id and store the initial Pending state.
The caller (handler) is responsible for spawning the CLI and
feeding stdout lines into record_line.
exclusive_key is the account directory the login writes to. A live
session for the same directory is cancelled first: two CLIs logging
in to one directory at once race on its credential files (the
desktop host’s single login slot has the same rule).
Sourcepub fn record_line(
&self,
session_id: &str,
line: &str,
) -> Option<AuthPatternMatch>
pub fn record_line( &self, session_id: &str, line: &str, ) -> Option<AuthPatternMatch>
Feed a single line of CLI stdout/stderr into the session. Returns the pattern match (if any) so the handler can decide to forward the URL elsewhere (e.g. broker event).
Sourcepub fn finish_success(
&self,
session_id: &str,
bundle_id: String,
account_id: Option<String>,
) -> bool
pub fn finish_success( &self, session_id: &str, bundle_id: String, account_id: Option<String>, ) -> bool
Handler-side completion hook. Called when the CLI exits or
auth check confirms success. Transitions the session to a
terminal state. account_id is None for the legacy
bundle-mode path; Some(id) for a direct-account session
(issue #1624 PR-C Part B) — see AuthSessionStatus::Success.
pub fn finish_failure(&self, session_id: &str, error: String) -> bool
Sourcepub fn poll_session(&self, session_id: &str) -> Option<PollSessionResult>
pub fn poll_session(&self, session_id: &str) -> Option<PollSessionResult>
Poll a session’s current status. A session past SESSION_TIMEOUT_SECS is ended first (Failed, CLI killed).
Sourcepub fn sweep(&self)
pub fn sweep(&self)
End sessions past their timeout (Failed, CLI killed) and drop
finished ones nobody has polled for FINISHED_RETENTION_SECS. Runs
every SWEEP_INTERVAL_SECS (spawn_sweeper), so a login whose UI went
away doesn’t leave its CLI running or its session behind.
Sourcepub fn spawn_sweeper(self: &Arc<Self>)
pub fn spawn_sweeper(self: &Arc<Self>)
Run sweep every SWEEP_INTERVAL_SECS for as long as srv runs.
Sourcepub fn cancel_session(&self, session_id: &str) -> bool
pub fn cancel_session(&self, session_id: &str) -> bool
Cancel a session: transition state to Failed + abort the spawned drain task (which kills the child via kill_on_drop). Returns true if the state transition happened (false on unknown / already-terminal session — the process refs are torn down either way so a re-fired cancel is a no-op).
Sourcefn end_session(&self, session_id: &str, error: String) -> bool
fn end_session(&self, session_id: &str, error: String) -> bool
Fail a session with error and stop its CLI: abort the drain task
(the pipe path’s child goes with it, kill_on_drop), drop its stdin,
and kill a PTY child by PID. True if the state changed; the process
refs go either way, so ending a session twice is harmless.
Sourcefn stop_process(&self, session_id: &str)
fn stop_process(&self, session_id: &str)
Stop a session’s CLI and drop its process refs: abort the drain task
(the pipe path’s child goes with it, kill_on_drop), drop its stdin,
and kill a PTY child by PID.
Sourcepub fn ended(&self, session_id: &str) -> bool
pub fn ended(&self, session_id: &str) -> bool
Has this session ended (or gone)? A login confirmed after its session was replaced, cancelled or timed out must not be saved: a newer sign-in owns the directory now.
fn is_terminal(&self, session_id: &str) -> bool
Sourcepub fn attach_pty_pid(&self, session_id: &str, pid: u32)
pub fn attach_pty_pid(&self, session_id: &str, pid: u32)
Register the PID of a PTY-backed auth subprocess so
cancel_session can terminate it. Called by auth.start
after spawning a PTY login (in addition to attach_process).
Sourcepub fn attach_process(
&self,
session_id: &str,
drain_task: JoinHandle<()>,
stdin_sender: Sender<String>,
)
pub fn attach_process( &self, session_id: &str, drain_task: JoinHandle<()>, stdin_sender: Sender<String>, )
Register the drain task + stdin sender for a session. Called by the handler immediately after spawning the CLI.
Sourcepub async fn send_to_stdin(&self, session_id: &str, line: String) -> bool
pub async fn send_to_stdin(&self, session_id: &str, line: String) -> bool
Forward a pasted callback URL to the spawned CLI’s stdin. Returns true if the session has an attached stdin sender; false if the session never spawned a CLI or the sender’s receiver was dropped.
Sourcepub fn detach_process(&self, session_id: &str)
pub fn detach_process(&self, session_id: &str)
Drop a session’s process refs without aborting them. Called by the drain task itself when it exits normally so terminal state lookups still work but the resources are reclaimed.
Sourcepub fn captured_email(&self, session_id: &str) -> Option<String>
pub fn captured_email(&self, session_id: &str) -> Option<String>
The account email scraped from this session’s login transcript, if the provider printed one.
Read before finish_success, which consumes the session — the
account is persisted first (identity_auth_spawn) and needs the email
at that point to record it on the account
(SPEC_ACCOUNT_EMAIL_IN_ARMORY_2026_09_23.md). None when the
provider reported no email, which is not an error: providers whose CLI
does not surface one simply have no email to show.
Trait Implementations§
Source§impl Default for AuthSessionManager
impl Default for AuthSessionManager
Source§fn default() -> AuthSessionManager
fn default() -> AuthSessionManager
Auto Trait Implementations§
impl Freeze for AuthSessionManager
impl RefUnwindSafe for AuthSessionManager
impl Send for AuthSessionManager
impl Sync for AuthSessionManager
impl Unpin for AuthSessionManager
impl UnsafeUnpin for AuthSessionManager
impl UnwindSafe for AuthSessionManager
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
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> 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> ⓘ
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> ⓘ
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 more