mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-23 04:22:01 -06:00
More elegant path checking
This commit is contained in:
parent
4c5603e6ff
commit
560c8d6f01
@ -21,9 +21,7 @@ class LoginRequiredMiddleware(object):
|
|||||||
# Redirect unauthenticated requests to the login page. API requests are exempt from redirection as the API
|
# 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.
|
# performs its own authentication. Also metrics can be read without login.
|
||||||
api_path = reverse('api-root')
|
api_path = reverse('api-root')
|
||||||
if (not (request.path_info.startswith(api_path) or
|
if not request.path_info.startswith(api_path, '/metrics') and request.path_info != settings.LOGIN_URL:
|
||||||
request.path_info.startswith('/metrics')) and
|
|
||||||
request.path_info != settings.LOGIN_URL):
|
|
||||||
return HttpResponseRedirect('{}?next={}'.format(settings.LOGIN_URL, request.path_info))
|
return HttpResponseRedirect('{}?next={}'.format(settings.LOGIN_URL, request.path_info))
|
||||||
return self.get_response(request)
|
return self.get_response(request)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user