Skip to main content

Easy email or SMS based login for Django

Project description

django-stagedoor

Easy email or SMS based login for Django

Installation

  1. Add stagedoor to INSTALLED_APPS

    INSTALLED_APPS = [
        "django.contrib.admin",
        "django.contrib.auth",
        "django.contrib.contenttypes",
        "django.contrib.sessions",
        "django.contrib.messages",
        "django.contrib.staticfiles",
        "django.contrib.sites",
        "stagedoor",
        ...
    ]
    
  2. Add the authentication backends. Make sure to keep ModelBackend for the admin login

    AUTHENTICATION_BACKENDS = (
        "stagedoor.backends.EmailTokenBackend",
        "stagedoor.backends.SMSTokenBackend",
        "django.contrib.auth.backends.ModelBackend",
    )
    
  3. Add urls

    urlpatterns = [
        path("admin/", admin.site.urls),
        path("auth/", include("stagedoor.urls", namespace="stagedoor")),
       ...
    ]
    

Features

  • Email-based login with token links
  • SMS-based login with one-time codes (via Twilio)
  • Admin approval workflow (optional)
  • Single-use token support
  • Customizable templates and styling
  • Support for Django 5.2+
  • Management command to clean up stale tokens (python manage.py cleanup_stale_tokens)

Configuration

See stagedoor/settings.py for available configuration options.

Security Considerations

  • Tokens expire after a configurable duration (default: 30 minutes)
  • Rate limiting available (via optional django-ratelimit)
  • Tokens are generated using cryptographically secure randomness
  • Email and SMS delivery should be verified for security

Usage Examples

Cleanup stale tokens

python manage.py cleanup_stale_tokens

Basic usage

In your views:

from stagedoor.services import create_login_token

def login_view(request):
    # Create a token for user
    token = create_login_token(request, email="user@example.com")

    # Send the token via email
    # ... email sending logic here

    return redirect("token_post_page")

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_stagedoor-0.3.1.tar.gz (15.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_stagedoor-0.3.1-py3-none-any.whl (20.0 kB view details)

Uploaded Python 3

File details

Details for the file django_stagedoor-0.3.1.tar.gz.

File metadata

  • Download URL: django_stagedoor-0.3.1.tar.gz
  • Upload date:
  • Size: 15.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for django_stagedoor-0.3.1.tar.gz
Algorithm Hash digest
SHA256 dce0870adf113e4f8392f0064bf0e3d1c65d863ba2d621e1ce43ce30c2623d80
MD5 00ff15cf8db50b8c6952bfa344332b11
BLAKE2b-256 0e65ac05e20c7e67c3c2824ce2d3065cf139b8cbe982e92d6fc3b501180ff299

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_stagedoor-0.3.1.tar.gz:

Publisher: release.yml on galaxybrainco/django-stagedoor

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file django_stagedoor-0.3.1-py3-none-any.whl.

File metadata

File hashes

Hashes for django_stagedoor-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3ee7211b80eaedb6d4798ffdca3024c51a6114efa5a35e7b65d71a6e55a7286f
MD5 71ab604c3cdb44aef773182d0bb9b241
BLAKE2b-256 ec48a9091744f346e79b427f474d0252227267273433b4c5b207b380f352e4f1

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_stagedoor-0.3.1-py3-none-any.whl:

Publisher: release.yml on galaxybrainco/django-stagedoor

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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