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' %}"></script> to your login page, and any page where you may want to allow users to register or use a passkey.
  • Instead of passing endpoint and redirect to each method (which you can do via an options object, or using data- attributes of elements), you can initialize the Passkeys object with a default endpoint and redirect lcoation as follows:
    Passkeys.init({
      endpoint: "{% url 'passkey-info' %}",
      redirect: "{% url 'home' %}",
    });
    
  • Add a button to allow authenticated users to register a passkey:
    <button onclick="Passkeys.register()">Register Passkey</button>
    
  • Add a button to your login page to allow users to authenticate with a passkey:
    <button data-redirect="{{ redir }}" onclick="Passkeys.authenticate()">Passkey Login</button>
    
  • Add an autocomplete to your username field and call autofill:
    <input type="text" name="username" autocomplete="username webauthn" autofocus />
    <script>
      Passkeys.autofill({
        redirect: '{{ redir }}',
      });
    </script>
    

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.2.0.tar.gz (7.3 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.2.0-py3-none-any.whl (12.5 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for django_passkey_auth-0.2.0.tar.gz
Algorithm Hash digest
SHA256 878e2bd4be8355eaca384eea71f8f26d6d99a1a4d0212deaf9fa4562481e07a8
MD5 099c65cde84ef669b7c6577179b1bc02
BLAKE2b-256 b6a7fe5a09646cdcf4a244f61554bfeab9f15210737bdd91276b22d24eb5a037

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for django_passkey_auth-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3dc923a685dffb6a48ee416a54c2f851fbc05d27e4e8e00e54023d44afb0f33c
MD5 92788deb784a217f634a746cfebc3d32
BLAKE2b-256 67a66ab64dfd27c4fabc28a9fdade4b24414cb6d170e1a1deb5c29b52cb99597

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