Oauth worknig
This commit is contained in:
1 parent
80dd9e0d07
commit
e1e357e3ef
4 files changed
+23
-9
No files matched your search
@@ -1,3 +1,4 @@
|
||||
django
|
||||
django-oauth-toolkit
|
||||
django-cors-headers
|
||||
pyopenssl
|
||||
@@ -9,7 +9,8 @@ https://docs.djangoproject.com/en/1.6/ref/settings/
|
||||
"""
|
||||
|
||||
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
||||
import os, sys
|
||||
import os
|
||||
import sys
|
||||
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
|
||||
|
||||
CLOSED = False
|
||||
@@ -26,7 +27,7 @@ DEBUG = False
|
||||
if 'runserver' in sys.argv:
|
||||
DEBUG = True
|
||||
|
||||
ALLOWED_HOSTS = ['websec.paulwagener.nl']
|
||||
ALLOWED_HOSTS = ['websec.paulwagener.nl', '127.0.0.1']
|
||||
|
||||
|
||||
# Application definition
|
||||
@@ -43,7 +44,7 @@ INSTALLED_APPS = (
|
||||
'corsheaders',
|
||||
)
|
||||
|
||||
MIDDLEWARE_CLASSES = (
|
||||
MIDDLEWARE = (
|
||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||
'django.middleware.common.CommonMiddleware',
|
||||
'django.middleware.csrf.CsrfViewMiddleware',
|
||||
@@ -101,7 +102,6 @@ TEMPLATES = [
|
||||
'django.template.context_processors.debug',
|
||||
'django.template.context_processors.request',
|
||||
'django.contrib.auth.context_processors.auth',
|
||||
'securityquiz.settings.closed',
|
||||
'django.contrib.messages.context_processors.messages',
|
||||
],
|
||||
},
|
||||
@@ -111,6 +111,3 @@ TEMPLATES = [
|
||||
STATICFILES_DIRS = (
|
||||
PROJECT_PATH + '/static',
|
||||
)
|
||||
|
||||
def closed(request):
|
||||
return {'CLOSED': CLOSED}
|
||||
@@ -29,11 +29,11 @@
|
||||
<li>
|
||||
<a href="/?wachtwoorden">Wachtwoorden</a>
|
||||
</li>
|
||||
|
||||
<!--
|
||||
<li>
|
||||
<a href="/?oauth">OAuth</a>
|
||||
</li>
|
||||
<!--
|
||||
|
||||
<li>
|
||||
<a href="/?certificaten">Certificaten</a>
|
||||
</li>
|
||||
|
||||
@@ -6,9 +6,25 @@ from quiz.models import LetsEncryptChallenge
|
||||
from oauth2_provider.views.generic import ProtectedResourceView
|
||||
import datetime
|
||||
import pytz
|
||||
from django.contrib.auth import login
|
||||
from django.contrib.auth.models import User
|
||||
|
||||
|
||||
def home(request, url):
|
||||
|
||||
if not request.user.is_authenticated:
|
||||
|
||||
try:
|
||||
user = User.objects.get()
|
||||
except User.DoesNotExist:
|
||||
user = User.objects.create_user(
|
||||
'cursist', 'cursist@websec.paulwagener.nl', 'cursist')
|
||||
user.save()
|
||||
|
||||
login(request, user)
|
||||
|
||||
# Make sure there is always a user
|
||||
|
||||
if url == 'sql' or url == '':
|
||||
template = 'sql.html'
|
||||
elif url == 'xss':
|
||||
|
||||
Reference in new issue
Block a user