mirror of
https://github.com/element-hq/synapse.git
synced 2024-11-28 23:20:09 +03:00
Parse ui_auth.session_timeout as a duration (instead of treating it as ms) (#9426)
This commit is contained in:
parent
e8e7012265
commit
e17553e185
4 changed files with 11 additions and 8 deletions
1
changelog.d/9426.bugfix
Normal file
1
changelog.d/9426.bugfix
Normal file
|
@ -0,0 +1 @@
|
||||||
|
The `ui_auth.session_timeout` configuration setting can now be specified in terms of number of seconds/minutes/etc/. Contributed by Rishabh Arya.
|
|
@ -2228,8 +2228,8 @@ password_config:
|
||||||
#require_uppercase: true
|
#require_uppercase: true
|
||||||
|
|
||||||
ui_auth:
|
ui_auth:
|
||||||
# The number of milliseconds to allow a user-interactive authentication
|
# The amount of time to allow a user-interactive authentication session
|
||||||
# session to be active.
|
# to be active.
|
||||||
#
|
#
|
||||||
# This defaults to 0, meaning the user is queried for their credentials
|
# This defaults to 0, meaning the user is queried for their credentials
|
||||||
# before every action, but this can be overridden to allow a single
|
# before every action, but this can be overridden to allow a single
|
||||||
|
@ -2240,7 +2240,7 @@ ui_auth:
|
||||||
# Uncomment below to allow for credential validation to last for 15
|
# Uncomment below to allow for credential validation to last for 15
|
||||||
# seconds.
|
# seconds.
|
||||||
#
|
#
|
||||||
#session_timeout: 15000
|
#session_timeout: "15s"
|
||||||
|
|
||||||
|
|
||||||
# Configuration for sending emails from Synapse.
|
# Configuration for sending emails from Synapse.
|
||||||
|
|
|
@ -37,7 +37,9 @@ class AuthConfig(Config):
|
||||||
|
|
||||||
# User-interactive authentication
|
# User-interactive authentication
|
||||||
ui_auth = config.get("ui_auth") or {}
|
ui_auth = config.get("ui_auth") or {}
|
||||||
self.ui_auth_session_timeout = ui_auth.get("session_timeout", 0)
|
self.ui_auth_session_timeout = self.parse_duration(
|
||||||
|
ui_auth.get("session_timeout", 0)
|
||||||
|
)
|
||||||
|
|
||||||
def generate_config_section(self, config_dir_path, server_name, **kwargs):
|
def generate_config_section(self, config_dir_path, server_name, **kwargs):
|
||||||
return """\
|
return """\
|
||||||
|
@ -93,8 +95,8 @@ class AuthConfig(Config):
|
||||||
#require_uppercase: true
|
#require_uppercase: true
|
||||||
|
|
||||||
ui_auth:
|
ui_auth:
|
||||||
# The number of milliseconds to allow a user-interactive authentication
|
# The amount of time to allow a user-interactive authentication session
|
||||||
# session to be active.
|
# to be active.
|
||||||
#
|
#
|
||||||
# This defaults to 0, meaning the user is queried for their credentials
|
# This defaults to 0, meaning the user is queried for their credentials
|
||||||
# before every action, but this can be overridden to allow a single
|
# before every action, but this can be overridden to allow a single
|
||||||
|
@ -105,5 +107,5 @@ class AuthConfig(Config):
|
||||||
# Uncomment below to allow for credential validation to last for 15
|
# Uncomment below to allow for credential validation to last for 15
|
||||||
# seconds.
|
# seconds.
|
||||||
#
|
#
|
||||||
#session_timeout: 15000
|
#session_timeout: "15s"
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -343,7 +343,7 @@ class UIAuthTests(unittest.HomeserverTestCase):
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
@unittest.override_config({"ui_auth": {"session_timeout": 5 * 1000}})
|
@unittest.override_config({"ui_auth": {"session_timeout": "5s"}})
|
||||||
def test_can_reuse_session(self):
|
def test_can_reuse_session(self):
|
||||||
"""
|
"""
|
||||||
The session can be reused if configured.
|
The session can be reused if configured.
|
||||||
|
|
Loading…
Reference in a new issue