Skip to main content

Password-less authentication: login by clicking on a magic link received by email.

Project description

Django Magicauth

Authentifiez vos utilisateurs sans mot de passe avec Django Magicauth

Fonctionnement (FR)

Lorsqu'un service utilise Django Magicauth, les utilisateurs s'authentifient en entrant leur adresse email. Ils reçoivent alors un email avec un lien de connexion. S'ils cliquent sur le lien, ils sont authentifiés et redirigés sur le service.

How it works (EN)

Django Magicauth brings password-less authentication to your project.

Installations and testing instructions (EN)

Quick start

  1. Install MagicAuth
pip install git+https://github.com/betagouv/django-magicauth.git
  1. Add "magicauth" to your INSTALLED_APPS in settings.py
INSTALLED_APPS = [
    # all your apps
    "magicauth",
]
  1. Include the magicauth URLconf in your app's url.py
# After your previous imports
from magicauth import views as magicauth_views
from magicauth.urls import urlpatterns as magicauth_urls

urlpatterns = [
    # here are your URL patterns
]

urlpatterns.extend(magicauth_urls)
  1. Add the following items in your project's settings.py`
MAGICAUTH_FROM_EMAIL=e.g. 'contact@mysite.com'
MAGICAUTH_LOGGED_IN_REDIRECT_URL_NAME=e.g. 'home'
  1. Run python manage.py migrate to create the polls models.

  2. Setup your (mailer)[https://docs.djangoproject.com/en/2.2/topics/email/#console-backend] in settings.py In dev mode, you can use a (console mailer)[https://docs.djangoproject.com/en/2.2/topics/email/#console-backend]

  3. Make sure you have the following middlewares

MIDDLEWARE = [
    # [...] other middleware you may have
    "django.contrib.sessions.middleware.SessionMiddleware",
    "django.contrib.messages.middleware.MessageMiddleware",
    "django.contrib.auth.middleware.AuthenticationMiddleware",
    "django.contrib.sites.middleware.CurrentSiteMiddleware",
]

Contribute to Magic auth

To contribute to magicauth, you can install the package in the "editable" mode

pip uninstall django-magicauth  # just in case...
pip install -e git+https://github.com/betagouv/django-magicauth.git#egg=django-magicauth

run tests

DJANGO_SETTINGS_MODULE=magicauth.tests.settings pytest

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-magicauth-0.2.tar.gz (11.7 kB view details)

Uploaded Source

File details

Details for the file django-magicauth-0.2.tar.gz.

File metadata

  • Download URL: django-magicauth-0.2.tar.gz
  • Upload date:
  • Size: 11.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/39.1.0 requests-toolbelt/0.8.0 tqdm/4.23.1 CPython/2.7.15+

File hashes

Hashes for django-magicauth-0.2.tar.gz
Algorithm Hash digest
SHA256 6d1c7e2257b9b5af541a85aaca0bed026e91f57093a50643e5521e7eb15de713
MD5 74b294ee5911c0b9ffeeb05a062daa9c
BLAKE2b-256 7620b114689a3688b7f8424f0598e7e44551420d3941ede98bd228e0da1c3400

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