Skip to content

Commit

Permalink
Merge pull request #163 from matrix-org/shay/normalize_username
Browse files Browse the repository at this point in the history
Normalize username before interacting with Synapse
  • Loading branch information
H-Shay authored May 6, 2022
2 parents ed863ba + bc87e5a commit 4ae8c9a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions ldap_auth_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ async def check_auth(
except ActiveDirectoryUPNException:
return None

localpart = localpart.lower()

try:
server = self._get_server()
logger.debug("Attempting LDAP connection with %s", self.ldap_uris)
Expand Down
9 changes: 9 additions & 0 deletions tests/test_simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,15 @@ def test_no_pwd(self):
)
self.assertFalse(result)

@defer.inlineCallbacks
def test_uppercase_username(self):
result = yield defer.ensureDeferred(
self.auth_provider.check_auth(
"BOB", "m.login.password", {"password": "secret"}
)
)
self.assertEqual(result, "@bob:test")


class LdapSearchTestCase(unittest.TestCase):
@defer.inlineCallbacks
Expand Down

0 comments on commit 4ae8c9a

Please sign in to comment.