mirror of
https://mau.dev/maunium/synapse.git
synced 2024-12-14 01:43:45 +01:00
parent
3355c1a9ec
commit
f85676cc93
3 changed files with 15 additions and 7 deletions
1
changelog.d/4319.feature
Normal file
1
changelog.d/4319.feature
Normal file
|
@ -0,0 +1 @@
|
|||
Return server data in /login response
|
|
@ -28,6 +28,7 @@ from synapse.http.servlet import (
|
|||
parse_json_object_from_request,
|
||||
parse_string,
|
||||
)
|
||||
from synapse.rest.well_known import WellKnownBuilder
|
||||
from synapse.types import UserID, map_username_to_mxid_localpart
|
||||
from synapse.util.msisdn import phone_number_to_msisdn
|
||||
|
||||
|
@ -95,6 +96,7 @@ class LoginRestServlet(ClientV1RestServlet):
|
|||
self.auth_handler = self.hs.get_auth_handler()
|
||||
self.device_handler = self.hs.get_device_handler()
|
||||
self.handlers = hs.get_handlers()
|
||||
self._well_known_builder = WellKnownBuilder(hs)
|
||||
|
||||
def on_GET(self, request):
|
||||
flows = []
|
||||
|
@ -132,16 +134,18 @@ class LoginRestServlet(ClientV1RestServlet):
|
|||
if self.jwt_enabled and (login_submission["type"] ==
|
||||
LoginRestServlet.JWT_TYPE):
|
||||
result = yield self.do_jwt_login(login_submission)
|
||||
defer.returnValue(result)
|
||||
elif login_submission["type"] == LoginRestServlet.TOKEN_TYPE:
|
||||
result = yield self.do_token_login(login_submission)
|
||||
defer.returnValue(result)
|
||||
else:
|
||||
result = yield self._do_other_login(login_submission)
|
||||
defer.returnValue(result)
|
||||
except KeyError:
|
||||
raise SynapseError(400, "Missing JSON keys.")
|
||||
|
||||
well_known_data = self._well_known_builder.get_well_known()
|
||||
if well_known_data:
|
||||
result["well_known"] = well_known_data
|
||||
defer.returnValue((200, result))
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def _do_other_login(self, login_submission):
|
||||
"""Handle non-token/saml/jwt logins
|
||||
|
@ -150,7 +154,7 @@ class LoginRestServlet(ClientV1RestServlet):
|
|||
login_submission:
|
||||
|
||||
Returns:
|
||||
(int, object): HTTP code/response
|
||||
dict: HTTP response
|
||||
"""
|
||||
# Log the request we got, but only certain fields to minimise the chance of
|
||||
# logging someone's password (even if they accidentally put it in the wrong
|
||||
|
@ -233,7 +237,7 @@ class LoginRestServlet(ClientV1RestServlet):
|
|||
if callback is not None:
|
||||
yield callback(result)
|
||||
|
||||
defer.returnValue((200, result))
|
||||
defer.returnValue(result)
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def do_token_login(self, login_submission):
|
||||
|
@ -253,7 +257,7 @@ class LoginRestServlet(ClientV1RestServlet):
|
|||
"device_id": device_id,
|
||||
}
|
||||
|
||||
defer.returnValue((200, result))
|
||||
defer.returnValue(result)
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def do_jwt_login(self, login_submission):
|
||||
|
@ -307,7 +311,7 @@ class LoginRestServlet(ClientV1RestServlet):
|
|||
"home_server": self.hs.hostname,
|
||||
}
|
||||
|
||||
defer.returnValue((200, result))
|
||||
defer.returnValue(result)
|
||||
|
||||
def _register_device(self, user_id, login_submission):
|
||||
"""Register a device for a user.
|
||||
|
|
|
@ -140,6 +140,9 @@ def default_config(name):
|
|||
config.rc_messages_per_second = 10000
|
||||
config.rc_message_burst_count = 10000
|
||||
config.saml2_enabled = False
|
||||
config.public_baseurl = None
|
||||
config.default_identity_server = None
|
||||
|
||||
config.use_frozen_dicts = False
|
||||
|
||||
# we need a sane default_room_version, otherwise attempts to create rooms will
|
||||
|
|
Loading…
Reference in a new issue