@@ -86,6 +86,9 @@ def _environ_get_and_map(variable_name: str, default: str | None = None, map_fn:
8686 'tasks' : {
8787 'HOST' : environ .get ('REDIS_HOST' , 'localhost' ),
8888 '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 ),
8992 'USERNAME' : environ .get ('REDIS_USERNAME' , '' ),
9093 'PASSWORD' : _read_secret ('redis_password' , environ .get ('REDIS_PASSWORD' , '' )),
9194 '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:
9598 'caching' : {
9699 'HOST' : environ .get ('REDIS_CACHE_HOST' , environ .get ('REDIS_HOST' , 'localhost' )),
97100 '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' )),
98103 'USERNAME' : environ .get ('REDIS_CACHE_USERNAME' , environ .get ('REDIS_USERNAME' , '' )),
99104 'PASSWORD' : _read_secret ('redis_cache_password' , environ .get ('REDIS_CACHE_PASSWORD' , environ .get ('REDIS_PASSWORD' , '' ))),
100105 '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:
183188if 'ENFORCE_GLOBAL_UNIQUE' in environ :
184189 ENFORCE_GLOBAL_UNIQUE = _environ_get_and_map ('ENFORCE_GLOBAL_UNIQUE' , None , _AS_BOOL )
185190
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+
186198# Exempt certain models from the enforcement of view permissions. Models listed here will be viewable by all users and
187199# by anonymous users. List models in the form `<app>.<model>`. Add '*' to this list to exempt all models.
188200EXEMPT_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:
300312# The name to use for the session cookie.
301313SESSION_COOKIE_NAME = environ .get ('SESSION_COOKIE_NAME' , 'sessionid' )
302314
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+
303332# By default, NetBox will store session data in the database. Alternatively, a file path can be specified here to use
304333# local file storage instead. (This can be useful for enabling authentication on a standby instance with read-only
305334# 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:
308337# Time zone (default: UTC)
309338TIME_ZONE = environ .get ('TIME_ZONE' , 'UTC' )
310339
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