Skip to main content

Authentication helpers for WebAuthn and TOTP flows.

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

authguard_lib-0.1.0.tar.gz (16.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

authguard_lib-0.1.0-py3-none-any.whl (30.9 kB view details)

Uploaded Python 3

File details

Details for the file authguard_lib-0.1.0.tar.gz.

File metadata

  • Download URL: authguard_lib-0.1.0.tar.gz
  • Upload date:
  • Size: 16.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for authguard_lib-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ac12ad1e1a0d46c39bd7d37e06f40e327966d5b757de2e72da4b4f6f42716664
MD5 02d8c443d8a404af852da09a05a5cb11
BLAKE2b-256 b2271ab122f42eea6de2e9352e79d3c527eecbb824524f50c774c80e214a622b

See more details on using hashes here.

File details

Details for the file authguard_lib-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: authguard_lib-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 30.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for authguard_lib-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f9c6a4084a0b51e184686201d4a32610029629274a111c4e2c77e4d51aa76469
MD5 d3872a7c1f28455ad6298487781114c2
BLAKE2b-256 33583c2aa6dd5db3b77c479e4e714d4e5a4d1d384d49462570cd61559b50cc80

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page