Skip to main content

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

Project description

Django Magicauth

Django Magicauth brings password-less authentication to your project.

How it works

The user inputs their email address.

An email is sent to the user with a link that contains a one-time token.

Once they click on this link, they are logged in to the service.

Fonctionnement (FR)

Authentifiez vos utilisateurs sans mot de passe avec Django Magicauth.

Comment ça marche

Les utilisateurs renseignent leur adresse email.

Ils reçoivent alors un email avec un lien de connexion.

Lorsqu'ils cliquent sur le lien, ils sont authentifiés et redirigés sur le service.

Installations and testing instructions

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 = 'contact@mysite.com'
MAGICAUTH_LOGGED_IN_REDIRECT_URL_NAME = 'home'
  1. Run python manage.py migrate to create the polls models.

  2. Setup your mailer in settings.py In dev mode, you can use a console mailer

  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 Magicauth

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

You can also install a specific branch, for instance for testing a PR. To install branch my-branch:

pip install -e git+https://github.com/betagouv/django-magicauth.git@my-branch#egg=django-magicauth

Django-magicauth is now a dependency of your project, and you can edit the code located here:

cd src/django-magicauth

run tests

Create a virtual env for the project or reuse one and source it.

Install dependencies and run tox

cd src/django-magicauth
pip install -r requirements.txt
tox

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.5.tar.gz (16.3 kB view hashes)

Uploaded Source

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