diff --git a/CHANGELOG.md b/CHANGELOG.md index 969235c58..1496c5ead 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,6 +31,7 @@ NetBox now supports modeling physical cables for console, power, and interface c * [#1444](https://github.com/digitalocean/netbox/issues/1444) - Added an `asset_tag` field for racks * [#1931](https://github.com/digitalocean/netbox/issues/1931) - Added a count of assigned IP addresses to the interface API serializer * [#2000](https://github.com/digitalocean/netbox/issues/2000) - Dropped support for Python 2 +* [#2053](https://github.com/digitalocean/netbox/issues/2053) - Introduced the `LOGIN_TIMEOUT` configuration setting * [#2057](https://github.com/digitalocean/netbox/issues/2057) - Added description columns to interface connections list * [#2104](https://github.com/digitalocean/netbox/issues/2104) - Added a `status` field for racks * [#2165](https://github.com/digitalocean/netbox/issues/2165) - Improved natural ordering of Interfaces diff --git a/docs/configuration/optional-settings.md b/docs/configuration/optional-settings.md index ee266ecc1..82412cdf7 100644 --- a/docs/configuration/optional-settings.md +++ b/docs/configuration/optional-settings.md @@ -133,6 +133,14 @@ Setting this to True will permit only authenticated users to access any part of --- +## LOGIN_TIMEOUT + +Default: 1209600 seconds (14 days) + +The liftetime (in seconds) of the authentication cookie issued to a NetBox user upon login. + +--- + ## MAINTENANCE_MODE Default: False diff --git a/netbox/netbox/configuration.example.py b/netbox/netbox/configuration.example.py index 34f1bff8d..d7a9cf2ed 100644 --- a/netbox/netbox/configuration.example.py +++ b/netbox/netbox/configuration.example.py @@ -91,6 +91,10 @@ LOGGING = {} # are permitted to access most data in NetBox (excluding secrets) but not make any changes. LOGIN_REQUIRED = False +# The length of time (in seconds) for which a user will remain logged into the web UI before being prompted to +# re-authenticate. (Default: 1209600 [14 days]) +LOGIN_TIMEOUT = None + # Setting this to True will display a "maintenance mode" banner at the top of every page. MAINTENANCE_MODE = False diff --git a/netbox/netbox/settings.py b/netbox/netbox/settings.py index 800d39d82..75d4f3197 100644 --- a/netbox/netbox/settings.py +++ b/netbox/netbox/settings.py @@ -54,6 +54,7 @@ ENFORCE_GLOBAL_UNIQUE = getattr(configuration, 'ENFORCE_GLOBAL_UNIQUE', False) EMAIL = getattr(configuration, 'EMAIL', {}) LOGGING = getattr(configuration, 'LOGGING', {}) LOGIN_REQUIRED = getattr(configuration, 'LOGIN_REQUIRED', False) +LOGIN_TIMEOUT = getattr(configuration, 'LOGIN_TIMEOUT', None) MAINTENANCE_MODE = getattr(configuration, 'MAINTENANCE_MODE', False) MAX_PAGE_SIZE = getattr(configuration, 'MAX_PAGE_SIZE', 1000) MEDIA_ROOT = getattr(configuration, 'MEDIA_ROOT', os.path.join(BASE_DIR, 'media')).rstrip('/') @@ -113,6 +114,13 @@ DATABASES = { } # Sessions +if LOGIN_TIMEOUT is not None: + if type(LOGIN_TIMEOUT) is not int or LOGIN_TIMEOUT < 0: + raise ImproperlyConfigured( + "LOGIN_TIMEOUT must be a positive integer (value: {})".format(LOGIN_TIMEOUT) + ) + # Django default is 1209600 seconds (14 days) + SESSION_COOKIE_AGE = LOGIN_TIMEOUT if SESSION_FILE_PATH is not None: SESSION_ENGINE = 'django.contrib.sessions.backends.file'