diff --git a/CHANGELOG.md b/CHANGELOG.md index 4a26e5395..f2aee269d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,8 @@ The format is based on the [KeepAChangeLog] project. ### Changed - [#134] ``l_registration_enpoint`` has been deprecated, use ``create_registration`` instead +- [#457] pyldap is now an optional dependency. ``oic.utils.authn.ldapc`` and ``oic.utils.userinfo.ldap_info`` raise + ``ImportError`` on import if ``pyldap`` is not present ### Fixed - [#430] Audience of a client assertion is endpoint dependent. @@ -30,6 +32,7 @@ The format is based on the [KeepAChangeLog] project. [#446]: https://github.com/OpenIDC/pyoidc/issues/446 [#449]: https://github.com/OpenIDC/pyoidc/issues/449 [#134]: https://github.com/OpenIDC/pyoidc/issues/134 +[#457]: https://github.com/OpenIDC/pyoidc/issues/457 ## 0.12.0 [2017-09-25] diff --git a/Pipfile b/Pipfile index 82f0c0b8b..a55f961b8 100644 --- a/Pipfile +++ b/Pipfile @@ -23,7 +23,6 @@ cryptography = "*" future = "*" pyOpenSSL = "*" pyjwkest = "*" -pyldap = "*" requests = "*" Beaker = "*" Mako = "*" diff --git a/Pipfile.lock b/Pipfile.lock index 9e47e5a8c..2cbca752d 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -182,12 +182,6 @@ ], "version": "==1.4.0" }, - "pyldap": { - "hashes": [ - "sha256:064ec1ec7db9ff3b941d83f94bacbe896be944951db548d774ad9cafdafd7887" - ], - "version": "==2.4.45" - }, "pyopenssl": { "hashes": [ "sha256:07a2de1a54de07448732a81e38a55df7da109b2f47f599f8bb35b0cbec69d4bd", diff --git a/setup.py b/setup.py index c8aa7573f..7394af7a9 100755 --- a/setup.py +++ b/setup.py @@ -75,6 +75,7 @@ def run_tests(self): 'testing': tests_requires, 'docs': ['Sphinx', 'sphinx-autobuild'], 'quality': ['pylama', 'isort'], + 'ldap_authn': ['pyldap'], }, install_requires=[ "requests", diff --git a/src/oic/utils/authn/ldapc.py b/src/oic/utils/authn/ldapc.py index c1389375c..4da793b80 100644 --- a/src/oic/utils/authn/ldapc.py +++ b/src/oic/utils/authn/ldapc.py @@ -1,4 +1,7 @@ -import ldap +try: + import ldap +except ImportError: + raise ImportError('This module can be used only with pyldap installed.') from oic.exception import PyoidcError from oic.utils.authn.user import UsernamePasswordMako diff --git a/src/oic/utils/userinfo/ldap_info.py b/src/oic/utils/userinfo/ldap_info.py index 176cd0d03..aac4b40e6 100644 --- a/src/oic/utils/userinfo/ldap_info.py +++ b/src/oic/utils/userinfo/ldap_info.py @@ -1,6 +1,9 @@ -import logging +try: + import ldap +except ImportError: + raise ImportError('This module can be used only with pyldap installed.') -import ldap +import logging from oic.utils.sanitize import sanitize from oic.utils.userinfo import UserInfo