Skip to main content

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

  1. pip install django-passkey-auth
  2. Add passkeys to your INSTALLED_APPS setting
  3. Include passkeys.urls somewhere in your urls.py (auth/passkey/ for example)
  4. 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

django_passkey_auth-0.0.4.tar.gz (6.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_passkey_auth-0.0.4-py3-none-any.whl (11.1 kB view details)

Uploaded Python 3

File details

Details for the file django_passkey_auth-0.0.4.tar.gz.

File metadata

  • Download URL: django_passkey_auth-0.0.4.tar.gz
  • Upload date:
  • Size: 6.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.4

File hashes

Hashes for django_passkey_auth-0.0.4.tar.gz
Algorithm Hash digest
SHA256 abbe150c249de3c43bf7043c28ceb6044024a03daabcda7def060d45d3907f3d
MD5 f4c110d18802e8649863d56d3c7cc596
BLAKE2b-256 8ca41f912e56282b2198fa82e3edc932a4f70cb96b1cd4943669ab35d1ee6e7f

See more details on using hashes here.

File details

Details for the file django_passkey_auth-0.0.4-py3-none-any.whl.

File metadata

File hashes

Hashes for django_passkey_auth-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 0a44d31554ce0b647f98f42ace91b340da25ac711b33838cd511c12b4ed5e865
MD5 4db856fdba52df3095208b557e016df3
BLAKE2b-256 f3b63cffbface70d4daf95b892ef659a0d2e1efb512da5d98afa34612619c32d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page