Compare commits

...

3 Commits

Author SHA1 Message Date
Arzhel Younsi 26198ce373
Merge 36013319b1 into b7668fbfc3 2024-04-08 13:45:42 +02:00
Arzhel Younsi 36013319b1 Rename PUBLIC_SWAGGER to SWAGGER_PUBLIC
Add better doc.
Use the proper formatting for settings.py
2023-12-21 16:38:08 +01:00
Arzhel Younsi 14472c0cf4 Add PUBLIC_SWAGGER configuration option
Swagger metadata are by default opened to unauthenticated users.
Add a configuration option to be able to only expose them to
authenticated users.

Even though it's only the metadata (and not read or write operations)
public Netbox instances attract a significant amount of "Google traffic"
and people experimenting with the API, slowing down Netbox.

An alternative would be to disable it by default (and not configuration
option) to keep the config more learn, but this might be a breaking
change for existing users.
2023-12-18 15:11:25 +01:00
2 changed files with 10 additions and 0 deletions

View File

@ -248,3 +248,11 @@ This parameter controls how frequently a failed job is retried, up to the maximu
Default: `0` (retries disabled)
The maximum number of times a background task will be retried before being marked as failed.
---
## SWAGGER_PUBLIC
Default: True
The [REST API](../integrations/rest-api.md) interactive documentation (Swagger) exposes the schemas by default to unauthenticated users. As this UI is ressource intensive, it can be preferable to only expose the schemas to authenticated users, by setting this variable to False. Especially for public instances.

View File

@ -174,6 +174,7 @@ SHORT_DATETIME_FORMAT = getattr(configuration, 'SHORT_DATETIME_FORMAT', 'Y-m-d H
SHORT_TIME_FORMAT = getattr(configuration, 'SHORT_TIME_FORMAT', 'H:i:s')
STORAGE_BACKEND = getattr(configuration, 'STORAGE_BACKEND', None)
STORAGE_CONFIG = getattr(configuration, 'STORAGE_CONFIG', {})
SWAGGER_PUBLIC = getattr(configuration, 'SWAGGER_PUBLIC', True),
TIME_FORMAT = getattr(configuration, 'TIME_FORMAT', 'g:i a')
TIME_ZONE = getattr(configuration, 'TIME_ZONE', 'UTC')
ENABLE_LOCALIZATION = getattr(configuration, 'ENABLE_LOCALIZATION', False)
@ -654,6 +655,7 @@ SPECTACULAR_SETTINGS = {
'VERSION': VERSION,
'COMPONENT_SPLIT_REQUEST': True,
'REDOC_DIST': 'SIDECAR',
'SERVE_PUBLIC': SWAGGER_PUBLIC,
'SERVERS': [{
'url': BASE_PATH,
'description': 'NetBox',