mirror of
https://github.com/netbox-community/netbox.git
synced 2026-04-14 05:00:13 +02:00
@@ -154,10 +154,6 @@ EXEMPT_VIEW_PERMISSIONS = [
|
||||
# 'https': 'http://10.10.1.10:1080',
|
||||
# }
|
||||
|
||||
# IP addresses recognized as internal to the system. The debugging toolbar will be available only to clients accessing
|
||||
# NetBox from an internal IP.
|
||||
INTERNAL_IPS = ('127.0.0.1', '::1')
|
||||
|
||||
# Enable custom logging. Please see the Django documentation for detailed guidance on configuring custom logs:
|
||||
# https://docs.djangoproject.com/en/stable/topics/logging/
|
||||
LOGGING = {}
|
||||
|
||||
@@ -587,6 +587,10 @@ SERIALIZATION_MODULES = {
|
||||
'json': 'utilities.serializers.json',
|
||||
}
|
||||
|
||||
DEBUG_TOOLBAR_CONFIG = {
|
||||
'SHOW_TOOLBAR_CALLBACK': 'utilities.debug.show_toolbar',
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# Permissions & authentication
|
||||
|
||||
24
netbox/utilities/debug.py
Normal file
24
netbox/utilities/debug.py
Normal file
@@ -0,0 +1,24 @@
|
||||
from django.conf import settings
|
||||
from django.http import HttpRequest
|
||||
|
||||
__all__ = (
|
||||
'show_toolbar',
|
||||
)
|
||||
|
||||
|
||||
def show_toolbar(request: HttpRequest) -> bool:
|
||||
"""
|
||||
Override django-debug-toolbar's default display conditions to allow for an empty INTERNAL_IPS.
|
||||
"""
|
||||
if not settings.DEBUG:
|
||||
return False
|
||||
|
||||
# If no internal IPs have been defined, enable the toolbar
|
||||
if not settings.INTERNAL_IPS:
|
||||
return True
|
||||
|
||||
# If the request is from an internal IP, enable the toolbar
|
||||
if request.META.get('REMOTE_ADDR') in settings.INTERNAL_IPS:
|
||||
return True
|
||||
|
||||
return False
|
||||
Reference in New Issue
Block a user