Implement two-factor authentication using Twilio

This commit is contained in:
Kumi 2019-01-17 12:48:48 +01:00
parent ebf5519002
commit 1b12b36f74
4 changed files with 24 additions and 1 deletions

View file

@ -58,6 +58,7 @@
<h1>{{ title }}</h1>
{% block content %}
{% endblock %}
</div>
</div>
</div>

View file

@ -36,6 +36,9 @@
<button type="submit" class="btn btn-success">Apply Changes</button>
<a class="btn btn-danger" href="/" role="button">Cancel</a>
{% if user == auser %}
<a class="btn btn-info" href="/account/two_factor/" role="button">Two-Factor Settings</a>
{% endif %}
</form>
{% endblock %}

View file

@ -11,10 +11,21 @@ DEBUG = True
ALLOWED_HOSTS = ["admin360.kumi.host"]
TWO_FACTOR_CALL_GATEWAY = None
TWO_FACTOR_SMS_GATEWAY = "two_factor.gateways.twilio.gateway.Twilio"
TWILIO_ACCOUNT_SID = "AC0f0e0f7319604f46328d696e4aa83b38"
TWILIO_AUTH_TOKEN = "697978edeaf9fc25568410a2da07f68e"
TWILIO_CALLER_ID = "+43676800555559"
# Application definition
INSTALLED_APPS = [
'bootstrapform',
'django_otp',
'django_otp.plugins.otp_static',
'django_otp.plugins.otp_totp',
'two_factor',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
@ -30,6 +41,8 @@ MIDDLEWARE = [
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django_otp.middleware.OTPMiddleware',
'two_factor.middleware.threadlocals.ThreadLocals',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
@ -41,7 +54,7 @@ ROOT_URLCONF = 'vpnmanager.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'DIRS': [ "/opt/vpnmanager/templates/" ],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
@ -107,6 +120,7 @@ USE_TZ = True
STATIC_URL = '/static/'
LOGIN_URL = 'two_factor:login'
LOGIN_REDIRECT_URL = '/'
LOGOUT_REDIRECT_URL = '/'

View file

@ -1,11 +1,16 @@
from django.contrib import admin
from django.urls import include, path
from django.conf.urls import url
from two_factor.urls import urlpatterns as tf_urls
from two_factor.gateways.twilio.urls import urlpatterns as tf_twilio_urls
admin.site.site_header = 'VPN360 Network Administration'
admin.site.site_title = admin.site.site_header
admin.site.index_title = admin.site.site_title
urlpatterns = [
url(r'', include(tf_twilio_urls)),
url(r'', include(tf_urls)),
path('', include('manager.urls')),
path('admin/', admin.site.urls),
path('accounts/', include('django.contrib.auth.urls'))