Pythonic WebAuthn
Maintained. Last release 2 months ago, commits in 6 of the last 26 weeks. Weaker on contributor spread and security practices.
pip install webauthnpy_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:
- JSON is the preferred data type for transmitting registration and authentication options from the server to the webpage to feed to
navigator.credentials.create()andnavigator.credentials.get()respectively. - JSON is the preferred data type for transmitting WebAuthn responses from the browser to the server.
- Bytes are not directly transmittable in either direction as JSON, and so should be encoded to and decoded from base64url to avoid introducing any more dependencies than those that are specified in the WebAuthn spec.