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

Remove email addresses / phone numbers from ID servers when they're removed from synapse #3276

Merged
merged 13 commits into from
Jun 11, 2018

Conversation

dbkr
Copy link
Member

@dbkr dbkr commented May 24, 2018

On account deactivation and 3pid deletion.

Implements unbind API as per spec proposal: matrix-org/matrix-spec-proposals#1194
Related sydent PR: matrix-org/sydent#67

@@ -825,6 +825,15 @@ def delete_threepid(self, user_id, medium, address):
if medium == 'email':
address = address.lower()

identity_handler = self.hs.get_handlers().identity_handler
identity_handler.unbind_threepid(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing a yield ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch

yield self.store.user_delete_threepid(
user_id, threepid['medium'], threepid['address'],
)

# first delete any devices belonging to the user, which will also
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/first//

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -138,6 +140,44 @@ def bind_threepid(self, creds, mxid):
data = json.loads(e.msg)
defer.returnValue(data)

@defer.inlineCallbacks
def unbind_threepid(self, mxid, threepid):
yield run_on_reactor()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cargoculting probably. removed.

@@ -138,6 +140,44 @@ def bind_threepid(self, creds, mxid):
data = json.loads(e.msg)
defer.returnValue(data)

@defer.inlineCallbacks
def unbind_threepid(self, mxid, threepid):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can haz docstring pls

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -264,14 +264,19 @@ def _request(self, destination, method, path,
defer.returnValue(response)

def sign_request(self, destination, method, url_bytes, headers_dict,
content=None):
content=None, destination_is=None):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can haz doc for new param pls

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@richvdh richvdh assigned dbkr and unassigned richvdh Jun 1, 2018
@dbkr dbkr assigned richvdh and unassigned dbkr Jun 4, 2018
@richvdh richvdh assigned dbkr and richvdh and unassigned richvdh and dbkr Jun 5, 2018
threepid (dict): Dict with medium & address of binding to be removed

Returns:
Deferred
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deferred what?

Deferred[bool] I guess, but what does the bool mean?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

destination_is (str): As 'destination', but if the destination is an identity server

Returns:
Deferred
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think not

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops

"""
Signs a request by adding an Authorization header to headers_dict
Args:
destination (str): The desination home server of the request. May be null if the
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/null/None/

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

"""
Signs a request by adding an Authorization header to headers_dict
Args:
destination (str): The desination home server of the request. May be null if the
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these are all meant to be bytes rather than str fwiw. Especially url_bytes which you are carefully .encodeing

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

point

destination (str): The desination home server of the request. May be null if the
destination is an identity server, in which case destination_is must be non-null.
method (str): The HTTP method of the request
url_bytes (str): ?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the uri path of the request

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

request["destination"] = destination

if destination_is is not None:
request["destination_is"] = destination_is
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so what is the logic behind putting this in a different field?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To make sure it's always distinct from a request to a homeserver with the same name, eg. that you could reuse the same signature for a request to the matrix.org HS to sign the same request to the matrix.org IS as they're different destinations (although in practice are unlikely to support the same request).

@richvdh
Copy link
Member

richvdh commented Jun 5, 2018

also your pep8 is bad

@richvdh richvdh assigned dbkr and unassigned richvdh Jun 5, 2018
@dbkr dbkr assigned richvdh and unassigned dbkr Jun 5, 2018
@dbkr
Copy link
Member Author

dbkr commented Jun 5, 2018

ptal!

Copy link
Member

@richvdh richvdh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm apart from doc nits

url_bytes (str): ?
destination (bytes): The desination home server of the request. May be None
if the destination is an identity server, in which case destination_is
must be non-null.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/null/None/

destination is an identity server, in which case destination_is must be non-null.
method (str): The HTTP method of the request
url_bytes (str): ?
destination (bytes): The desination home server of the request. May be None
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bytes|None

content (str): The body of the request
destination_is (str): As 'destination', but if the destination is an identity server
content (bytes): The body of the request
destination_is (bytes): As 'destination', but if the destination is an
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bytes|None

@richvdh
Copy link
Member

richvdh commented Jun 5, 2018

could you try to update the PR summary to something which will make more sense when it lands in the changelog?

@richvdh richvdh assigned dbkr and unassigned richvdh Jun 5, 2018
@dbkr dbkr changed the title Use the 3pid unbind endpoint to remove 3pids from IS Remove email addresses / phone numbers from ID servers when they're removed from synapse Jun 6, 2018
@dbkr dbkr merged commit 187a546 into develop Jun 11, 2018
@hawkowl hawkowl deleted the dbkr/unbind branch September 20, 2018 14:00
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants