matrix-org / matrix-synapse-ldap3

An LDAP3 auth provider for Synapse
Apache License 2.0
127 stars 46 forks source link

PyAsn1Error with ldap3==2.4 #45

Closed mweinelt closed 4 years ago

mweinelt commented 6 years ago

After upgrading to pyldap==2.4 logging in triggers the following exception. Downgrading to pyldap==2.3 makes it work again.

Failed handle request synapse.http.server._async_render on <synapse.rest.ClientRestResource object at 0x7fda8dc80450>: <XForwardedForRequest at 0x7fda7c539680 method=POST uri=/_matrix/client/r0/login clientproto=HTTP/1.1 site=8008>: Traceback (most recent call last):
to=HTTP/1.1 site=8008>: Traceback (most recent call last):
File "/home/matrix/.synapse/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 653, in _runCallbacks
current.result = callback(current.result, *args, **kw)
File "/home/matrix/.synapse/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 1442, in gotResult
_inlineCallbacks(r, g, deferred)
File "/home/matrix/.synapse/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 1384, in _inlineCallbacks
result = result.throwExceptionIntoGenerator(g)
File "/home/matrix/.synapse/local/lib/python2.7/site-packages/twisted/python/failure.py", line 408, in throwExceptionIntoGenerator
return g.throw(self.type, self.value, self.tb)
--- <exception caught here> ---
File "/home/matrix/git/synapse/synapse/http/server.py", line 117, in wrapped_request_handler
yield request_handler(self, request, request_metrics)
File "/home/matrix/.synapse/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 1384, in _inlineCallbacks
result = result.throwExceptionIntoGenerator(g)
File "/home/matrix/.synapse/local/lib/python2.7/site-packages/twisted/python/failure.py", line 408, in throwExceptionIntoGenerator
return g.throw(self.type, self.value, self.tb)
File "/home/matrix/git/synapse/synapse/http/server.py", line 263, in _async_render
callback_return = yield callback(request, **kwargs)
File "/home/matrix/.synapse/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 1384, in _inlineCallbacks
result = result.throwExceptionIntoGenerator(g)
File "/home/matrix/.synapse/local/lib/python2.7/site-packages/twisted/python/failure.py", line 408, in throwExceptionIntoGenerator
return g.throw(self.type, self.value, self.tb)
File "/home/matrix/git/synapse/synapse/rest/client/v1/login.py", line 154, in on_POST
result = yield self._do_other_login(login_submission)
File "/home/matrix/.synapse/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 1384, in _inlineCallbacks
result = result.throwExceptionIntoGenerator(g)
File "/home/matrix/.synapse/local/lib/python2.7/site-packages/twisted/python/failure.py", line 408, in throwExceptionIntoGenerator
return g.throw(self.type, self.value, self.tb)
File "/home/matrix/git/synapse/synapse/rest/client/v1/login.py", line 224, in _do_other_login
login_submission,
File "/home/matrix/.synapse/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 1384, in _inlineCallbacks
result = result.throwExceptionIntoGenerator(g)
File "/home/matrix/.synapse/local/lib/python2.7/site-packages/twisted/python/failure.py", line 408, in throwExceptionIntoGenerator
return g.throw(self.type, self.value, self.tb)
File "/home/matrix/git/synapse/synapse/handlers/auth.py", line 639, in validate_login
qualified_user_id, password,
File "/home/matrix/.synapse/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 1384, in _inlineCallbacks
result = result.throwExceptionIntoGenerator(g)
File "/home/matrix/.synapse/local/lib/python2.7/site-packages/twisted/python/failure.py", line 408, in throwExceptionIntoGenerator
return g.throw(self.type, self.value, self.tb)
File "/home/matrix/git/matrix-synapse-ldap3/ldap_auth_provider.py", line 113, in check_password
server=server, localpart=localpart, password=password
File "/home/matrix/.synapse/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 1384, in _inlineCallbacks
result = result.throwExceptionIntoGenerator(g)
File "/home/matrix/.synapse/local/lib/python2.7/site-packages/twisted/python/failure.py", line 408, in throwExceptionIntoGenerator
return g.throw(self.type, self.value, self.tb)
File "/home/matrix/git/matrix-synapse-ldap3/ldap_auth_provider.py", line 354, in _ldap_authenticated_search
if not (yield threads.deferToThread(conn.bind)):
File "/home/matrix/.synapse/local/lib/python2.7/site-packages/twisted/python/threadpool.py", line 250, in inContext
result = inContext.theWork()
File "/home/matrix/.synapse/local/lib/python2.7/site-packages/twisted/python/threadpool.py", line 266, in <lambda>
inContext.theWork = lambda: context.call(ctx, func, *args, **kw)
File "/home/matrix/.synapse/local/lib/python2.7/site-packages/twisted/python/context.py", line 122, in callWithContext
return self.currentContext().callWithContext(ctx, func, *args, **kw)
File "/home/matrix/.synapse/local/lib/python2.7/site-packages/twisted/python/context.py", line 85, in callWithContext
return func(*args,**kw)
File "/home/matrix/.synapse/local/lib/python2.7/site-packages/ldap3/core/connection.py", line 427, in bind
response = self.post_send_single_response(self.send('bindRequest', request, controls))
File "/home/matrix/.synapse/local/lib/python2.7/site-packages/ldap3/strategy/sync.py", line 122, in post_send_single_response
responses, result = self.get_response(message_id)
File "/home/matrix/.synapse/local/lib/python2.7/site-packages/ldap3/strategy/base.py", line 298, in get_response
responses = self._get_response(message_id)
File "/home/matrix/.synapse/local/lib/python2.7/site-packages/ldap3/strategy/sync.py", line 168, in _get_response
dict_response = self.decode_response(ldap_resp)
File "/home/matrix/.synapse/local/lib/python2.7/site-packages/ldap3/strategy/base.py", line 403, in decode_response
result = bind_response_to_dict(component)
File "/home/matrix/.synapse/local/lib/python2.7/site-packages/ldap3/operation/bind.py", line 119, in bind_response_to_dict
'saslCreds': bytes(response['serverSaslCreds']) if response['serverSaslCreds'] is not None else None}
File "/home/matrix/.synapse/local/lib/python2.7/site-packages/pyasn1/type/univ.py", line 843, in __str__
return str(self._value)
File "/home/matrix/.synapse/local/lib/python2.7/site-packages/pyasn1/type/base.py", line 199, in plug
raise error.PyAsn1Error('Attempted "%s" operation on ASN.1 schema object' % name)
pyasn1.error.PyAsn1Error: Attempted "__str__" operation on ASN.1 schema object
h3ndrik commented 6 years ago

i'm affected, too. using debian (testing) packages, i had to downgrade python-ldap3 python-pyasn1 python-pyasn1-modules to the stretch versions to make it work.

jaywink commented 4 years ago

The combination of:

seems to work fine. Since this issue concerns old versions of the dependencies, will close it.