Skip to main content

Module auth_session

Module auth_session 

Source
Expand description

In-memory manager for pre-launch OAuth sessions.

See docs/specs/SPEC_PRE_LAUNCH_OAUTH_FLOW_2026_05_14.md §7.

Each session represents one user-initiated “Connect with OAuth” attempt. The frontend creates a session via start_session, polls via poll_session, optionally pastes a callback URL (the auth.submitcallback handler forwards it via send_to_stdin), and cancels via cancel_session.

PR A scope: the session-state machine + per-line stdout interpretation + lifecycle (timeout, cancel, cleanup). The actual CLI spawn lives in the handler (server/identity_auth_spawn.rs, so it can use AppState’s CLI resolver) but emits frames into this module via record_line / finish_success / finish_failure. That keeps this module pure and testable.

Structs§

AuthSessionManager
PollSessionResult
Snapshot returned by poll_session. Mirrors AuthSessionStatus plus the provider id for renderer dispatch.
ProcessRefs 🔒
Per-session “process refs” — the join handle for the drain task and the stdin sender for the callback-paste-back path. Held outside the sessions Mutex so cancellation can .abort() / drop without holding the state lock across an await.
Session 🔒
StartSessionResult
Public-facing handle returned by start_session. The handler owns the spawned CLI’s child handle (so it can stdin-inject the pasted callback URL and kill on cancel); this manager owns the session state.

Enums§

AuthSessionStatus

Constants§

FINISHED_RETENTION_SECS 🔒
How long a finished session stays pollable before sweep drops it. The UI stops polling once it sees the terminal state, so this only has to outlast one poll interval; it’s generous.
SESSION_TIMEOUT_SECS 🔒
Wall-clock cap on a single auth session. Past this, the session transitions to Failed and its CLI is killed, whether or not anyone is polling it (sweep).
SWEEP_INTERVAL_SECS 🔒
How often the sweeper runs (spawn_sweeper).

Functions§

timeout_error 🔒