Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit 5077626

Browse files
anoadragon453richvdh
authored andcommitted
Add submit_url response parameter to msisdn /requestToken (#6079)
Second part of solving #6076 Fixes #6076 We return a submit_url parameter on calls to POST */msisdn/requestToken so that clients know where to submit token information to.
1 parent 2b071a2 commit 5077626

File tree

4 files changed

+16
-1
lines changed

4 files changed

+16
-1
lines changed

changelog.d/6079.feature

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add `submit_url` response parameter to `*/msisdn/requestToken` endpoints.

docs/sample_config.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -940,6 +940,8 @@ uploads_path: "DATADIR/uploads"
940940
# by the Matrix Identity Service API specification:
941941
# https://matrix.org/docs/spec/identity_service/latest
942942
#
943+
# If a delegate is specified, the config option public_baseurl must also be filled out.
944+
#
943945
account_threepid_delegates:
944946
#email: https://example.com # Delegate email sending to example.org
945947
#msisdn: http://localhost:8090 # Delegate SMS sending to this local process

synapse/config/registration.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,8 @@ def generate_config_section(self, generate_secrets=False, **kwargs):
293293
# by the Matrix Identity Service API specification:
294294
# https://matrix.org/docs/spec/identity_service/latest
295295
#
296+
# If a delegate is specified, the config option public_baseurl must also be filled out.
297+
#
296298
account_threepid_delegates:
297299
#email: https://example.com # Delegate email sending to example.org
298300
#msisdn: http://localhost:8090 # Delegate SMS sending to this local process

synapse/handlers/identity.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,13 +452,23 @@ def requestMsisdnToken(
452452
id_server + "/_matrix/identity/api/v1/validate/msisdn/requestToken",
453453
params,
454454
)
455-
return data
456455
except HttpResponseException as e:
457456
logger.info("Proxied requestToken failed: %r", e)
458457
raise e.to_synapse_error()
459458
except TimeoutError:
460459
raise SynapseError(500, "Timed out contacting identity server")
461460

461+
assert self.hs.config.public_baseurl
462+
463+
# we need to tell the client to send the token back to us, since it doesn't
464+
# otherwise know where to send it, so add submit_url response parameter
465+
# (see also MSC2078)
466+
data["submit_url"] = (
467+
self.hs.config.public_baseurl
468+
+ "_matrix/client/unstable/add_threepid/msisdn/submit_token"
469+
)
470+
return data
471+
462472
@defer.inlineCallbacks
463473
def validate_threepid_session(self, client_secret, sid):
464474
"""Validates a threepid session with only the client secret and session ID

0 commit comments

Comments
 (0)