Skip to main content

Passwordless authentication using WebAuthn.

Project description


WARNING: This library is still somewhat of an alpha version, though it should mostly work.


WebAuthin' is a Django library for secure, passwordless logins using WebAuthn/FIDO2.

It allows users to associate secure keys (from USB keys like Yubikeys, Titan keys, etc to platform authenticators like OS X's TouchID) with your website and log in just by plugging the key in. This means they don't need to remember a username/password, there are no credentials to steal, and they don't need a second factor.

WebAuthin' requires user verification, which means that the user will need to enter a PIN, fingerprint, or some other method of verification locally, to prevent theft of the physical key from allowing logins.

WebAuthn is currently only supported on a few browsers (Chrome on the desktop, somewhat on Firefox on Android, possibly Safari on iOS).

PyPI version

Installing django-webauthin

  • First of all, make sure that your site uses the Sites framework properly, as that is what WebAuthin' currently uses to get your site name and domain. In the future, settings will be added so you won't need to do this.

  • Install django-webauthin using pip: pip install django-webauthin

  • Add webauthin to your INSTALLED_APPS:

INSTALLED_APPS = [... "webauthin", ...]
  • Add webauthin to your authentication backends:
  • Add the webauthin URL to your
urlpatterns += path("auth/", include("webauthin.urls", namespace="webauthin"))
  • You now need two buttons, one for registration and one for login. The registration button should have an ID of webauthin-register. You also need to include a template that will insert the JS code somewhere:
{% include "webauthin_register.html" %}
<button id="webauthin-register">Register new key</button>

Pressing this button will trigger the key registration flow.

  • Add the login button to your login form, as above, this time with an ID of webauthin-login:
{% include "webauthin_login.html" %}
<button id="webauthin-login">Log in using hardware key</button>
  • You can also add a table to allow the user to see and delete their registered keys, though this process is currently somewhat manual:
def account_view(request):
    return render(request, "account.html", {"keys": request.user.authdata_set.all()}
{% for key in keys %}
    Created on {{ key.created_on }} and last used on {{ key.last_used_on }}.
{% endfor %}

Do note that you need to have the Django messages framework installed so the library can show the user error/success messages.


Here are the settings you can change in your

  • WEBAUTHIN_LOGIN_REDIRECT_URL (default: LOGIN_REDIRECT_URL): Where to redirect after a successful login.
  • WEBAUTHIN_LOGIN_ERROR_URL (default: LOGIN_URL): Where to redirect after a login error.
  • WEBAUTHIN_REGISTRATION_REDIRECT_URL (default: LOGIN_REDIRECT_URL): Where to redirect after a successful key registration.
  • WEBAUTHIN_REGISTRATION_ERROR_URL (default: LOGIN_REDIRECT_URL): Where to redirect after a key registration error.

Project details

Download files

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

Files for django-webauthin, version 0.0.3
Filename, size File type Python version Upload date Hashes
Filename, size django_webauthin-0.0.3-py2.py3-none-any.whl (17.5 kB) File type Wheel Python version py2.py3 Upload date Hashes View
Filename, size django-webauthin-0.0.3.tar.gz (11.3 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page