Skip to main content

AuthSessionManager

Struct AuthSessionManager 

Source
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

Source

pub fn new() -> Self

Source

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).

Source

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).

Source

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.

Source

pub fn finish_failure(&self, session_id: &str, error: String) -> bool

Source

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).

Source

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.

Source

pub fn spawn_sweeper(self: &Arc<Self>)

Run sweep every SWEEP_INTERVAL_SECS for as long as srv runs.

Source

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).

Source

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.

Source

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.

Source

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.

Source

fn is_terminal(&self, session_id: &str) -> bool

Source

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).

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn transcript(&self, session_id: &str) -> Option<Vec<String>>

Read the full transcript of captured stdout/stderr lines. Used by integration tests; exposed for completeness even though no production caller currently reads it.

Trait Implementations§

Source§

impl Default for AuthSessionManager

Source§

fn default() -> AuthSessionManager

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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>

Convert 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)

Convert &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)

Convert &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
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync> ⓘ

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

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 more
§

impl<T> NoneValue for T
where T: Default,

§

type NoneType = T

§

fn null_value() -> T

The none-equivalent value.
§

impl<T> NoneValue for T
where T: Default,

§

type NoneType = T

§

fn null_value() -> T

The none-equivalent value.
§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more