Add Python authclient module (mirrors the Go/Node authclient)

Async (asyncpg-consistent with the rest of this package), stdlib-only
HTTP via urllib + asyncio.to_thread (no new dependency for one GET
call). Framework-agnostic by design: read the two real consumers
(HordeWorker's aiohttp webui, Heretic's FastAPI app) and they don't
share a framework, so token_from_request/resolve_user work over plain
headers/cookies mappings rather than shipping a framework adapter.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Gabriel20xxandClaude Sonnet 5 committed 2026-08-31 23:06:07 +02:00
1 parent 7c813cce9e
commit ac516a7dc8
4 files changed
+438 -1

No files matched your search

@@ -14,6 +14,14 @@ from .auth import (
normalize_role,
verify_password,
)
from .authclient import (
AuthClient,
AuthClientError,
AuthGuardUser,
InvalidSessionError,
resolve_user,
token_from_request,
)
from .config import DatabaseConfig, database_url_from_env
from .postgres import Database
from .tokens import hash_token, new_session_token
@@ -22,6 +30,12 @@ from .totp import generate_totp_secret, totp_provisioning_uri, verify_totp
__all__ = [
"AuthStore",
"AuthUser",
"AuthClient",
"AuthClientError",
"AuthGuardUser",
"InvalidSessionError",
"resolve_user",
"token_from_request",
"ROLE_ADMIN",
"ROLE_SUPERADMIN",
"ROLE_USER",