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

Mainline username generation #121

Merged
merged 5 commits into from
Jan 27, 2022
Merged

Mainline username generation #121

merged 5 commits into from
Jan 27, 2022

Conversation

babolivier
Copy link
Contributor

Note to reviewer:

1st commit is a cherry-pick of matrix-org/synapse#11743
2nd commit is a cherry-pick of matrix-org/synapse#11790
3rd commit removes the now obsolete register_mxid_from_3pid setting introduced in matrix-org/synapse#3096
4th commit removes some hacks specific to synapse-dinsic that were made to better ignore username at registration that aren't needed anymore.

Note to ops:

This change removes the register_mxid_from_3pid setting. To reproduce its behaviour, the new inhibit_user_in_use_error setting must be set to true and https://github.com/matrix-org/synapse-username-from-threepid must be installed and configured with threepid_to_use set to the same value as register_mxid_from_3pid was, and fail_if_not_found set to true.

babolivier and others added 5 commits January 26, 2022 18:00
…743)

This is mostly motivated by the tchap use case, where usernames are automatically generated from the user's email address (in a way that allows figuring out the email address from the username). Therefore, it's an issue if we respond to requests on /register and /register/available with M_USER_IN_USE, because it can potentially leak email addresses (which include the user's real name and place of work).

This commit adds a flag to inhibit the M_USER_IN_USE errors that are raised both by /register/available, and when providing a username early into the registration process. This error will still be raised if the user completes the registration process but the username conflicts. This is particularly useful when using modules (matrix-org/synapse#11790 adds a module callback to set the username of users at registration) or SSO, since they can ensure the username is unique.

More context is available in the PR that introduced this behaviour to synapse-dinsic: #48 - as well as the issue in the matrix-dinsic repo: matrix-org/matrix-dinsic#476
This is in the context of mainlining the Tchap fork of Synapse. Currently in Tchap usernames are derived from the user's email address (extracted from the UIA results, more specifically the m.login.email.identity step).
This change also exports the check_username method from the registration handler as part of the module API, so that a module can check if the username it's trying to generate is correct and doesn't conflict with an existing one, and fallback gracefully if not.

Co-authored-by: David Robertson <davidr@element.io>
@babolivier babolivier requested a review from a team as a code owner January 26, 2022 18:02
@DMRobertson DMRobertson self-assigned this Jan 27, 2022
Copy link
Contributor

@DMRobertson DMRobertson left a comment

Choose a reason for hiding this comment

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

Seems reasonable.

3rd commit removes the now obsolete register_mxid_from_3pid setting introduced in matrix-org/synapse#3096

To check I understand:

  • this commit never made it into synapse mainline, just the dinsic branch?
  • it's now obsolete because mainline has this functionality (with a module)?

@babolivier
Copy link
Contributor Author

babolivier commented Jan 27, 2022

  • this commit never made it into synapse mainline, just the dinsic branch?

This is correct.

  • it's now obsolete because mainline has this functionality (with a module)?

The combination of the new configuration flag + the module capability is what makes it obsolete.

@babolivier babolivier merged commit 717ab47 into dinsic Jan 27, 2022
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