RepositoryPythonUSUnited States
duo-labs

duo-labs/py_webauthn

Pythonic WebAuthn 🐍

1.1kstars
203forks
5issues
6views

Featured achievements

The project's latest awards

1
TINIX TRENDING·Topic: webauthn

#1 Repository of the month

1
TINIX TRENDING·Topic: pypi

#1 Repository of the month

1
TINIX TRENDING·Topic: fido2

#1 Repository of the month

py_webauthn

PyPI GitHub license Pythonic WebAuthn

A Python3 implementation of the server-side of the WebAuthn API focused on making it easy to leverage the power of WebAuthn.

This library supports all FIDO2-compliant authenticators, including security keys, Touch ID, Face ID, Windows Hello, Android biometrics...and pretty much everything else.

Installation

This module is available on PyPI:

pip install webauthn

Requirements

  • Python 3.10 and up

Usage

The library exposes just a few core methods on the root webauthn module:

  • generate_registration_options()
  • verify_registration_response()
  • generate_authentication_options()
  • verify_authentication_response()

Two additional helper methods are also exposed:

  • options_to_json()
  • base64url_to_bytes()

Additional data structures are available on webauthn.helpers.structs. These dataclasses are useful for constructing inputs to the methods above, and for providing type hinting to help ensure consistency in the shape of data being passed around.

Generally, the library makes the following assumptions about how a Relying Party implementing this library will interface with a webpage that will handle calling the WebAuthn API:

The examples mentioned below include uses of the options_to_json() helper (see above) to show how easily bytes values in registration and authentication options can be encoded to base64url for transmission to the front end.

The examples also include demonstrations of how to pass JSON-ified responses, using base64url encoding for ArrayBuffer values, into parse_registration_credential_json and parse_authentication_credential_json to be automatically parsed by the methods in this library. An RP can pair this with corresponding custom front end logic, or one of several frontend-specific libraries (like @simplewebauthn/browser, for example) to handle encoding and decoding such values to and from JSON.

Other arguments into this library's methods that are defined as bytes are intended to be values stored entirely on the server. Such values can more easily exist as bytes without needing potentially extraneous encoding and decoding into other formats. Any encoding or decoding of such values in the name of storing them between steps in a WebAuthn ceremony is left up to the RP to achieve in an implementation-specific manner.

Registration

See examples/registration.py for practical examples of using generate_registration_options() and verify_registration_response().

You can also run these examples with the following:

# See "Development" below for venv setup instructions
venv $> uv run -m examples.registration

Authentication

See examples/authentication.py for practical examples of using generate_authentication_options() and verify_authentication_response().

You can also run these examples with the following:

# See "Development" below for venv setup instructions
venv $> uv run -m examples.authentication

Development

Installation

Install uv by following the installation instructions here:

https://docs.astral.sh/uv/getting-started/installation/

Afterwards, run the following command to set up a virtual environment and install the project's dependencies:

$> uv sync

Testing

Python's unittest module can be used to execute everything in the tests/ directory:

venv $> uv run -m unittest

Auto-watching unittests can be achieved with a tool like nodemon.

All tests:

venv $> nodemon --exec "uv run -m unittest" --ext py

An individual test file:

venv $> nodemon --exec "uv run -m unittest tests/test_aaguid_to_string.py" --ext py

Linting and Formatting

Linting is handled via mypy:

venv $> uv run -m mypy webauthn
Success: no issues found in 52 source files

The entire library is formatted using black:

venv $> uv run -m black webauthn --line-length=99
All done! ✨ 🍰 ✨
52 files left unchanged.

Similar Projects

Discover other similar projects and AI models.

RepositoryPython
donnemartin/system-design-primer

Learn how to design large-scale systems. Prep for the system design interview. Includes Anki flashcards.

379.9k
Sep 15, 2026
RepositoryPython
practical-tutorials/project-based-learning

Curated list of project-based tutorials

290.9k
Nov 30, 2026
RepositoryTypeScript
morluto/rea

Reverse engineer anything with agents, from app behavior down to native binaries.

487.0k
Dec 2, 2026
RepositoryJavaScript
CyC2018/CS-Notes

:books: 技术面试必备基础知识、Leetcode、计算机操作系统、计算机网络、系统设计

186.6k
Nov 27, 2026
RepositoryPython
Asabeneh/30-Days-Of-Python

The 30 Days of Python programming challenge is a step-by-step guide to learn the Python programming language in 30 days. This challenge may take more than 100 days. Follow your own pace. These videos may help too: https://www.youtube.com/channel/UC7PNRuno1rzYPb1xLa4yktw

80.0k
Sep 30, 2026
RepositoryPython
pypa/pipx

Install and Run Python Applications in Isolated Environments

13.0k
Nov 24, 2026
RepositoryPython
pypiserver/pypiserver

Minimal PyPI server for uploading & downloading packages with pip/easy_install

2.1k
Dec 1, 2026
RepositoryPython
CoderWanFeng/python-office

pip install python-office 自动化办公专用库

1.4k
Oct 29, 2026
RepositoryPython
Yubico/python-fido2

Provides library functionality for FIDO 2.0, including communication with a device over USB.

553
Nov 19, 2026