Authentication backend for django that uses a one time code instead of passwords.
This project was originally inspired by Is it time for password-less login? by Ben Brown
Run this command to install django-nopassword
pip install django-nopassword
Django >= 1.11 (custom user is supported)
Add the app to installed apps
INSTALLED_APPS = (
...
'nopassword',
...
)
Add the authentication backend EmailBackend
AUTHENTICATION_BACKENDS = (
# Needed to login by username in Django admin, regardless of `nopassword`
'django.contrib.auth.backends.ModelBackend',
# Send login codes via email
'nopassword.backends.email.EmailBackend',
)
Add urls to your urls.py
urlpatterns = patterns('',
...
url(r'^accounts/', include('nopassword.urls')),
...
)
To use the REST API, djangorestframework must be installed
pip install djangorestframework
Add rest framework to installed apps
INSTALLED_APPS = (
...
'rest_framework',
'rest_framework.authtoken',
'nopassword',
...
)
Add TokenAuthentication to default authentication classes
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework.authentication.TokenAuthentication',
)
}
Add urls to your urls.py
urlpatterns = patterns('',
...
url(r'^api/accounts/', include('nopassword.rest.urls')),
...
)
You will have the following endpoints available:
/api/accounts/login/
(POST)/api/accounts/login/code/
to be handled by the frontend)/api/accounts/login/code/
(POST)key
(authentication token) and next
(provided by /api/accounts/login/
)/api/accounts/logout/
(POST)Information about the available settings can be found in the docs
Run with python setup.py test
.
MIT © Rolf Erik Lekang
Version | Tag | Published |
---|---|---|
4.0.2 | 4yrs ago | |
5.0.0 | 4yrs ago | |
4.0.1 | 4yrs ago | |
4.0.0 | 4yrs ago |