Skip to content

Add numeric username support #179

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion ldap_auth_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,10 @@ async def check_auth(
# Default display name for the user, if a new account is registered.
default_display_name = username
# Local part of Matrix ID which will be used in registration process
localpart = username
if username.isnumeric():
localpart = f"U{username}"
else:
localpart = username
Comment on lines +126 to +129
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 this implies conflicts if you have both 1234 and U1234 as unique usernames in your system?

Copy link
Author

Choose a reason for hiding this comment

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

Yes, that is correct. I cannot imagine how to solve this problem at this time.

Copy link
Member

Choose a reason for hiding this comment

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

My initial thought would be to add a configuration prefix or something that gets added to all usernames. (Or do something similar to the mapping that the SSO providers do.)

Copy link
Author

Choose a reason for hiding this comment

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

This can do the trick. Also, I will add one more change to overcome a bug while getting encryption keys. When you try to download backup keys, it asks for the password. Even if you enter it correctly, synapse says it is invallid. This is because the module tries to send the username with the prefix, however there is no match in LDAP for the username with prefix. I had also fixed this problem and will publish another change.


if self.ldap_active_directory:
try:
Expand Down