matrix-org / synapse

Synapse: Matrix homeserver written in Python/Twisted.
https://matrix-org.github.io/synapse
Apache License 2.0
11.83k stars 2.12k forks source link

Allow the Admin API to create a user where the same localpart exists with uppercase letters #11426

Open Twi1ightSparkle opened 2 years ago

Twi1ightSparkle commented 2 years ago

Description

Note, I have added a space after the @ in all example Matrix IDs in this issue, this is to avoid pinging the existing @ Alice user on GitHub.

Use case

There are a handful of users who have uppercase letters in their Matrix ID from before Synapse started enforcing lowercase only. They may want to create a new Matrix account with a spec compliant all lowercase localpart. Ie. they currently have @ Alice:example.com, but want to register @ alice:example.com

Proposed solution

Adding a feature to the User creation Admin API to allow registering @ alice:example.com when @ Alice:example.com already exists.

Authentication endpoints may also need updating when implementing this as these may ignore casing currently.

Security considerations

The localpart availability checker and both client-server and Admin user creation API endpoints ignore casing today and should continue doing this by default.

We should add a parameter to the API something along the lines of &ignore_localpart_casing_duplicates=true. This need to be an optional parameter and default to false if not set

Twi1ightSparkle commented 2 years ago

For additional context, see the discussion starting here (sorry to everyone not working for Element and don't have access to this internal room)

paride commented 2 years ago

I'm the requestor of the username capitalization change (s/Paride/paride/) that led to opening this issue (thanks @Twi1ightSparkle). I'm subscribed to it and looking forward making my username spec compliant.

reivilibre commented 2 years ago

Worth noting: _find_user_id_and_pwd_hash does a case-insensitive login using LOWER on both sides. It would need changing to try the exact match first or something like that.

callahad commented 2 years ago

Notes from discussion today:

paride commented 2 years ago

Or maybe the "one-way gate" could cause the deactivation of the non-compliant ID when the compliant one is registered. This would eliminate many edge cases (e.g. a@example and A@example being simultaneously in a room). The identify verification @Twi1ightSparkle mentioned in the issue description should prevent unwanted account deactivations.

Twi1ightSparkle commented 2 years ago

Or maybe the "one-way gate" could cause the deactivation of the non-compliant ID when the compliant one is registered.

You probably don't want this for several reasons. For example: you might wanna have both accounts for a period to migrate your rooms and encryption keys. And making sure all is well on the new account before deactivating the old one. Account deactivation is not easily reversed.

callahad commented 2 years ago

Not sure if we'll get to this before year's end, but we should soon. It seems like a valuable thing to have in terms of shaking out unexpected corner cases in our handling of MXIDs, and malicious / buggy / chaotic server admins could do this already, so we'll have to handle it on the network somehow.

paride commented 2 years ago

Hi, any news on this one? Looks like there's a similar issue in dendrite: https://github.com/matrix-org/dendrite/issues/2073.