diff --git a/ldap_auth_provider.py b/ldap_auth_provider.py index 97a2b7b..77d668b 100644 --- a/ldap_auth_provider.py +++ b/ldap_auth_provider.py @@ -20,6 +20,9 @@ import ldap3.core.exceptions import logging +import synapse + +from pkg_resources import parse_version __version__ = "0.1.3" @@ -281,11 +284,21 @@ def register_user(self, localpart, name, email_address): emails = [email_address] if email_address is not None else [] # create account - user_id, access_token = ( - yield self.account_handler.register( - localpart=localpart, displayname=name, emails=emails, + # check if we're running a version of synapse that supports binding emails + # from password providers + if parse_version(synapse.__version__) <= parse_version("0.99.3"): + user_id, access_token = ( + yield self.account_handler.register( + localpart=localpart, displayname=name, + ) + ) + else: + # If Synapse has support, bind emails + user_id, access_token = ( + yield self.account_handler.register( + localpart=localpart, displayname=name, emails=emails, + ) ) - ) logger.info( "Registration based on LDAP data was successful: %s", diff --git a/setup.py b/setup.py index e925d30..cfaea94 100755 --- a/setup.py +++ b/setup.py @@ -49,6 +49,9 @@ def exec_file(path_segments, name): "ldap3>=2.6", "service_identity", ], + test_require=[ + "matrix-synapse", + ], long_description=read_file(("README.rst",)), classifiers=[ 'Development Status :: 4 - Beta', diff --git a/tox.ini b/tox.ini index 10d9be1..79c8284 100644 --- a/tox.ini +++ b/tox.ini @@ -6,6 +6,7 @@ deps = Twisted>=15.1 mock ldaptor + matrix-synapse ldap0: ldap3<1.0 ldap1: ldap3>=1.0,<2.0 ldap2: ldap3>=2.0