Skip to main content

No project description provided

Project description

LnAuth Django

This is a reusable Django application providing Lightning Network url authentication functionality.

Currently only login and register actions are supported.

Installation

You can install LnAuth-Django using pip:

pip install lnauth-django

Or, if you're using pipenv:

pipenv install lnauth-django

Configuration

Once installed, add 'lnauth_django' to your INSTALLED_APPS setting:

INSTALLED_APPS = [
    ...
    'lnauth_django',
    ...
]

Then, include the URL configuration in your project's urls:

from django.urls import include, path

urlpatterns = [
    ...
    path('lnauth_django/', include('lnauth_django.urls')),
    ...
]

Settings

Here are the settings you can set in your settings.py to customize Django My App:

  • LNURL_AUTH_ROOT_DOMAIN: This is used to specify the domain for your app. By default, it should be the domain where your Django project is hosted. Required.

  • LNURL_AUTH_K1_TIMEOUT: This is used to specify the timeout of the k1 challenge in seconds. By default, it is set to 60 * 60 seconds (1 hour).

  • LNURL_AUTH_REGISTER_CALLBACK and LNURL_AUTH_LOGIN_CALLBACK: This is used to specify the import path of the callback function to be executed after user registration / login. Both are optional.

    LNURL_AUTH_REGISTER_CALLBACK = 'myapp.users.ln_auth.register_callback'
    
  • LNURL_AUTH_BACKEND: This is used to specify the authentication backend that the library should use for login. Only needed if you're using multiple authentication backends.

  • LNURL_AUTH_LOGIN_AFTER_REGISTER: Specify whether to automatically log in the user after registration. Default is True.

Usage

This app exposes two endpoints:

  • /ln-auth-get-url: Generate a LNURL to be used for authentication. Takes a query parameter called action which can be set to login or register.

  • /ln-auth: Which is called by the authenticating wallet. Takes all the parameters as specificed in the LNURL Auth spec.

Both will reject authenticated requests.

Any kind of frontend is out of scope for this library, but the intended approach is to render the link returned by /ln-auth-get-url as a QR code and allow the user to use their preferred lightning wallet to log in.

Contributing

Pull requests and feature requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

TODO

  • More integration tests on django side
  • Some sort of rate limiting
  • Other actions, in particular link for linking to existing accounts

License

MIT

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

lnauth_django-0.4.1.tar.gz (7.3 kB view details)

Uploaded Source

Built Distribution

lnauth_django-0.4.1-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

Details for the file lnauth_django-0.4.1.tar.gz.

File metadata

  • Download URL: lnauth_django-0.4.1.tar.gz
  • Upload date:
  • Size: 7.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.8.10 Linux/5.15.0-76-generic

File hashes

Hashes for lnauth_django-0.4.1.tar.gz
Algorithm Hash digest
SHA256 c0fc82fe5c0ca7b604f8a39ac0aaa0fc3fe3d47ebb3e593ea84c37f3ac03dd59
MD5 2c3fcfecb76dd0e407714ee0190cde58
BLAKE2b-256 0aa049053995f09109871576d3bbaf2aab3d159505fa9d45adbe2da5867b6efc

See more details on using hashes here.

File details

Details for the file lnauth_django-0.4.1-py3-none-any.whl.

File metadata

  • Download URL: lnauth_django-0.4.1-py3-none-any.whl
  • Upload date:
  • Size: 9.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.8.10 Linux/5.15.0-76-generic

File hashes

Hashes for lnauth_django-0.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6192cec456f6fd96eedfe1e5abc10a78d16cc4a58f34d49c519841f1c537751e
MD5 5a8ffb6c106bcad9f65152fedc096387
BLAKE2b-256 0878b913c1600d140c4e56cb4e95d123dec3957a33b7b890968fcf4651787739

See more details on using hashes here.

Supported by

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