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,
into_bundle_id: Option<String>,
) -> StartSessionResult
pub fn start_session( &self, provider_id: String, into_bundle_id: 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.
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) -> bool
pub fn finish_success(&self, session_id: &str, bundle_id: String) -> bool
Handler-side completion hook. Called when the CLI exits or auth check confirms success. Transitions the session to a terminal state.
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. Also sweeps timed-out sessions: if the session has been Pending past SESSION_TIMEOUT_SECS, transition to Failed and return that.
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).
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 remove(&self, session_id: &str)
pub fn remove(&self, session_id: &str)
Remove a session from the map. Caller should only invoke this after the session is terminal AND the frontend has had time to read the final state (typically after the next successful poll). For PR A we just leave terminal sessions in the map; PR B can add an LRU sweep.
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 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.