Revert "Fix existing v2 identity server calls (MSC2140) (#6013)"
This has now been merged into develop (michaelkaye/matrix_org_hotfixes_increase_replication_timeout3505ffcda
) so we don't need this cherry-picked commit. This reverts commite0eef47315
.
parent
ee91c69ef7
commit
e01026d84d
|
@ -1 +0,0 @@
|
||||||
Compatibility with v2 Identity Service APIs other than /lookup.
|
|
|
@ -74,25 +74,6 @@ class IdentityHandler(BaseHandler):
|
||||||
id_access_token = creds.get("id_access_token")
|
id_access_token = creds.get("id_access_token")
|
||||||
return client_secret, id_server, id_access_token
|
return client_secret, id_server, id_access_token
|
||||||
|
|
||||||
def create_id_access_token_header(self, id_access_token):
|
|
||||||
"""Create an Authorization header for passing to SimpleHttpClient as the header value
|
|
||||||
of an HTTP request.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
id_access_token (str): An identity server access token.
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
list[str]: The ascii-encoded bearer token encased in a list.
|
|
||||||
"""
|
|
||||||
# Prefix with Bearer
|
|
||||||
bearer_token = "Bearer %s" % id_access_token
|
|
||||||
|
|
||||||
# Encode headers to standard ascii
|
|
||||||
bearer_token.encode("ascii")
|
|
||||||
|
|
||||||
# Return as a list as that's how SimpleHttpClient takes header values
|
|
||||||
return [bearer_token]
|
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def threepid_from_creds(self, id_server, creds):
|
def threepid_from_creds(self, id_server, creds):
|
||||||
"""
|
"""
|
||||||
|
@ -168,20 +149,15 @@ class IdentityHandler(BaseHandler):
|
||||||
use_v2 = False
|
use_v2 = False
|
||||||
|
|
||||||
# Decide which API endpoint URLs to use
|
# Decide which API endpoint URLs to use
|
||||||
headers = {}
|
|
||||||
bind_data = {"sid": creds["sid"], "client_secret": client_secret, "mxid": mxid}
|
bind_data = {"sid": creds["sid"], "client_secret": client_secret, "mxid": mxid}
|
||||||
if use_v2:
|
if use_v2:
|
||||||
bind_url = "https://%s/_matrix/identity/v2/3pid/bind" % (id_server,)
|
bind_url = "https://%s/_matrix/identity/v2/3pid/bind" % (id_server,)
|
||||||
headers["Authorization"] = self.create_id_access_token_header(
|
bind_data["id_access_token"] = id_access_token
|
||||||
id_access_token
|
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
bind_url = "https://%s/_matrix/identity/api/v1/3pid/bind" % (id_server,)
|
bind_url = "https://%s/_matrix/identity/api/v1/3pid/bind" % (id_server,)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
data = yield self.http_client.post_json_get_json(
|
data = yield self.http_client.post_json_get_json(bind_url, bind_data)
|
||||||
bind_url, bind_data, headers=headers
|
|
||||||
)
|
|
||||||
logger.debug("bound threepid %r to %s", creds, mxid)
|
logger.debug("bound threepid %r to %s", creds, mxid)
|
||||||
|
|
||||||
# Remember where we bound the threepid
|
# Remember where we bound the threepid
|
||||||
|
|
Loading…
Reference in New Issue