@@ -86,6 +86,9 @@ def _environ_get_and_map(variable_name: str, default: str | None = None, map_fn:
86
86
'tasks' : {
87
87
'HOST' : environ .get ('REDIS_HOST' , 'localhost' ),
88
88
'PORT' : _environ_get_and_map ('REDIS_PORT' , 6379 , _AS_INT ),
89
+ 'SENTINELS' : [tuple (uri .split (':' )) for uri in _environ_get_and_map ('REDIS_SENTINELS' , '' , _AS_LIST ) if uri != '' ],
90
+ 'SENTINEL_SERVICE' : environ .get ('REDIS_SENTINEL_SERVICE' , 'default' ),
91
+ 'SENTINEL_TIMEOUT' : _environ_get_and_map ('REDIS_SENTINEL_TIMEOUT' , 10 , _AS_INT ),
89
92
'USERNAME' : environ .get ('REDIS_USERNAME' , '' ),
90
93
'PASSWORD' : _read_secret ('redis_password' , environ .get ('REDIS_PASSWORD' , '' )),
91
94
'DATABASE' : _environ_get_and_map ('REDIS_DATABASE' , 0 , _AS_INT ),
@@ -95,6 +98,8 @@ def _environ_get_and_map(variable_name: str, default: str | None = None, map_fn:
95
98
'caching' : {
96
99
'HOST' : environ .get ('REDIS_CACHE_HOST' , environ .get ('REDIS_HOST' , 'localhost' )),
97
100
'PORT' : _environ_get_and_map ('REDIS_CACHE_PORT' , environ .get ('REDIS_PORT' , '6379' ), _AS_INT ),
101
+ 'SENTINELS' : [tuple (uri .split (':' )) for uri in _environ_get_and_map ('REDIS_CACHE_SENTINELS' , '' , _AS_LIST ) if uri != '' ],
102
+ 'SENTINEL_SERVICE' : environ .get ('REDIS_CACHE_SENTINEL_SERVICE' , environ .get ('REDIS_SENTINEL_SERVICE' , 'default' )),
98
103
'USERNAME' : environ .get ('REDIS_CACHE_USERNAME' , environ .get ('REDIS_USERNAME' , '' )),
99
104
'PASSWORD' : _read_secret ('redis_cache_password' , environ .get ('REDIS_CACHE_PASSWORD' , environ .get ('REDIS_PASSWORD' , '' ))),
100
105
'DATABASE' : _environ_get_and_map ('REDIS_CACHE_DATABASE' , '1' , _AS_INT ),
@@ -183,6 +188,13 @@ def _environ_get_and_map(variable_name: str, default: str | None = None, map_fn:
183
188
if 'ENFORCE_GLOBAL_UNIQUE' in environ :
184
189
ENFORCE_GLOBAL_UNIQUE = _environ_get_and_map ('ENFORCE_GLOBAL_UNIQUE' , None , _AS_BOOL )
185
190
191
+ # By default, netbox sends census reporting data using a single HTTP request each time a worker starts.
192
+ # This data enables the project maintainers to estimate how many NetBox deployments exist and track the adoption of new versions over time.
193
+ # The only data reported by this function are the NetBox version, Python version, and a pseudorandom unique identifier.
194
+ # To opt out of census reporting, set CENSUS_REPORTING_ENABLED to False.
195
+ if 'CENSUS_REPORTING_ENABLED' in environ :
196
+ CENSUS_REPORTING_ENABLED = _environ_get_and_map ('CENSUS_REPORTING_ENABLED' , None , _AS_BOOL )
197
+
186
198
# Exempt certain models from the enforcement of view permissions. Models listed here will be viewable by all users and
187
199
# by anonymous users. List models in the form `<app>.<model>`. Add '*' to this list to exempt all models.
188
200
EXEMPT_VIEW_PERMISSIONS = _environ_get_and_map ('EXEMPT_VIEW_PERMISSIONS' , '' , _AS_LIST )
@@ -300,6 +312,23 @@ def _environ_get_and_map(variable_name: str, default: str | None = None, map_fn:
300
312
# The name to use for the session cookie.
301
313
SESSION_COOKIE_NAME = environ .get ('SESSION_COOKIE_NAME' , 'sessionid' )
302
314
315
+ # If true, the `includeSubDomains` directive will be included in the HTTP Strict Transport Security (HSTS) header.
316
+ # This directive instructs the browser to apply the HSTS policy to all subdomains of the current domain.
317
+ SECURE_HSTS_INCLUDE_SUBDOMAINS = _environ_get_and_map ('SECURE_HSTS_INCLUDE_SUBDOMAINS' , 'False' , _AS_BOOL )
318
+
319
+ # If true, the `preload` directive will be included in the HTTP Strict Transport Security (HSTS) header.
320
+ # This directive instructs the browser to preload the site in HTTPS. Browsers that use the HSTS preload list will force the
321
+ # site to be accessed via HTTPS even if the user types HTTP in the address bar.
322
+ SECURE_HSTS_PRELOAD = _environ_get_and_map ('SECURE_HSTS_PRELOAD' , 'False' , _AS_BOOL )
323
+
324
+ # If set to a non-zero integer value, the SecurityMiddleware sets the HTTP Strict Transport Security (HSTS) header on all
325
+ # responses that do not already have it. This will instruct the browser that the website must be accessed via HTTPS,
326
+ # blocking any HTTP request.
327
+ SECURE_HSTS_SECONDS = _environ_get_and_map ('SECURE_HSTS_SECONDS' , 0 , _AS_INT )
328
+
329
+ # If true, all non-HTTPS requests will be automatically redirected to use HTTPS.
330
+ SECURE_SSL_REDIRECT = _environ_get_and_map ('SECURE_SSL_REDIRECT' , 'False' , _AS_BOOL )
331
+
303
332
# By default, NetBox will store session data in the database. Alternatively, a file path can be specified here to use
304
333
# local file storage instead. (This can be useful for enabling authentication on a standby instance with read-only
305
334
# database access.) Note that the user as which NetBox runs must have read and write permissions to this path.
@@ -308,11 +337,3 @@ def _environ_get_and_map(variable_name: str, default: str | None = None, map_fn:
308
337
# Time zone (default: UTC)
309
338
TIME_ZONE = environ .get ('TIME_ZONE' , 'UTC' )
310
339
311
- # Date/time formatting. See the following link for supported formats:
312
- # https://docs.djangoproject.com/en/stable/ref/templates/builtins/#date
313
- DATE_FORMAT = environ .get ('DATE_FORMAT' , 'N j, Y' )
314
- SHORT_DATE_FORMAT = environ .get ('SHORT_DATE_FORMAT' , 'Y-m-d' )
315
- TIME_FORMAT = environ .get ('TIME_FORMAT' , 'g:i a' )
316
- SHORT_TIME_FORMAT = environ .get ('SHORT_TIME_FORMAT' , 'H:i:s' )
317
- DATETIME_FORMAT = environ .get ('DATETIME_FORMAT' , 'N j, Y g:i a' )
318
- SHORT_DATETIME_FORMAT = environ .get ('SHORT_DATETIME_FORMAT' , 'Y-m-d H:i' )
0 commit comments