From 7e2a9b474967ba6dafbcd4435b86c06a9993d56d Mon Sep 17 00:00:00 2001 From: Andre Ruiz Date: Tue, 19 Feb 2019 14:17:25 -0300 Subject: [PATCH] Implement new option: session-timeout This change implements a new option in config.yaml that enables a specific session timeout to be defined. Change-Id: I4a521c672347e33718fd03427393eaa5356e57cb Closes-Bug: #1599968 --- config.yaml | 7 +++++++ hooks/horizon_contexts.py | 1 + templates/icehouse/local_settings.py | 3 +++ templates/liberty/local_settings.py | 3 +++ templates/mitaka/local_settings.py | 3 +++ templates/newton/local_settings.py | 3 +++ templates/ocata/local_settings.py | 3 +++ unit_tests/test_horizon_contexts.py | 15 +++++++++++++++ 8 files changed, 38 insertions(+) diff --git a/config.yaml b/config.yaml index c9723f7c..0833ca2a 100644 --- a/config.yaml +++ b/config.yaml @@ -49,6 +49,13 @@ options: description: | Directory where application will be accessible, relative to http://$hostname/. + session-timeout: + type: int + default: 3600 + description: + A method to supersede the token timeout with a shorter dashboard session + timeout in seconds. For example, if your token expires in 60 minutes, a + value of 1800 will log users out after 30 minutes. default-role: type: string default: "Member" diff --git a/hooks/horizon_contexts.py b/hooks/horizon_contexts.py index 751a2c35..2734d8b1 100644 --- a/hooks/horizon_contexts.py +++ b/hooks/horizon_contexts.py @@ -205,6 +205,7 @@ class HorizonContext(OSContextGenerator): 'image_formats': config('image-formats'), 'api_result_limit': config('api-result-limit') or 1000, 'enable_fip_topology_check': config('enable-fip-topology-check'), + 'session_timeout': config('session-timeout') } return ctxt diff --git a/templates/icehouse/local_settings.py b/templates/icehouse/local_settings.py index 3e8cc0a3..30dffb41 100644 --- a/templates/icehouse/local_settings.py +++ b/templates/icehouse/local_settings.py @@ -33,6 +33,9 @@ CSRF_COOKIE_SECURE = True SESSION_COOKIE_SECURE = True {% endif %} +# A method to supersede the token timeout with a shorter dashboard session +# timeout in seconds. +SESSION_TIMEOUT = {{ session_timeout }} # Overrides for OpenStack API versions. Use this setting to force the # OpenStack dashboard to use a specfic API version for a given service API. diff --git a/templates/liberty/local_settings.py b/templates/liberty/local_settings.py index b8b8a3f2..64931b43 100644 --- a/templates/liberty/local_settings.py +++ b/templates/liberty/local_settings.py @@ -51,6 +51,9 @@ CSRF_COOKIE_SECURE = True SESSION_COOKIE_SECURE = True {% endif %} +# A method to supersede the token timeout with a shorter dashboard session +# timeout in seconds. +SESSION_TIMEOUT = {{ session_timeout }} # Overrides for OpenStack API versions. Use this setting to force the # OpenStack dashboard to use a specific API version for a given service API. diff --git a/templates/mitaka/local_settings.py b/templates/mitaka/local_settings.py index 58d4cfbf..21b244a1 100644 --- a/templates/mitaka/local_settings.py +++ b/templates/mitaka/local_settings.py @@ -50,6 +50,9 @@ CSRF_COOKIE_SECURE = True SESSION_COOKIE_SECURE = True {% endif %} +# A method to supersede the token timeout with a shorter dashboard session +# timeout in seconds. +SESSION_TIMEOUT = {{ session_timeout }} # The absolute path to the directory where message files are collected. # The message file must have a .json file extension. When the user logins to diff --git a/templates/newton/local_settings.py b/templates/newton/local_settings.py index 314f439b..928ec26b 100644 --- a/templates/newton/local_settings.py +++ b/templates/newton/local_settings.py @@ -50,6 +50,9 @@ CSRF_COOKIE_SECURE = True SESSION_COOKIE_SECURE = True {% endif %} +# A method to supersede the token timeout with a shorter dashboard session +# timeout in seconds. +SESSION_TIMEOUT = {{ session_timeout }} # The absolute path to the directory where message files are collected. # The message file must have a .json file extension. When the user logins to diff --git a/templates/ocata/local_settings.py b/templates/ocata/local_settings.py index 8b2584b4..18d0bfff 100644 --- a/templates/ocata/local_settings.py +++ b/templates/ocata/local_settings.py @@ -50,6 +50,9 @@ CSRF_COOKIE_SECURE = True SESSION_COOKIE_SECURE = True {% endif %} +# A method to supersede the token timeout with a shorter dashboard session +# timeout in seconds. +SESSION_TIMEOUT = {{ session_timeout }} # The absolute path to the directory where message files are collected. # The message file must have a .json file extension. When the user logins to diff --git a/unit_tests/test_horizon_contexts.py b/unit_tests/test_horizon_contexts.py index 5d380aeb..448ce3cb 100644 --- a/unit_tests/test_horizon_contexts.py +++ b/unit_tests/test_horizon_contexts.py @@ -164,6 +164,7 @@ class TestHorizonContexts(CharmTestCase): "image_formats": '', "api_result_limit": 1000, "enable_fip_topology_check": True, + "session_timeout": 3600, } ) @@ -192,6 +193,7 @@ class TestHorizonContexts(CharmTestCase): "image_formats": '', "api_result_limit": 1000, "enable_fip_topology_check": True, + "session_timeout": 3600, } ) @@ -220,6 +222,7 @@ class TestHorizonContexts(CharmTestCase): "image_formats": '', "api_result_limit": 1000, "enable_fip_topology_check": True, + "session_timeout": 3600, } ) @@ -248,6 +251,7 @@ class TestHorizonContexts(CharmTestCase): "image_formats": '', "api_result_limit": 1000, "enable_fip_topology_check": True, + "session_timeout": 3600, } ) @@ -277,6 +281,7 @@ class TestHorizonContexts(CharmTestCase): "image_formats": '', "api_result_limit": 1000, "enable_fip_topology_check": True, + "session_timeout": 3600, } ) @@ -309,6 +314,7 @@ class TestHorizonContexts(CharmTestCase): "image_formats": '', "api_result_limit": 1000, "enable_fip_topology_check": True, + "session_timeout": 3600, } ) @@ -337,6 +343,7 @@ class TestHorizonContexts(CharmTestCase): "image_formats": '', "api_result_limit": 1000, "enable_fip_topology_check": True, + "session_timeout": 3600, } ) @@ -365,6 +372,7 @@ class TestHorizonContexts(CharmTestCase): "image_formats": '', "api_result_limit": 1000, "enable_fip_topology_check": True, + "session_timeout": 3600, } ) @@ -398,6 +406,7 @@ class TestHorizonContexts(CharmTestCase): "image_formats": '', "api_result_limit": 1000, "enable_fip_topology_check": True, + "session_timeout": 3600, } ) @@ -426,6 +435,7 @@ class TestHorizonContexts(CharmTestCase): "image_formats": '', "api_result_limit": 1000, "enable_fip_topology_check": True, + "session_timeout": 3600, } ) @@ -454,6 +464,7 @@ class TestHorizonContexts(CharmTestCase): "image_formats": '', "api_result_limit": 1000, "enable_fip_topology_check": True, + "session_timeout": 3600, } ) @@ -483,6 +494,7 @@ class TestHorizonContexts(CharmTestCase): "image_formats": '', "api_result_limit": 1000, "enable_fip_topology_check": True, + "session_timeout": 3600, } ) @@ -512,6 +524,7 @@ class TestHorizonContexts(CharmTestCase): "image_formats": '', "api_result_limit": 1000, "enable_fip_topology_check": True, + "session_timeout": 3600, } ) @@ -541,6 +554,7 @@ class TestHorizonContexts(CharmTestCase): "image_formats": 'iso qcow2 raw', "api_result_limit": 1000, "enable_fip_topology_check": True, + "session_timeout": 3600, } ) @@ -570,6 +584,7 @@ class TestHorizonContexts(CharmTestCase): "image_formats": '', "api_result_limit": 1000, "enable_fip_topology_check": False, + "session_timeout": 3600, } )