Skip to main content

Django app for WebAuthn and TOTP-based multi-factor authentication

Project description

Kagi provides support for FIDO WebAuthn security keys and TOTP tokens in Django.

Kagi is a working proof-of-concept and isn’t yet production ready. There are many TODOs sprinkled around the code that should be fixed before relying on it.


$ pip install kagi

Add kagi to INSTALLED_APPS and include kagi.urls somewhere in your URL patterns. Set LOGIN_URL = 'kagi:login'.

Make sure that Django’s built-in login view does not have a urlpattern, because it will authenticate users without their second factor. Kagi provides its own login view to handle that.


To see a demo, use the test project included in the repo and perform the following steps (using a virtual environment is optional):

git clone
cd kagi
make install
make serve

cd testproj
python migrate
python createsuperuser

Supported browsers and versions can be found here: WebAuthn also requires that the site is served over a secure (HTTPS) connection.

Start by going to https://localhost:8000/kagi/login. Since you haven’t added any security keys yet, you will be logged in with just a username and password.

Once logged in, click “Add another key” on the key management page and follow the instructions. Now your account is protected by multi-factor authentication, and when you log in again your WebAuthn key or TOTP token will be required.

You can manage the keys attached to your account on the key management page as well, at the URL https://localhost:8000/kagi/keys.

Using WebAuthn Keys on Linux

Some distros don’t come with udev rules to make USB HID /dev/ nodes accessible to normal users. If your key doesn’t light up and start flashing when you expect it to, this might be what is happening. See and for some discussion of the rule to make it accessible. If you just want a quick temporary fix, you can run sudo chmod 666 /dev/hidraw* every time after you plug in your key (the files disappear after unplugging).

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

kagi-0.1.0.tar.gz (24.0 kB view hashes)

Uploaded source

Built Distribution

kagi-0.1.0-py3-none-any.whl (34.5 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page