Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit e17553e

Browse files
authored
Parse ui_auth.session_timeout as a duration (instead of treating it as ms) (#9426)
1 parent e8e7012 commit e17553e

File tree

4 files changed

+11
-8
lines changed

4 files changed

+11
-8
lines changed

changelog.d/9426.bugfix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
The `ui_auth.session_timeout` configuration setting can now be specified in terms of number of seconds/minutes/etc/. Contributed by Rishabh Arya.

docs/sample_config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2228,8 +2228,8 @@ password_config:
22282228
#require_uppercase: true
22292229

22302230
ui_auth:
2231-
# The number of milliseconds to allow a user-interactive authentication
2232-
# session to be active.
2231+
# The amount of time to allow a user-interactive authentication session
2232+
# to be active.
22332233
#
22342234
# This defaults to 0, meaning the user is queried for their credentials
22352235
# before every action, but this can be overridden to allow a single
@@ -2240,7 +2240,7 @@ ui_auth:
22402240
# Uncomment below to allow for credential validation to last for 15
22412241
# seconds.
22422242
#
2243-
#session_timeout: 15000
2243+
#session_timeout: "15s"
22442244

22452245

22462246
# Configuration for sending emails from Synapse.

synapse/config/auth.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ def read_config(self, config, **kwargs):
3737

3838
# User-interactive authentication
3939
ui_auth = config.get("ui_auth") or {}
40-
self.ui_auth_session_timeout = ui_auth.get("session_timeout", 0)
40+
self.ui_auth_session_timeout = self.parse_duration(
41+
ui_auth.get("session_timeout", 0)
42+
)
4143

4244
def generate_config_section(self, config_dir_path, server_name, **kwargs):
4345
return """\
@@ -93,8 +95,8 @@ def generate_config_section(self, config_dir_path, server_name, **kwargs):
9395
#require_uppercase: true
9496
9597
ui_auth:
96-
# The number of milliseconds to allow a user-interactive authentication
97-
# session to be active.
98+
# The amount of time to allow a user-interactive authentication session
99+
# to be active.
98100
#
99101
# This defaults to 0, meaning the user is queried for their credentials
100102
# before every action, but this can be overridden to allow a single
@@ -105,5 +107,5 @@ def generate_config_section(self, config_dir_path, server_name, **kwargs):
105107
# Uncomment below to allow for credential validation to last for 15
106108
# seconds.
107109
#
108-
#session_timeout: 15000
110+
#session_timeout: "15s"
109111
"""

tests/rest/client/v2_alpha/test_auth.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ def test_cannot_change_uri(self):
343343
},
344344
)
345345

346-
@unittest.override_config({"ui_auth": {"session_timeout": 5 * 1000}})
346+
@unittest.override_config({"ui_auth": {"session_timeout": "5s"}})
347347
def test_can_reuse_session(self):
348348
"""
349349
The session can be reused if configured.

0 commit comments

Comments
 (0)