1
0

Remember mappings when we bind a 3pid using the internal sydent bind API (#66)

https://github.com/matrix-org/synapse-dinsic/pull/51 added an option that would automatically bind a user's threepid to a configured identity server after they had registered. Unfortunately, when you bind threepids, ideally you would store that mapping in the database so that later on you can remove those mappings when you deactivate an account.

We found that due the fact that we did not store these mappings, threepids were not unbound upon user account deactivation.

This PR fixes the issue by creating the mappings again, meaning they will again be removed upon account deactivation.
This commit is contained in:
Andrew Morgan
2020-10-14 11:18:29 +01:00
committed by GitHub
parent 722e1c016a
commit a2b8233a4e
3 changed files with 16 additions and 0 deletions

1
changelog.d/66.bugfix Normal file
View File

@@ -0,0 +1 @@
Create a mapping between user ID and threepid when binding via the internal Sydent bind API.

View File

@@ -1066,6 +1066,9 @@ class IdentityHandler(BaseHandler):
Raises:
HTTPResponseException: On a non-2xx HTTP response.
"""
# Extract the domain name from the IS URL as we store IS domains instead of URLs
id_server = urllib.parse.urlparse(id_server_url).hostname
# id_server_url is assumed to have no trailing slashes
url = id_server_url + "/_matrix/identity/internal/bind"
body = {
@@ -1074,8 +1077,14 @@ class IdentityHandler(BaseHandler):
"mxid": user_id,
}
# Bind the threepid
await self.http_client.post_json_get_json(url, body)
# Remember where we bound the threepid
await self.store.add_user_bound_threepid(
user_id=user_id, medium="email", address=email, id_server=id_server,
)
def create_id_access_token_header(id_access_token: str) -> List[str]:
"""Create an Authorization header for passing to SimpleHttpClient as the header value

View File

@@ -566,6 +566,12 @@ class RegistrationTestCase(unittest.HomeserverTestCase):
{"address": "alice@example.com", "medium": "email", "mxid": "@alice:test"},
)
# Check that we stored a mapping of this bind
bound_threepids = self.get_success(
self.store.user_get_bound_threepids("@alice:test")
)
self.assertListEqual(bound_threepids, [{"medium": "email", "address": email}])
def uia_register(self, expected_response: int, body: dict) -> FakeChannel:
"""Make a register request."""
request, channel = self.make_request(