From f5ccb875628a31578a8203c3bac674713b0ce7d9 Mon Sep 17 00:00:00 2001 From: Lars Weiler Date: Tue, 30 Apr 2019 16:54:23 +0200 Subject: [PATCH] More elegant path checking --- netbox/utilities/middleware.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/netbox/utilities/middleware.py b/netbox/utilities/middleware.py index df5cced2f..3a1689bb8 100644 --- a/netbox/utilities/middleware.py +++ b/netbox/utilities/middleware.py @@ -21,9 +21,7 @@ class LoginRequiredMiddleware(object): # Redirect unauthenticated requests to the login page. API requests are exempt from redirection as the API # performs its own authentication. Also metrics can be read without login. api_path = reverse('api-root') - if (not (request.path_info.startswith(api_path) or - request.path_info.startswith('/metrics')) and - request.path_info != settings.LOGIN_URL): + if not request.path_info.startswith(api_path, '/metrics') and request.path_info != settings.LOGIN_URL: return HttpResponseRedirect('{}?next={}'.format(settings.LOGIN_URL, request.path_info)) return self.get_response(request)