kamax-matrix / mxisd

Federated Matrix Identity Server
GNU Affero General Public License v3.0
224 stars 114 forks source link

LDAP User Directory search fails when try to search via Matrix ID staring with '@' #79

Closed MurzNN closed 6 years ago

MurzNN commented 6 years ago

When we try to find Matrix user by Matrix ID staring with '@', eg @alice - LDAP search returns empty result, because usernames in LDAP database don't contain @ symbol.

май 15 09:46:03 tad mxisd[2840]: .200  INFO [nio-8090-exec-3]    i.k.m.directory.DirectoryManager : Performing search for '@alice'
май 15 09:46:03 tad mxisd[2840]: .200  INFO [nio-8090-exec-3]    i.k.m.directory.DirectoryManager : Original request URL: http://homeserver.ru/_matrix/client/r0/user_directory/search
май 15 09:46:03 tad mxisd[2840]: .200  INFO [nio-8090-exec-3]    i.k.m.directory.DirectoryManager : Querying HS at http://localhost:8008/_matrix/client/r0/user_directory/search
май 15 09:46:03 tad mxisd[2840]: .208  INFO [nio-8090-exec-3]    i.k.m.directory.DirectoryManager : Found 0 match(es) in HS for '@alice'
май 15 09:46:03 tad mxisd[2840]: .208  INFO [nio-8090-exec-3]    i.k.m.directory.DirectoryManager : Using Directory provider LdapDirectoryProvider
май 15 09:46:03 tad mxisd[2840]: .208  INFO [nio-8090-exec-3]  i.k.m.b.ldap.LdapDirectoryProvider : Performing LDAP directory search on display name using '@alice'
май 15 09:46:03 tad mxisd[2840]: .293  INFO [nio-8090-exec-3]    i.k.m.directory.DirectoryManager : Display name: found 0 match(es) for '@alice'
май 15 09:46:03 tad mxisd[2840]: .293  INFO [nio-8090-exec-3]  i.k.m.b.ldap.LdapDirectoryProvider : Performing LDAP directory search on 3PIDs using '@alice'
май 15 09:46:03 tad mxisd[2840]: .368  INFO [nio-8090-exec-3]    i.k.m.directory.DirectoryManager : Threepid: found 0 match(es) for '@alice'
май 15 09:46:03 tad mxisd[2840]: .368  INFO [nio-8090-exec-3]    i.k.m.directory.DirectoryManager : Total matches: 0 - limited? false

As workaround for this problem - maybe try to remove leading @ symbols from string before executing LDAP search?

MurzNN commented 6 years ago

This is right only for new LDAP users, that is not do first login into Matrix, so Matrix ID is missed in Matrix server database. So let's close it.

MurzNN commented 6 years ago

After next query from users I recheck this and see that this issue is true for already exists in Synapse server database too, if we have no rooms with this contact.

So if we have private chat with person, Riot (or Synapse?) seems do auto-complete it without using mxisd, so seems all works well.

But if this person is not known for current user (user have no rooms with this person) - autocomplete via mxid string (starting with @) not works.

This can be solved at mxisd side via parsing strings, started with @ and compare it with string like @[ldap.attribute.name]:[matrix.domain]. What do you think about this solution?

maxidorius commented 6 years ago

Good catch, will handle it correctly with:

maxidorius commented 6 years ago

Fixed in v1.1.1