Skip to content
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

Error in LDAP connection in "providers/ldap/util.py" #60

Closed
kastanas opened this issue Jul 15, 2022 · 2 comments · Fixed by #61
Closed

Error in LDAP connection in "providers/ldap/util.py" #60

kastanas opened this issue Jul 15, 2022 · 2 comments · Fixed by #61

Comments

@kastanas
Copy link
Contributor

In a new installation of Newdle, which uses Flask Multipass as an authentication backend, I observe the following error in the app when trying to connect to a OpenLDAP server in "providers/ldap/util.py":

[2022-07-15 16:34:51,965] ERROR in app: Request failed
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 1523, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python3.10/site-packages/flask/app.py", line 1509, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
  File "/usr/local/lib/python3.10/site-packages/webargs/core.py", line 452, in wrapper
    return func(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/newdle/api.py", line 228, in users
    total, data = search_users(name, email, 10)
  File "/usr/local/lib/python3.10/site-packages/newdle/core/auth.py", line 59, in search_users
    identities, total = multipass.search_identities_ex(
  File "/usr/local/lib/python3.10/site-packages/flask_multipass/core.py", line 399, in search_identities_ex
    result = list(itertools.islice(result_iter, limit))
  File "/usr/local/lib/python3.10/site-packages/flask_multipass/providers/ldap/providers.py", line 194, in search_identities
    with ldap_context(self.ldap_settings):
  File "/usr/local/lib/python3.10/contextlib.py", line 135, in __enter__
    return next(self.gen)
  File "/usr/local/lib/python3.10/site-packages/flask_multipass/providers/ldap/util.py", line 68, in ldap_context
    connection = ldap_connect(settings, use_cache=use_cache)
  File "/usr/local/lib/python3.10/site-packages/flask_multipass/providers/ldap/util.py", line 138, in ldap_connect
    ldap_connection.set_option(ldap.OPT_X_TLS, ldap.OPT_X_TLS_DEMAND if use_ldaps else ldap.OPT_X_TLS_NEVER)
AttributeError: module 'ldap' has no attribute 'OPT_X_TLS'

I have traced the error to using the latest version of python-ldap, version 3.4.2 (release 2022-07-06), which removes the deprecated option OPT_X_TLS, see the changelog.

Explicitly requiring at most python-ldap-3.4.1 makes everything work again.

@ThiefMaster
Copy link
Member

A PR to remove this option (and if needed bump the minimum python-ldap version) would be appreciated! ;)

@kastanas
Copy link
Contributor Author

Absolutely, I need to study a bit the way things are meant to be set up
after the deprecation and will submit it. :)

@ThiefMaster ThiefMaster linked a pull request Aug 11, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants