|
AQIT 0.1.0
|
Functions | |
| Path | config_path () |
| str | _base_url () |
| None | safe_print (str msg, *, file=None) |
| str | normalize_cli_token (str raw) |
| str|None | validate_cli_token_format (str raw) |
| dict[str, Any] | load_config () |
| None | save_config (dict[str, Any] cfg) |
| dict[str, Any] | _migrate_legacy (dict[str, Any] cfg) |
| str | _account_id (str|None email, str|None name, str|None user_id) |
| str | active_account_id (dict[str, Any]|None cfg=None) |
| list[dict[str, str]] | list_accounts (dict[str, Any]|None cfg=None) |
| str | resolve_api_key (*, bool allow_missing=False, str|None explicit=None) |
| dict[str, Any] | fetch_whoami (str api_key, str|None base_url=None) |
| str | format_account_label (dict[str, Any] whoami) |
| str | cached_account_label (dict[str, Any]|None cfg=None) |
| str | format_revoked_ago (str revoked_at) |
| None | _cache_whoami_ok (str api_key, dict[str, Any] whoami) |
| bool | _cached_whoami_fresh (str api_key, *, float ttl_s=_WHOAMI_CACHE_TTL_S) |
| str | require_valid_login (*, bool force_refresh=False) |
| None | print_token_rejected (str|None api_key=None) |
| str | save_login (str api_key, *, dict[str, Any]|None whoami=None) |
| dict[str, str] | switch_account (str account_id) |
| None | logout_local (*, str|None account_id=None) |
Variables | |
| str | _CONFIG_PATH = Path.home() / ".aquin" / "config.json" |
| str | _BASE_URL_DEFAULT = "https://api.aquin.app" |
| int | _WHOAMI_CACHE_TTL_S = 15 * 60 |
| int | _MIN_TOKEN_LEN = 20 |
|
protected |
Definition at line 114 of file auth_config.py.
Referenced by save_login().
|
protected |
Definition at line 28 of file auth_config.py.
Referenced by fetch_whoami().
|
protected |
Remember a successful whoami so we do not hit the network every command.
Definition at line 301 of file auth_config.py.
References active_account_id(), load_config(), normalize_cli_token(), and save_config().
Referenced by require_valid_login().
|
protected |
Definition at line 326 of file auth_config.py.
References active_account_id(), load_config(), and normalize_cli_token().
Referenced by require_valid_login().
|
protected |
Definition at line 94 of file auth_config.py.
Referenced by load_config().
| str active_account_id | ( | dict[str, Any] | None | cfg = None | ) |
Definition at line 124 of file auth_config.py.
References load_config().
Referenced by _cache_whoami_ok(), _cached_whoami_fresh(), cached_account_label(), list_accounts(), logout_local(), and resolve_api_key().
| str cached_account_label | ( | dict[str, Any] | None | cfg = None | ) |
Account label from saved login metadata - no network.
Definition at line 262 of file auth_config.py.
References active_account_id(), and load_config().
| Path config_path | ( | ) |
Definition at line 24 of file auth_config.py.
| dict[str, Any] fetch_whoami | ( | str | api_key, |
| str | None | base_url = None ) |
Definition at line 172 of file auth_config.py.
References _base_url(), normalize_cli_token(), and validate_cli_token_format().
Referenced by print_token_rejected(), require_valid_login(), and save_login().
| str format_account_label | ( | dict[str, Any] | whoami | ) |
Definition at line 254 of file auth_config.py.
Referenced by switch_account().
| str format_revoked_ago | ( | str | revoked_at | ) |
Definition at line 279 of file auth_config.py.
Referenced by print_token_rejected(), require_valid_login(), and save_login().
| list[dict[str, str]] list_accounts | ( | dict[str, Any] | None | cfg = None | ) |
Definition at line 129 of file auth_config.py.
References active_account_id(), and load_config().
| dict[str, Any] load_config | ( | ) |
Definition at line 77 of file auth_config.py.
References _migrate_legacy().
Referenced by _cache_whoami_ok(), _cached_whoami_fresh(), active_account_id(), cached_account_label(), list_accounts(), logout_local(), resolve_api_key(), save_login(), and switch_account().
| None logout_local | ( | * | , |
| str | None | account_id = None ) |
Definition at line 466 of file auth_config.py.
References active_account_id(), load_config(), and save_config().
| str normalize_cli_token | ( | str | raw | ) |
Strip whitespace / accidental 'Bearer ' prefix.
Definition at line 49 of file auth_config.py.
Referenced by _cache_whoami_ok(), _cached_whoami_fresh(), fetch_whoami(), resolve_api_key(), save_login(), and validate_cli_token_format().
| None print_token_rejected | ( | str | None | api_key = None | ) |
User-facing auth failure with revoked-at hint when available.
Definition at line 384 of file auth_config.py.
References fetch_whoami(), format_revoked_ago(), and safe_print().
Referenced by require_valid_login().
| str require_valid_login | ( | * | , |
| bool | force_refresh = False ) |
Ensure a CLI token is present AND valid with Aquin cloud. Exits the process on failure. Returns the verified api key.
Definition at line 342 of file auth_config.py.
References _cache_whoami_ok(), _cached_whoami_fresh(), fetch_whoami(), format_revoked_ago(), print_token_rejected(), resolve_api_key(), safe_print(), and validate_cli_token_format().
| str resolve_api_key | ( | * | , |
| bool | allow_missing = False, | ||
| str | None | explicit = None ) |
Definition at line 147 of file auth_config.py.
References active_account_id(), load_config(), normalize_cli_token(), and safe_print().
Referenced by require_valid_login().
| None safe_print | ( | str | msg, |
| * | , | ||
| file = None ) |
Print without crashing on Windows cp1252 consoles (no fancy unicode).
Definition at line 32 of file auth_config.py.
Referenced by print_token_rejected(), require_valid_login(), and resolve_api_key().
| None save_config | ( | dict[str, Any] | cfg | ) |
Definition at line 89 of file auth_config.py.
Referenced by _cache_whoami_ok(), logout_local(), save_login(), and switch_account().
| str save_login | ( | str | api_key, |
| * | , | ||
| dict[str, Any] | None | whoami = None ) |
Definition at line 401 of file auth_config.py.
References _account_id(), fetch_whoami(), format_revoked_ago(), load_config(), normalize_cli_token(), save_config(), and validate_cli_token_format().
| dict[str, str] switch_account | ( | str | account_id | ) |
Definition at line 437 of file auth_config.py.
References format_account_label(), load_config(), and save_config().
| str | None validate_cli_token_format | ( | str | raw | ) |
Return an error message if the token is obviously not an Aquin CLI token. Returns None when the shape looks acceptable (still must pass whoami).
Definition at line 57 of file auth_config.py.
References normalize_cli_token().
Referenced by fetch_whoami(), require_valid_login(), and save_login().
|
protected |
Definition at line 18 of file auth_config.py.
|
protected |
Definition at line 17 of file auth_config.py.
|
protected |
Definition at line 21 of file auth_config.py.
|
protected |
Definition at line 20 of file auth_config.py.