This repository was archived by the owner on Apr 26, 2024. It is now read-only.
Repository navigation
Support configuring the lifetime of non-refreshable access tokens separately to refreshable access tokens. #11445
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
08bbade
Add nonrefreshable access token lifetime configuration option
reivilibre d73e564
Factorise out now_ms
reivilibre 0789757
Use the non-refreshable access token lifetime
reivilibre 81ffa3c
Copyright
reivilibre a06e49a
Add some tests for non-refreshable access token expiry.
reivilibre c7d59f3
Newsfile
reivilibre d2de500
Merge branch 'develop' into rei/nonrefreshable_lifetime
reivilibre b79ece8
Revert false start change
reivilibre 6b746b2
Fix typo
reivilibre 8ec406f
Check that session lifetime is not smaller than the non-refreshable a…
reivilibre 9c8e027
Check that the other two kinds of lifetimes are not larger than sessi…
reivilibre 94abe8f
Add test to check that the configured lifetimes are checked properly
reivilibre File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Support configuring the lifetime of non-refreshable access tokens separately to refreshable access tokens. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| # Copyright 2021 The Matrix.org Foundation C.I.C. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| from synapse.config import ConfigError | ||
| from synapse.config.homeserver import HomeServerConfig | ||
|
|
||
| from tests.unittest import TestCase | ||
| from tests.utils import default_config | ||
|
|
||
|
|
||
| class RegistrationConfigTestCase(TestCase): | ||
| def test_session_lifetime_must_not_be_exceeded_by_smaller_lifetimes(self): | ||
| """ | ||
| session_lifetime should logically be larger than, or at least as large as, | ||
| all the different token lifetimes. | ||
| Test that the user is faced with configuration errors if they make it | ||
| smaller, as that configuration doesn't make sense. | ||
| """ | ||
| config_dict = default_config("test") | ||
|
|
||
| # First test all the error conditions | ||
| with self.assertRaises(ConfigError): | ||
| HomeServerConfig().parse_config_dict( | ||
| { | ||
| "session_lifetime": "30m", | ||
| "nonrefreshable_access_token_lifetime": "31m", | ||
| **config_dict, | ||
| } | ||
| ) | ||
|
|
||
| with self.assertRaises(ConfigError): | ||
| HomeServerConfig().parse_config_dict( | ||
| { | ||
| "session_lifetime": "30m", | ||
| "refreshable_access_token_lifetime": "31m", | ||
| **config_dict, | ||
| } | ||
| ) | ||
|
|
||
| with self.assertRaises(ConfigError): | ||
| HomeServerConfig().parse_config_dict( | ||
| { | ||
| "session_lifetime": "30m", | ||
| "refresh_token_lifetime": "31m", | ||
| **config_dict, | ||
| } | ||
| ) | ||
|
|
||
| # Then test all the fine conditions | ||
| HomeServerConfig().parse_config_dict( | ||
| { | ||
| "session_lifetime": "31m", | ||
| "nonrefreshable_access_token_lifetime": "31m", | ||
| **config_dict, | ||
| } | ||
| ) | ||
|
|
||
| HomeServerConfig().parse_config_dict( | ||
| { | ||
| "session_lifetime": "31m", | ||
| "refreshable_access_token_lifetime": "31m", | ||
| **config_dict, | ||
| } | ||
| ) | ||
|
|
||
| HomeServerConfig().parse_config_dict( | ||
| {"session_lifetime": "31m", "refresh_token_lifetime": "31m", **config_dict} | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.