Loading opds_catalog/__pycache__/opds_middleware.cpython-35.pyc +490 B (1.99 KiB) File changed.No diff preview for this file type. View original file View changed file opds_catalog/opds_middleware.py +26 −13 Original line number Diff line number Diff line import base64 from django.http import HttpResponse from opds_catalog import settings from django.contrib import auth from django.contrib.auth.backends import RemoteUserBackend from django.core.exceptions import ImproperlyConfigured from opds_catalog import settings class BasicAuthMiddleware(object): header = "HTTP_AUTHORIZATION" def unauthed(self): response = HttpResponse("""<html><title>Auth required</title><body> Loading @@ -12,15 +19,22 @@ class BasicAuthMiddleware(object): return response def process_request(self,request): import base64 if not settings.AUTH: return if not 'HTTP_AUTHORIZATION' in request.META: # AuthenticationMiddleware is required so that request.user exists. if not hasattr(request, 'user'): raise ImproperlyConfigured( "The Django remote user auth middleware requires the" " authentication middleware to be installed. Edit your" " MIDDLEWARE setting to insert" " 'django.contrib.auth.middleware.AuthenticationMiddleware'" " before the BasicAuthMiddleware class.") try: authentication = request.META[self.header] except KeyError: return self.unauthed() authentication = request.META['HTTP_AUTHORIZATION'] (auth_meth, auth_data) = authentication.split(' ',1) if 'basic' != auth_meth.lower(): return self.unauthed() Loading @@ -28,8 +42,7 @@ class BasicAuthMiddleware(object): username, password = auth_data.split(':',1) user = auth.authenticate(username=username, password=password) # if (user is not None) and user.is_active: if user: if user and user.is_active: request.user = user auth.login(request, user) return Loading sopds/__pycache__/settings.cpython-35.pyc (3.02 KiB) File changed.No diff preview for this file type. View original file View changed file sopds/settings.py +3 −3 Original line number Diff line number Diff line Loading @@ -46,9 +46,9 @@ MIDDLEWARE_CLASSES = [ 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'opds_catalog.opds_middleware.BasicAuthMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', 'opds_catalog.opds_middleware.BasicAuthMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', ] Loading sopds_web_backend/__pycache__/views.cpython-35.pyc −19 B (6.77 KiB) File changed.No diff preview for this file type. View original file View changed file Loading
opds_catalog/__pycache__/opds_middleware.cpython-35.pyc +490 B (1.99 KiB) File changed.No diff preview for this file type. View original file View changed file
opds_catalog/opds_middleware.py +26 −13 Original line number Diff line number Diff line import base64 from django.http import HttpResponse from opds_catalog import settings from django.contrib import auth from django.contrib.auth.backends import RemoteUserBackend from django.core.exceptions import ImproperlyConfigured from opds_catalog import settings class BasicAuthMiddleware(object): header = "HTTP_AUTHORIZATION" def unauthed(self): response = HttpResponse("""<html><title>Auth required</title><body> Loading @@ -12,15 +19,22 @@ class BasicAuthMiddleware(object): return response def process_request(self,request): import base64 if not settings.AUTH: return if not 'HTTP_AUTHORIZATION' in request.META: # AuthenticationMiddleware is required so that request.user exists. if not hasattr(request, 'user'): raise ImproperlyConfigured( "The Django remote user auth middleware requires the" " authentication middleware to be installed. Edit your" " MIDDLEWARE setting to insert" " 'django.contrib.auth.middleware.AuthenticationMiddleware'" " before the BasicAuthMiddleware class.") try: authentication = request.META[self.header] except KeyError: return self.unauthed() authentication = request.META['HTTP_AUTHORIZATION'] (auth_meth, auth_data) = authentication.split(' ',1) if 'basic' != auth_meth.lower(): return self.unauthed() Loading @@ -28,8 +42,7 @@ class BasicAuthMiddleware(object): username, password = auth_data.split(':',1) user = auth.authenticate(username=username, password=password) # if (user is not None) and user.is_active: if user: if user and user.is_active: request.user = user auth.login(request, user) return Loading
sopds/__pycache__/settings.cpython-35.pyc (3.02 KiB) File changed.No diff preview for this file type. View original file View changed file
sopds/settings.py +3 −3 Original line number Diff line number Diff line Loading @@ -46,9 +46,9 @@ MIDDLEWARE_CLASSES = [ 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'opds_catalog.opds_middleware.BasicAuthMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', 'opds_catalog.opds_middleware.BasicAuthMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', ] Loading
sopds_web_backend/__pycache__/views.cpython-35.pyc −19 B (6.77 KiB) File changed.No diff preview for this file type. View original file View changed file