API Reference¶
Every public name in authority-auth is importable from the top-level
authority package unless noted otherwise. The reference is split into
per-topic pages:
| Topic | Page |
|---|---|
| Configuration | Configuration |
| Sync manager | AuthManager |
| Async manager | AsyncAuthManager |
| Tokens | Tokens |
| Sessions | Sessions |
| Multi-factor authentication | MFA |
| WebAuthn / passkeys | WebAuthn |
| Roles & permissions | RBAC |
| API keys | API keys |
| Audit log | Audit |
| Events | Events |
| Exceptions | Exceptions |
| Storage | Storage |
| Framework integrations | Integrations |
| Utilities | Utilities |
Package layout¶
| Module | Contents |
|---|---|
authority |
Re-exports config, managers, events, exceptions, storage, utils |
authority.config |
AuthConfig |
authority.core |
AuthManager (sync) |
authority.async_core |
AsyncAuthManager (async) |
authority.events |
Event, EventBus |
authority.exceptions |
The exception hierarchy |
authority.storage.base |
StorageInterface, AsyncStorageInterface |
authority.storage.sqlite |
SQLiteStorage |
authority.storage.aiosqlite |
AsyncSQLiteStorage |
authority.fastapi |
FastAPI dependencies (fastapi extra) |
authority.flask |
FlaskAuth + helpers (flask extra) |
authority.django |
AuthorityBackend + helpers (django extra) |
authority.starlette |
StarletteAuth (starlette extra) |
authority.asgi |
AuthorityASGIMiddleware + helpers |
authority.wsgi |
AuthorityWSGIMiddleware + helpers |
authority.utils |
Standalone helpers |
Syncing and async¶
Both managers expose the same 55-method surface; the async manager's methods
are coroutines and require the async extra.
- AuthManager — sync, backed by
SQLiteStorage. - AsyncAuthManager — async, backed by
AsyncSQLiteStorage(aiosqlite).
Managers are context managers: with AuthManager(...) / async with
AsyncAuthManager(...) close the storage connection on exit. Otherwise call
close() / await close() explicitly. There is no .open() call —
SQLite storage connects lazily, and AsyncSQLiteStorage requires an explicit
await storage.connect().
Constructor arguments¶
AuthConfig¶
AuthConfig(**kwargs) — dataclass. Values resolve as constructor kwargs >
environment variables (AUTHORITY_*) > defaults. An empty jwt_secret_key
raises ConfigurationError. See Configuration for all 36
fields.
AuthManager / AsyncAuthManager¶
AuthManager(config: AuthConfig, storage: StorageInterface, event_bus: EventBus | None = None)
AsyncAuthManager(config: AuthConfig, storage: AsyncStorageInterface, event_bus: EventBus | None = None)
event_bus is optional; pass one to receive lifecycle events. See
Events.
Exceptions¶
All errors inherit from AuthError. The full 24-class hierarchy is on the
Exceptions page. Import from authority: