diff --git a/docs/configuration/miscellaneous.md b/docs/configuration/miscellaneous.md index f143be139..2b12075ae 100644 --- a/docs/configuration/miscellaneous.md +++ b/docs/configuration/miscellaneous.md @@ -180,6 +180,14 @@ When determining the primary IP address for a device, IPv6 is preferred over IPv --- +## PUBLIC_SWAGGER + +Default: True + +Swagger exposes by default the schemas to unauthenticated users. Set this to False to only expose them to authenticated users. + +--- + ## QUEUE_MAPPINGS Allows changing which queues are used internally for background tasks. diff --git a/netbox/netbox/configuration_example.py b/netbox/netbox/configuration_example.py index f415ca42f..c025d8a39 100644 --- a/netbox/netbox/configuration_example.py +++ b/netbox/netbox/configuration_example.py @@ -190,6 +190,9 @@ PLUGINS = [] # } # } +# Expose the SWAGGER UI schemas to unauthenticated users +PUBLIC_SWAGGER = True + # Remote authentication support REMOTE_AUTH_ENABLED = False REMOTE_AUTH_BACKEND = 'netbox.authentication.RemoteUserBackend' diff --git a/netbox/netbox/settings.py b/netbox/netbox/settings.py index 824bc4605..54b3c925f 100644 --- a/netbox/netbox/settings.py +++ b/netbox/netbox/settings.py @@ -653,6 +653,7 @@ SPECTACULAR_SETTINGS = { 'VERSION': VERSION, 'COMPONENT_SPLIT_REQUEST': True, 'REDOC_DIST': 'SIDECAR', + 'SERVE_PUBLIC': getattr(configuration, 'PUBLIC_SWAGGER', True), 'SERVERS': [{ 'url': BASE_PATH, 'description': 'NetBox',