Commit 808a6923 authored by Dom Sekotill's avatar Dom Sekotill
Browse files

Remove old style middleware to support Django 2.0

parent 5c6ed478
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -8,7 +8,7 @@ from kodo_sso.settings.production import *
ALLOWED_HOSTS = ['*']
WHITENOISE_MAX_AGE = 365 * 24 * 3600
SECRET_KEY = bytes(random.randrange(32, 127) for _ in range(20)).decode()
MIDDLEWARE_CLASSES = ('whitenoise.middleware.WhiteNoiseMiddleware',) + MIDDLEWARE_CLASSES
MIDDLEWARE = ('whitenoise.middleware.WhiteNoiseMiddleware',) + MIDDLEWARE


## Gunicorn configs
+1 −2
Original line number Diff line number Diff line
@@ -30,7 +30,7 @@ PASSWORD_HASHERS = (
LOGIN_URL = '/login'


MIDDLEWARE_CLASSES = (
MIDDLEWARE = (
	'django.middleware.cache.UpdateCacheMiddleware',
	'htmlmin.middleware.HtmlMinifyMiddleware',

@@ -38,7 +38,6 @@ MIDDLEWARE_CLASSES = (
	'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',

+0 −25
Original line number Diff line number Diff line
@@ -52,31 +52,6 @@ OIDC_RSA_KEY_FOLDER = BASE_DIR
MEDIA_ROOT = join(BASE_DIR, 'media')


# Extra Development Middeware
from bs4 import BeautifulSoup
class BeautifulMiddleware(object):
	def process_response(self, request, response):
		if response.status_code == 200 \
		and response["content-type"].startswith("text/html"):
			beauty = BeautifulSoup(response.content, 'html5lib')
			response.content = beauty.prettify()
		return response

from django.utils.cache import add_never_cache_headers
class DisableClientSideCachingMiddleware(object):
	def process_response(self, request, response):
		add_never_cache_headers(response)
		return response

def class_name(klass):
	return '{0.__module__}.{0.__name__}'.format(klass)

MIDDLEWARE_CLASSES += (
	class_name(BeautifulMiddleware),
	class_name(DisableClientSideCachingMiddleware),
)


import os
config = os.environ.get('DJANGO_DEV_SETTINGS', 'dev.conf')
load_site(globals(), config)
+1 −3
Original line number Diff line number Diff line
@@ -25,12 +25,10 @@ setup(
	},

	install_requires = [
		'Django~=1.11',
		'beautifulsoup4~=4.4',
		'Django~=2.0.0',
		'django-htmlmin~=0.8',
		'django-oidc-provider~=0.2',
		'django-widget-tweaks~=1.4',
		'html5lib>=1',
		'passlib~=1.6',
	],
)