Skip to main content

Module identity_auth_dirs

Module identity_auth_dirs 

Source
Expand description

Filesystem/directory provisioning for the pre-launch OAuth flow.

Split out of identity_handlers.rs (module-organization pass, see docs/specs/PLAN_LOGIN_SINGLE_PATH_CONSOLIDATION_2026_07_20.md) — owns compute_and_ensure_bundle_dir (vestigial, bundle mode was retired in Phase 4c of SPEC_PRESET_TO_BUNDLE_REFACTOR_2026_07_02.md, kept only so the wire shape and its one call site in identity_handlers::register_identity_handlers don’t need touching) and compute_and_ensure_account_dir (the live direct-account path).

Constants§

ORPHAN_SWEEP_MIN_AGE_SECS 🔒
Direct-account sibling of compute_and_ensure_bundle_dir (issue #1624 PR-C Part B) — bypasses the bundle system entirely. Mints a fresh account_id when existing_account_id is empty (first-time OAuth connect from the launch modal); reuses it when non-empty (Reconnect — refresh tokens in place, same isolation dir, same account row updated in place).

Functions§

caller_auth_dir 🔒
The account directory a caller already chose, as auth_env names it under the provider’s auth_config_dir_env_var: the key that keeps a login the caller persists itself (not direct_account) to one live session per directory. None for a provider without one, or when it isn’t set.
compute_and_ensure_account_dir 🔒
Returns (account_id, dir) — account_id is always populated (even on a dir-resolution failure, so the caller can still log/track it); dir is None on the same gate/registry/fs failures compute_and_ensure_bundle_dir treats as soft failures — never abort auth.start over a config-dir issue.
compute_and_ensure_bundle_dir 🔒
Compute the per-bundle OAuth config dir + ensure it exists + override the provider’s auth_config_dir_env_var entry in auth_env.
link_history_if_isolated 🔒
Best-effort: if provider has a linkable native history directory (ProviderConfig::history_native_subdir, None for providers with no fixed on-disk history to redirect) and credential isolation is currently on, ensure dir/<subdir> is linked to the always-global history location for entity_id (a bundle id or account id — same namespace, see [DataPaths::identity_dir]). No-op when isolation is off (dir is already inside the global tree, so dir/<subdir> already IS the global location) or the provider has no linkable subdir. Never fails the caller — logs and continues, same philosophy as every other soft-fail in this module.