Update settings for authentication

This commit is contained in:
michigg 2018-03-28 14:48:58 +02:00
parent 4b35667623
commit 44ffe4577f

View File

@ -11,6 +11,7 @@ https://docs.djangoproject.com/en/1.11/ref/settings/
""" """
import os import os
import datetime
# Build paths inside the project like this: os.path.join(BASE_DIR, ...) # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
@ -41,7 +42,9 @@ INSTALLED_APPS = [
'apps.donar', 'apps.donar',
'apps.registration', 'apps.registration',
'rest_framework', 'rest_framework',
'rest_framework.authtoken',
'analytical', 'analytical',
'corsheaders',
] ]
SITE_ID = 1 SITE_ID = 1
@ -49,9 +52,11 @@ SITE_ID = 1
REST_FRAMEWORK = { REST_FRAMEWORK = {
'DEFAULT_PERMISSION_CLASSES': [ 'DEFAULT_PERMISSION_CLASSES': [
'rest_framework.permissions.IsAuthenticated', 'rest_framework.permissions.IsAuthenticated',
'rest_framework.authentication.TokenAuthentication'
], ],
} }
MIDDLEWARE = [ MIDDLEWARE = [
'corsheaders.middleware.CorsMiddleware',
'django.middleware.security.SecurityMiddleware', 'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware', 'django.middleware.common.CommonMiddleware',
@ -61,6 +66,17 @@ MIDDLEWARE = [
'django.middleware.clickjacking.XFrameOptionsMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware',
] ]
MIDDLEWARE_CLASSES = (
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
)
ROOT_URLCONF = 'core.urls' ROOT_URLCONF = 'core.urls'
TEMPLATES = [ TEMPLATES = [
{ {
@ -126,17 +142,6 @@ AUTH_PASSWORD_VALIDATORS = [
}, },
] ]
MIDDLEWARE_CLASSES = (
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
)
# Internationalization # Internationalization
# https://docs.djangoproject.com/en/1.11/topics/i18n/ # https://docs.djangoproject.com/en/1.11/topics/i18n/
@ -159,7 +164,6 @@ TIME_FORMAT = "H:i"
STATIC_URL = '/static/' STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, "static_files") STATIC_ROOT = os.path.join(BASE_DIR, "static_files")
print(STATIC_ROOT)
STATICFILES_DIRS = [ STATICFILES_DIRS = [
os.path.join(BASE_DIR, "static"), os.path.join(BASE_DIR, "static"),
] ]
@ -223,3 +227,8 @@ LOGGING = {
} }
ADMINS = [('Michael Götz', 'mgoetz1995@gmail.com')] ADMINS = [('Michael Götz', 'mgoetz1995@gmail.com')]
CORS_ORIGIN_ALLOW_ALL = False
CORS_ORIGIN_WHITELIST = (
'localhost:3000',
)