animedex.auth.keyring_store
OS-keyring implementation of TokenStore.
Per plans/02 §7 this is the production token store: tokens live
in the OS keyring (Secret Service on Linux, Keychain on macOS,
Credential Locker on Windows) so a stolen dotfile cannot exfiltrate
credentials. Enumeration (keys()) is the one operation the
keyring package does not expose uniformly; we keep an in-process
companion set populated as set() and delete() are called,
so keys() returns what this process has registered. CLI
callers that need the full host-wide list use the OS keyring viewer.
Tests never touch the real keyring; the module pulls
_keyring through an indirection so a fake module can be
swapped in.
KeyringTokenStore
- class animedex.auth.keyring_store.KeyringTokenStore(*, service: str = 'animedex')[source]
Bases:
objectA
TokenStorebacked by the OS keyring.- Parameters:
service (str) – Keyring service namespace under which entries live; defaults to
"animedex". Test code overrides this so production keyring entries stay untouched.
selftest
- animedex.auth.keyring_store.selftest() bool[source]
Smoke-test the keyring store at the import level only.
Per
plans/02 §7andplans/04 §2this selftest must not touch the real OS keyring: a CI environment may have no backend available, and writing a real entry from the diagnostic would be a side effect users do not expect.The function therefore only verifies that the
keyringpackage imports and exposes the three call sites the store relies on. The behaviour itself is exercised in unit tests via a faked module.- Returns:
Trueon success.- Return type: