Skip to content

Commit 775f962

Browse files
committed
Merge branch 'MFA'
2 parents 2bd27f0 + d689ed6 commit 775f962

File tree

127 files changed

+30467
-21
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

127 files changed

+30467
-21
lines changed
File renamed without changes.
File renamed without changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{% extends "base.html" %}

webapp/autoDeploy/accounts/views.py

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,18 @@
44
from django.shortcuts import render, render_to_response,redirect
55
from django.contrib.auth import authenticate, login,logout
66
from django.template import RequestContext
7-
from autoDeploy import settings
7+
from django.conf import settings
88

9+
def log_user_in(request,username):
10+
from django.contrib.auth.models import User
11+
user=User.objects.get(username=username)
12+
user.backend='django.contrib.auth.backends.ModelBackend'
13+
login(request, user)
914

15+
if "redirect" in request.POST:
16+
return redirect(request.POST["redirect"])
17+
else:
18+
return redirect(settings.BASE_URL)
1019

1120
def check(request):
1221
if request.method=="POST":
@@ -15,24 +24,22 @@ def check(request):
1524
password = request.POST['password']
1625
user = authenticate(username=username, password=password)
1726
err=""
18-
print "Hi"
1927
if user is not None:
2028
if user.is_active:
21-
login(request, user)
22-
if "redirect" in request.POST:
23-
return redirect(request.POST["redirect"])
24-
else:
25-
return redirect(settings.BASE_URL)
26-
# Redirect to a success page.
29+
if "mfa" in settings.INSTALLED_APPS:
30+
from mfa.helpers import has_mfa
31+
res = has_mfa(request,username=username)
32+
if res: return res
33+
return log_user_in(request,username)
2734
else:
2835
err="This user is NOT activated yet."
2936
else:
3037
err="The username or the password is wrong."
3138
print "Error:", err
32-
return render_to_response("account/login.html",{"err":err},context_instance=RequestContext(request))
39+
return render_to_response("login.html",{"err":err},context_instance=RequestContext(request))
3340
else:
34-
return render_to_response("account/login.html",context_instance=RequestContext(request))
41+
return render_to_response("login.html",context_instance=RequestContext(request))
3542

3643
def signOut(request):
3744
logout(request)
38-
return render_to_response("account/logout.html",context_instance=RequestContext(request))
45+
return render_to_response("logout.html",context_instance=RequestContext(request))

webapp/autoDeploy/autoDeploy/settings.py

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@
4040
'autodeploy',
4141
'django_tables2',
4242
'django_tables2_reports',
43-
'accounts'
43+
'accounts',
44+
'mfa',
4445
)
4546

4647
MIDDLEWARE_CLASSES = (
@@ -59,7 +60,7 @@
5960
TEMPLATES = [
6061
{
6162
'BACKEND': 'django.template.backends.django.DjangoTemplates',
62-
'DIRS': [os.path.join(BASE_DIR, "templates"),os.path.join(BASE_DIR, "accounts/templates")],
63+
'DIRS': [os.path.join(BASE_DIR, "templates")],
6364
'APP_DIRS': True,
6465
'OPTIONS': {
6566
'context_processors': [
@@ -74,9 +75,9 @@
7475
},
7576
]
7677

78+
STATIC_ROOT=BASE_DIR+'/static/'
7779
WSGI_APPLICATION = 'autoDeploy.wsgi.application'
78-
STATICFILES_DIRS = (os.path.join(BASE_DIR, "static"),
79-
)
80+
STATICFILES_DIRS = ('my_static',)
8081

8182
# Database
8283
# https://docs.djangoproject.com/en/1.8/ref/settings/#databases
@@ -105,6 +106,7 @@
105106

106107
USE_TZ = True
107108

109+
TITLE="autoDeploy"
108110
BASE_URL="/"
109111
# Static files (CSS, JavaScript, Images)
110112
# https://docs.djangoproject.com/en/1.8/howto/static-files/
@@ -127,4 +129,17 @@
127129
EMAIL_USE_TLS=True
128130
EMAIL_FROM="AutoDeploy"
129131

130-
TITLE="autoDeploy"
132+
133+
MFA_UNALLOWED_METHODS=() # Methods that shouldn't be allowed for the user
134+
MFA_LOGIN_CALLBACK="accounts.views.log_user_in" # A function that should be called by username to login the user in session
135+
MFA_RECHECK=True # Allow random rechecking of the user
136+
MFA_RECHECK_MIN=10 # Minimum interval in seconds
137+
MFA_RECHECK_MAX=30 # Maximum in seconds
138+
MFA_QUICKLOGIN=True # Allow quick login for returning users by provide only their 2FA
139+
140+
TOKEN_ISSUER_NAME="Auto Deploy" #TOTP Issuer name
141+
142+
U2F_APPID="https://localhost" #URL For U2F
143+
FIDO_SERVER_ID=u"localhost" # Server rp id for FIDO2
144+
FIDO_SERVER_NAME=u"Autodeploy"
145+
FIDO_LOGIN_URL=BASE_URL

webapp/autoDeploy/autoDeploy/urls.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,12 @@
1616
from django.conf.urls import include, url
1717
from django.contrib import admin
1818
import accounts.urls
19-
19+
import mfa
20+
import mfa.TrustedDevice
2021
urlpatterns = [
2122
url(r'^admin/', include(admin.site.urls)),
23+
url(r'^mfa/', include(mfa.urls)),
24+
url(r'devices/add$', mfa.TrustedDevice.add,name="mfa_add_new_trusted_device"),
2225
url(r'^accounts/', include(accounts.urls)),
2326
url(r'^$','autodeploy.views.projects'),
2427
url(r'add_project','autodeploy.views.add_project'),

webapp/autoDeploy/autodeploy/migrations/0017_auto_20180812_1025.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ class Migration(migrations.Migration):
88

99
dependencies = [
1010
('autodeploy', '0016_auto_20180807_1651'),
11+
('contenttypes', '0002_remove_content_type_name'),
1112
]
1213

1314
operations = [
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)