parent
3355c1a9ec
commit
f85676cc93
|
@ -0,0 +1 @@
|
||||||
|
Return server data in /login response
|
|
@ -28,6 +28,7 @@ from synapse.http.servlet import (
|
||||||
parse_json_object_from_request,
|
parse_json_object_from_request,
|
||||||
parse_string,
|
parse_string,
|
||||||
)
|
)
|
||||||
|
from synapse.rest.well_known import WellKnownBuilder
|
||||||
from synapse.types import UserID, map_username_to_mxid_localpart
|
from synapse.types import UserID, map_username_to_mxid_localpart
|
||||||
from synapse.util.msisdn import phone_number_to_msisdn
|
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.auth_handler = self.hs.get_auth_handler()
|
||||||
self.device_handler = self.hs.get_device_handler()
|
self.device_handler = self.hs.get_device_handler()
|
||||||
self.handlers = hs.get_handlers()
|
self.handlers = hs.get_handlers()
|
||||||
|
self._well_known_builder = WellKnownBuilder(hs)
|
||||||
|
|
||||||
def on_GET(self, request):
|
def on_GET(self, request):
|
||||||
flows = []
|
flows = []
|
||||||
|
@ -132,16 +134,18 @@ class LoginRestServlet(ClientV1RestServlet):
|
||||||
if self.jwt_enabled and (login_submission["type"] ==
|
if self.jwt_enabled and (login_submission["type"] ==
|
||||||
LoginRestServlet.JWT_TYPE):
|
LoginRestServlet.JWT_TYPE):
|
||||||
result = yield self.do_jwt_login(login_submission)
|
result = yield self.do_jwt_login(login_submission)
|
||||||
defer.returnValue(result)
|
|
||||||
elif login_submission["type"] == LoginRestServlet.TOKEN_TYPE:
|
elif login_submission["type"] == LoginRestServlet.TOKEN_TYPE:
|
||||||
result = yield self.do_token_login(login_submission)
|
result = yield self.do_token_login(login_submission)
|
||||||
defer.returnValue(result)
|
|
||||||
else:
|
else:
|
||||||
result = yield self._do_other_login(login_submission)
|
result = yield self._do_other_login(login_submission)
|
||||||
defer.returnValue(result)
|
|
||||||
except KeyError:
|
except KeyError:
|
||||||
raise SynapseError(400, "Missing JSON keys.")
|
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
|
@defer.inlineCallbacks
|
||||||
def _do_other_login(self, login_submission):
|
def _do_other_login(self, login_submission):
|
||||||
"""Handle non-token/saml/jwt logins
|
"""Handle non-token/saml/jwt logins
|
||||||
|
@ -150,7 +154,7 @@ class LoginRestServlet(ClientV1RestServlet):
|
||||||
login_submission:
|
login_submission:
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
(int, object): HTTP code/response
|
dict: HTTP response
|
||||||
"""
|
"""
|
||||||
# Log the request we got, but only certain fields to minimise the chance of
|
# 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
|
# 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:
|
if callback is not None:
|
||||||
yield callback(result)
|
yield callback(result)
|
||||||
|
|
||||||
defer.returnValue((200, result))
|
defer.returnValue(result)
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def do_token_login(self, login_submission):
|
def do_token_login(self, login_submission):
|
||||||
|
@ -253,7 +257,7 @@ class LoginRestServlet(ClientV1RestServlet):
|
||||||
"device_id": device_id,
|
"device_id": device_id,
|
||||||
}
|
}
|
||||||
|
|
||||||
defer.returnValue((200, result))
|
defer.returnValue(result)
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def do_jwt_login(self, login_submission):
|
def do_jwt_login(self, login_submission):
|
||||||
|
@ -307,7 +311,7 @@ class LoginRestServlet(ClientV1RestServlet):
|
||||||
"home_server": self.hs.hostname,
|
"home_server": self.hs.hostname,
|
||||||
}
|
}
|
||||||
|
|
||||||
defer.returnValue((200, result))
|
defer.returnValue(result)
|
||||||
|
|
||||||
def _register_device(self, user_id, login_submission):
|
def _register_device(self, user_id, login_submission):
|
||||||
"""Register a device for a user.
|
"""Register a device for a user.
|
||||||
|
|
|
@ -140,6 +140,9 @@ def default_config(name):
|
||||||
config.rc_messages_per_second = 10000
|
config.rc_messages_per_second = 10000
|
||||||
config.rc_message_burst_count = 10000
|
config.rc_message_burst_count = 10000
|
||||||
config.saml2_enabled = False
|
config.saml2_enabled = False
|
||||||
|
config.public_baseurl = None
|
||||||
|
config.default_identity_server = None
|
||||||
|
|
||||||
config.use_frozen_dicts = False
|
config.use_frozen_dicts = False
|
||||||
|
|
||||||
# we need a sane default_room_version, otherwise attempts to create rooms will
|
# we need a sane default_room_version, otherwise attempts to create rooms will
|
||||||
|
|
Loading…
Reference in New Issue