mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-20 14:50:22 -04:00
Stabilise support for MSC2918 refresh tokens as they have now been merged into the Matrix specification. (#11435)
This commit is contained in:
parent
a15a893df8
commit
2f053f3f82
6 changed files with 115 additions and 44 deletions
|
@ -419,7 +419,7 @@ class RegisterRestServlet(RestServlet):
|
|||
self.password_policy_handler = hs.get_password_policy_handler()
|
||||
self.clock = hs.get_clock()
|
||||
self._registration_enabled = self.hs.config.registration.enable_registration
|
||||
self._msc2918_enabled = (
|
||||
self._refresh_tokens_enabled = (
|
||||
hs.config.registration.refreshable_access_token_lifetime is not None
|
||||
)
|
||||
|
||||
|
@ -445,18 +445,15 @@ class RegisterRestServlet(RestServlet):
|
|||
f"Do not understand membership kind: {kind}",
|
||||
)
|
||||
|
||||
if self._msc2918_enabled:
|
||||
# Check if this registration should also issue a refresh token, as
|
||||
# per MSC2918
|
||||
should_issue_refresh_token = body.get(
|
||||
"org.matrix.msc2918.refresh_token", False
|
||||
)
|
||||
if not isinstance(should_issue_refresh_token, bool):
|
||||
raise SynapseError(
|
||||
400, "`org.matrix.msc2918.refresh_token` should be true or false."
|
||||
)
|
||||
else:
|
||||
should_issue_refresh_token = False
|
||||
# Check if the clients wishes for this registration to issue a refresh
|
||||
# token.
|
||||
client_requested_refresh_tokens = body.get("refresh_token", False)
|
||||
if not isinstance(client_requested_refresh_tokens, bool):
|
||||
raise SynapseError(400, "`refresh_token` should be true or false.")
|
||||
|
||||
should_issue_refresh_token = (
|
||||
self._refresh_tokens_enabled and client_requested_refresh_tokens
|
||||
)
|
||||
|
||||
# Pull out the provided username and do basic sanity checks early since
|
||||
# the auth layer will store these in sessions.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue