common_auth.stores.base
Auth-state operations and concurrency shared by storage backends.
Classes
BaseStore
Bases: ABC
Versioned auth state with explicit opening and owner-controlled cleanup.
Carries lifecycle/loop admission; variants hold backend resources. Each writer holds a per-record guard and performs a conditional revision update. Pending grant records survive interrupted issuer calls and are never treated as reusable tokens. Only explicit publication/recovery clears pending state. Deletion keeps a revision tombstone, preventing stale-write resurrection.
__init__
def __init__() -> NoneFields and properties declared here; inherited members belong to the bases above.
state
Read-only property.
state: straclose
async def aclose() -> NoneStop admission, finish teardown under cancellation, and permit cleanup retry.
A failed teardown leaves the store closing: operations remain rejected, but a later aclose can release the resource. Successful teardown always publishes closed before propagating cancellation to its caller.
consume_state
async def consume_state(key: str, *, expected_revision: int) -> AuthResult[bytes]delete
async def delete(grant: GrantRef, *, expected_revision: int) -> AuthResult[None]get
async def get(grant: GrantRef) -> AuthResult[TokenSet]get_state
async def get_state(key: str) -> AuthResult[bytes]guard
async def guard(grant: GrantRef) -> AsyncIterator[_GrantGuard]open
async def open() -> Selfput
async def put(tokens: TokenSet, *, expected_revision: int, acquired_at: datetime | None = None) -> AuthResult[TokenSet]save_state
async def save_state(key: str, value: bytes, expires_at: datetime, *, expected_revision: int = 0) -> AuthResult[bytes]