diff --git a/CHANGELOG.md b/CHANGELOG.md index f4f2e91ad..969235c58 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,6 +36,7 @@ NetBox now supports modeling physical cables for console, power, and interface c * [#2165](https://github.com/digitalocean/netbox/issues/2165) - Improved natural ordering of Interfaces * [#2292](https://github.com/digitalocean/netbox/issues/2292) - Removed the deprecated UserAction model * [#2367](https://github.com/digitalocean/netbox/issues/2367) - Removed deprecated RPCClient functionality +* [#2426](https://github.com/digitalocean/netbox/issues/2426) - Introduced `SESSION_FILE_PATH` configuration setting for authentication without write access to database ## Changes From v2.5-beta1 diff --git a/docs/configuration/optional-settings.md b/docs/configuration/optional-settings.md index b4de6fe7b..ee266ecc1 100644 --- a/docs/configuration/optional-settings.md +++ b/docs/configuration/optional-settings.md @@ -223,6 +223,14 @@ The file path to the location where custom reports will be kept. By default, thi --- +## SESSION_FILE_PATH + +Default: None + +Session data is used to track authenticated users when they access NetBox. By default, NetBox stores session data in the PostgreSQL database. However, this inhibits authentication to a standby instance of NetBox without write access to the database. Alternatively, a local file path may be specified here and NetBox will store session data as files instead of using the database. Note that the user as which NetBox runs must have read and write permissions to this path. + +--- + ## TIME_ZONE Default: UTC diff --git a/netbox/netbox/configuration.example.py b/netbox/netbox/configuration.example.py index 23d6ba221..34f1bff8d 100644 --- a/netbox/netbox/configuration.example.py +++ b/netbox/netbox/configuration.example.py @@ -121,10 +121,6 @@ PAGINATE_COUNT = 50 # prefer IPv4 instead. PREFER_IPV4 = False -# The Webhook event backend is disabled by default. Set this to True to enable it. Note that this requires a Redis -# database be configured and accessible by NetBox (see `REDIS` below). -WEBHOOKS_ENABLED = False - # Redis database settings (optional). A Redis database is required only if the webhooks backend is enabled. REDIS = { 'HOST': 'localhost', @@ -138,9 +134,18 @@ REDIS = { # this setting is derived from the installed location. # REPORTS_ROOT = '/opt/netbox/netbox/reports' +# By default, NetBox will store session data in the database. Alternatively, a file path can be specified here to use +# local file storage instead. (This can be useful for enabling authentication on a standby instance with read-only +# database access.) Note that the user as which NetBox runs must have read and write permissions to this path. +SESSION_FILE_PATH = None + # Time zone (default: UTC) TIME_ZONE = 'UTC' +# The webhooks backend is disabled by default. Set this to True to enable it. Note that this requires a Redis +# database be configured and accessible by NetBox. +WEBHOOKS_ENABLED = False + # Date/time formatting. See the following link for supported formats: # https://docs.djangoproject.com/en/dev/ref/templates/builtins/#date DATE_FORMAT = 'N j, Y' diff --git a/netbox/netbox/settings.py b/netbox/netbox/settings.py index 67ad50655..800d39d82 100644 --- a/netbox/netbox/settings.py +++ b/netbox/netbox/settings.py @@ -65,6 +65,7 @@ PAGINATE_COUNT = getattr(configuration, 'PAGINATE_COUNT', 50) PREFER_IPV4 = getattr(configuration, 'PREFER_IPV4', False) REPORTS_ROOT = getattr(configuration, 'REPORTS_ROOT', os.path.join(BASE_DIR, 'reports')).rstrip('/') REDIS = getattr(configuration, 'REDIS', {}) +SESSION_FILE_PATH = getattr(configuration, 'SESSION_FILE_PATH', None) SHORT_DATE_FORMAT = getattr(configuration, 'SHORT_DATE_FORMAT', 'Y-m-d') SHORT_DATETIME_FORMAT = getattr(configuration, 'SHORT_DATETIME_FORMAT', 'Y-m-d H:i') SHORT_TIME_FORMAT = getattr(configuration, 'SHORT_TIME_FORMAT', 'H:i:s') @@ -111,6 +112,10 @@ DATABASES = { 'default': configuration.DATABASE, } +# Sessions +if SESSION_FILE_PATH is not None: + SESSION_ENGINE = 'django.contrib.sessions.backends.file' + # Redis REDIS_HOST = REDIS.get('HOST', 'localhost') REDIS_PORT = REDIS.get('PORT', 6379)