Skip to main content

AuthGuard

AuthGuard is a Python library for building TOTP and WebAuthn authentication flows.

It provides:

  • TOTP enrollment, verification, and recovery-code helpers
  • WebAuthn registration and authentication services
  • in-memory, SQLite, Redis, and PostgreSQL storage backends
  • a small, typed service surface built around a src/ package layout

Installation

Install the library:

pip install authguard

For local development:

pip install -e ".[dev]"

Quick Start

import asyncio

from authguard import AuthService, Config, MemoryStorage, User


async def main() -> None:
    storage = MemoryStorage()
    config = Config(
        RP_ID="example.com",
        RP_NAME="Example App",
        RP_ORIGINS=("https://example.com",),
    )
    auth = AuthService(storage=storage, config=config)

    user = User(id="user-123", name="alice@example.com", display_name="Alice")

    enrollment = await auth.totp.begin_enrollment(
        user_id=user.id,
        user_name=user.name,
    )
    print(enrollment.provisioning_uri)

    registration_options = await auth.webauthn.begin_registration(user=user)
    print(registration_options.rp.id)


asyncio.run(main())

Public API

Top-level imports:

from authguard import AuthService, Config, MemoryStorage, User, get_storage

Available storage backends:

  • MemoryStorage
  • SQLiteStorage
  • RedisStorage
  • PostgreSQLStorage

Running Tests

pytest -q tests/unit

Release files for authguard-lib 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for authguard-lib 0.1.0
File Size Uploaded
authguard_lib-0.1.0.tar.gz 16.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for authguard-lib 0.1.0
File Interpreter ABI Platform
authguard_lib-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 47.6 kB

Release files / authguard_lib-0.1.0.tar.gz

Download URL authguard_lib-0.1.0.tar.gz
Size 16.7 kB
Tags Source
SHA-256 checksum
How to use checksums
ac12ad1e1a0d46c39bd7d37e06f40e327966d5b757de2e72da4b4f6f42716664
BLAKE2b-256 checksum
How to use checksums
b2271ab122f42eea6de2e9352e79d3c527eecbb824524f50c774c80e214a622b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.7

Release files / authguard_lib-0.1.0-py3-none-any.whl

Download URL authguard_lib-0.1.0-py3-none-any.whl
Size 30.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f9c6a4084a0b51e184686201d4a32610029629274a111c4e2c77e4d51aa76469
BLAKE2b-256 checksum
How to use checksums
33583c2aa6dd5db3b77c479e4e714d4e5a4d1d384d49462570cd61559b50cc80
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.7

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page