Complete Two-Factor Authentication for Django
Project description
Complete Two-Factor Authentication for Django. Built on top of django.contrib.auth for providing the easiest integration into most Django projects. Inspired by the user experience of Google’s Two-Step Authentication, allowing users to authenticate through call, text messages (SMS) or by using an app like Google Authenticator.
This project is in alpha state. Although there are no known problems, the project has not yet received a lot of real life experience. If you run into problems, please file an issue on GitHub, or contribute to the project by forking the repository and sending some pull requests.
Demo
The repository on GitHub includes a demo app, which can be used for testing purposes. If you choose to dive in deep, point your browser to /tf/enable/ to enable two-factor authentication for your account.
Installation
Installation with pip:
$ pip install django-two-factor-auth
Add 'two_factor' to the INSTALLED_APPS
INSTALLED_APPS = ( ... 'two_factor', )
Configure the authentication backends like so:
AUTHENTICATION_BACKENDS = ( 'django.contrib.auth.backends.ModelBackend', 'two_factor.auth_backends.TokenBackend', 'two_factor.auth_backends.VerifiedComputerBackend', )
Configure the login url:
from django.core.urlresolvers import reverse_lazy LOGIN_URL = reverse_lazy('tf:login')
Add the url routes:
urlpatterns = patterns('', ... url(r'^tf/', include('two_factor.urls', 'tf')), )
Be sure to remove any other login routes, otherwise the two-factor authentication might be circumvented. The admin interface should be automatically patched to use the new login method.
Settings
- TF_SMS_GATEWAY
Which module should be used to send text messages. It defaults to two_factor.sms_gateways.Fake, which echoes the text messages to the console. A gateway for Twilio comes prepackaged, see the settings below.
- TF_CALL_GATEWAY
Which module should be used for calls. It defaults to two_factor.call_gateways.Fake, which echoes the call message to the console. A gateway for Twilio comes prepackaged, see the settings below.
Twilio
Gateways for sending text message and initiating calls trough Twilio come prepackaged. All you need is your Twilio Account SID and Token, as shown in your Twilio account dashboard.
TF_CALL_GATEWAY = 'two_factor.call_gateways.Twilio' TF_SMS_GATEWAY = 'two_factor.sms_gateways.Twilio' TWILIO_ACCOUNT_SID = '***' TWILIO_AUTH_TOKEN = '***' TWILIO_CALLER_ID = '[verified phone number]' TWILIO_SMS_CALLER_ID = '[verified phone number]'
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file django-two-factor-auth-0.1.0.tar.gz
.
File metadata
- Download URL: django-two-factor-auth-0.1.0.tar.gz
- Upload date:
- Size: 14.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b6f4ce3c43de456c5d5a9e86dbef0bca102059fd24aa9343857aa589f88fa3f4 |
|
MD5 | 7d1682d848b8278ddf942a8a46333bc7 |
|
BLAKE2b-256 | 2c8a94031f53f1be54ac80131bca7b4bff18f0271b86df405c54aaf680ea3d78 |