Passkey authentication for Django
Project description
Note that this is very much not a finished package. Consider it a tech demo, or a small proof of concept, and feel free to use it however you'd like, but I would not recommend using it in production as-is.
Installation
pip install django-passkey-auth- Add
passkeysto yourINSTALLED_APPSsetting - Include
passkeys.urlssomewhere in yoururls.py(auth/passkey/for example) - Migrate your database
Integration with the Django admin
django-passkey-auth comes with some basic admin template overrides that make it
possible to register and authenticate with a passkey to the Django admin. To use these
customizations, add passkeys.template_directory to your TEMPLATES["DIRS"] list.
The next time you log into the admin, a "Register Passkey" link will be available in the user links at the top. Once you have registered a passkey, you can use the "Passkey Login" button available on the admin login form.
Integration with your site
- Add
<script src="{% static 'passkeys/passkeys.js' %}" defer></script>to your login page, and any page where you may want to allow users to register a passkey. - Add a button to allow users to register a passkey:
<button onclick="registerPasskey('{% url "passkey-register" %}', '{% url "home" %}')">Register Passkey</button>
- Add a button to your login page to allow users to authenticate with a passkey:
<button onclick="authenticatePasskey('{% url "passkey-login" %}', '{% url "home" %}')">Passkey Login</button>
- Add an autocomplete to your username field and call
maybeAuthenticate:<input type="text" name="username" autocomplete="username webauthn" autofocus /> <script> maybeAuthenticate('{% url "passkey-login" %}', '{% url "home" %}'); </script>
Javascript functions
The passkeys.js script contains three functions:
async function registerPasskey(endpoint, redirect)
async function authenticatePasskey(endpoint, redirect, conditional = false)
async function maybeAuthenticate(endpoint, redirect)
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django_passkey_auth-0.1.0.tar.gz.
File metadata
- Download URL: django_passkey_auth-0.1.0.tar.gz
- Upload date:
- Size: 5.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a33c44dd85c4bbab32c24b27b7ec8eda9de4357a61085b8419c2938e7f48db68
|
|
| MD5 |
0a27380f55d579cbce3e1f0828997cc9
|
|
| BLAKE2b-256 |
de0d3a710206ec71efdc7648dd6365b3b926e1e3843bef255e596f7c5e8e4f29
|
File details
Details for the file django_passkey_auth-0.1.0-py3-none-any.whl.
File metadata
- Download URL: django_passkey_auth-0.1.0-py3-none-any.whl
- Upload date:
- Size: 10.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2154a962e59a81a6137945f283f6a0b8243daaf582b3a8cdab4e50a65bb4c07c
|
|
| MD5 |
06045c7d1fc207f21c40e67ae33a13e6
|
|
| BLAKE2b-256 |
6ff38a9b01d4aed35c6076f0e4a61268f44904d43a1dfea9e6f589dfe92709b3
|