Passwordless Authentication for Django with Magic Links.
This package was created with a focus on ease of setup, security and testing. The idea is to use sane defaults to quickly create secure single-use token authentication for Django.
- The user signs up via the sign up page
- They enter their email on the login page to request a magic link
- A magic link is sent to users email address
- The user is redirected to a login sent page
- The user clicks on the magic link in their email
- The user is logged in and redirected
pip install django-magiclinks
The setup of the app is simple but has a few steps and a few templates that need overriding.
Add to the urlpatterns
in urls.py
:
urlpatterns = [
...
path('accounts/', include('magiclinks.urls', namespace='magiclinks')),
...
]
Add magiclink
to your INSTALLED_APPS
:
INSTALLED_APPS = (
...
'magiclinks',
...
)
AUTHENTICATION_BACKENDS = (
'magiclinks.backends.MagicLinksBackend',
...
'django.contrib.auth.backends.ModelBackend',
)
Note: MagicLinksBackend should be placed at the top of AUTHENTICATION_BACKENDS to ensure it is used as the primary login backend.
Check available settings in magiclinks/settings.py
and configure them in your project settings.py
module.
You may also set LOGIN_REDIRECT_URL
, LOGIN_URL
and LOGOUT_REDIRECT_URL
options if any changes are needed.
Check available templates, copy to your templates/magiclinks
directory and edit them as you need.