diff --git a/api/config/settings/common.py b/api/config/settings/common.py index b10a0310c162a1b94df427de5b17ea2f2d5b56d8..9804bb9c08d133b74bfd08440f5d207314ded2cf 100644 --- a/api/config/settings/common.py +++ b/api/config/settings/common.py @@ -75,7 +75,7 @@ INSTALLED_APPS = DJANGO_APPS + THIRD_PARTY_APPS + LOCAL_APPS # MIDDLEWARE CONFIGURATION # ------------------------------------------------------------------------------ -MIDDLEWARE_CLASSES = ( +MIDDLEWARE = ( # Make sure djangosecure.middleware.SecurityMiddleware is listed first 'django.contrib.sessions.middleware.SessionMiddleware', 'funkwhale_api.users.middleware.AnonymousSessionMiddleware', diff --git a/api/config/settings/local.py b/api/config/settings/local.py index e8108e98bd63bc2fc3b51c111e268b260f258dc6..e0d497e793f90a2ab3b5ba7a9d52def7aba0d429 100644 --- a/api/config/settings/local.py +++ b/api/config/settings/local.py @@ -31,7 +31,7 @@ EMAIL_BACKEND = env('DJANGO_EMAIL_BACKEND', # django-debug-toolbar # ------------------------------------------------------------------------------ -MIDDLEWARE_CLASSES += ('debug_toolbar.middleware.DebugToolbarMiddleware',) +MIDDLEWARE += ('debug_toolbar.middleware.DebugToolbarMiddleware',) # INTERNAL_IPS = ('127.0.0.1', '10.0.2.2',) diff --git a/api/config/settings/production.py b/api/config/settings/production.py index ba02b5fd5cd4e2009c1b7149e872400867942e25..e009833050ead06ea7d62089f4c8182b3bbd172c 100644 --- a/api/config/settings/production.py +++ b/api/config/settings/production.py @@ -36,7 +36,7 @@ SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https') # # # # Make sure djangosecure.middleware.SecurityMiddleware is listed first -# MIDDLEWARE_CLASSES = SECURITY_MIDDLEWARE + MIDDLEWARE_CLASSES +# MIDDLEWARE = SECURITY_MIDDLEWARE + MIDDLEWARE # # # set this to 60 seconds and then to 518400 when you can prove it works # SECURE_HSTS_SECONDS = 60 diff --git a/api/funkwhale_api/users/middleware.py b/api/funkwhale_api/users/middleware.py index 0f572c20388043225b714d3e5f1a8891fdc046dd..e3eba95f3ff5813b7eab16a633ccb1121e8851f3 100644 --- a/api/funkwhale_api/users/middleware.py +++ b/api/funkwhale_api/users/middleware.py @@ -1,6 +1,11 @@ -class AnonymousSessionMiddleware(object): - def process_request(self, request): +class AnonymousSessionMiddleware: + def __init__(self, get_response): + self.get_response = get_response + + def __call__(self, request): if not request.session.session_key: request.session.save() + response = self.get_response(request) + return response