matrix-org / synapse

Synapse: Matrix homeserver written in Python/Twisted.
https://matrix-org.github.io/synapse
Apache License 2.0
11.82k stars 2.13k forks source link

Internal server error on login with ldap_auth_provider #2678

Closed jkolo closed 6 years ago

jkolo commented 6 years ago

Description

Cannot login or perform action require auth, if synapse using ldap_auth_provider.

Steps to reproduce

2017-11-15 21:31:15,769 - synapse.http.server - 139 - ERROR - DELETE-41647- Failed handle request synapse.http.server._async_render on <synapse.rest.ClientRestResource object at 0x7f1e1c2e8410>
: <XForwardedForRequest at 0x7f1de622cd40 method=DELETE uri=/_matrix/client/unstable/devices/PJPXHLTJDM?access_token=<redacted> clientproto=HTTP/1.0 site=8008>
Traceback (most recent call last):
  File "/srv/synapse/lib/python2.7/site-packages/synapse/http/server.py", line 116, in wrapped_request_handler
    yield request_handler(self, request, request_metrics)
  File "/srv/synapse/lib/python2.7/site-packages/twisted/internet/defer.py", line 1384, in _inlineCallbacks
    result = result.throwExceptionIntoGenerator(g)
  File "/srv/synapse/lib/python2.7/site-packages/twisted/python/failure.py", line 408, in throwExceptionIntoGenerator
    return g.throw(self.type, self.value, self.tb)
  File "/srv/synapse/lib/python2.7/site-packages/synapse/http/server.py", line 257, in _async_render
    callback_return = yield callback(request, **kwargs)
  File "/srv/synapse/lib/python2.7/site-packages/twisted/internet/defer.py", line 1384, in _inlineCallbacks
    result = result.throwExceptionIntoGenerator(g)
  File "/srv/synapse/lib/python2.7/site-packages/twisted/python/failure.py", line 408, in throwExceptionIntoGenerator
    return g.throw(self.type, self.value, self.tb)
  File "/srv/synapse/lib/python2.7/site-packages/synapse/rest/client/v2_alpha/devices.py", line 135, in on_DELETE
    ], body, self.hs.get_ip_from_request(request))
  File "/srv/synapse/lib/python2.7/site-packages/twisted/internet/defer.py", line 1384, in _inlineCallbacks
    result = result.throwExceptionIntoGenerator(g)
  File "/srv/synapse/lib/python2.7/site-packages/twisted/python/failure.py", line 408, in throwExceptionIntoGenerator
    return g.throw(self.type, self.value, self.tb)
  File "/srv/synapse/lib/python2.7/site-packages/synapse/handlers/auth.py", line 163, in check_auth
    result = yield self.checkers[login_type](authdict, clientip)
  File "/srv/synapse/lib/python2.7/site-packages/twisted/internet/defer.py", line 1386, in _inlineCallbacks
    result = g.send(result)
  File "/srv/synapse/lib/python2.7/site-packages/synapse/handlers/auth.py", line 280, in _check_password_auth
    "password": password,
ValueError: too many values to unpack

Version information

If not matrix.org:

agentpurple commented 6 years ago

I can confirm the issue

Josue-T commented 6 years ago

Me too

richvdh commented 6 years ago

thanks. This was introduced in 4c8f94a.

rexometer commented 6 years ago

Hi, thanks for the quick fix. When will version 0.25.1 be available in the Debian repo http://matrix.org/packages/debian/ ? Is it save to downgrade in the meantime?

Update: Is downgrading even possible? sudo apt-cache policy matrix-synapse lists only the latest package!?

Update2: https://github.com/matrix-org/synapse/commit/eded7084d2b829b07351c13cdb25221056f796a3 seems to be an easy fix. I added the fix to /usr/lib/python2.7/dist-packages/synapse/handlers/auth.py and deleted the auth.pyc and recompiled it, but still no luck. What else has to be changed?

Update3: Ok I figured it out, this fix https://github.com/matrix-org/synapse/pull/2683/commits/6f05de0e5ecd9e3f4d418232f0af7d1aef087426 is also necessary. Now it's up and running again.

rexometer commented 6 years ago

Hi, I now updated to 0.25.1 but this fix is missing: https://github.com/matrix-org/synapse/commit/6f05de0e5ecd9e3f4d418232f0af7d1aef087426

Without this I still get:

Dez 28 19:00:42 rexergie python[31746]: File "/usr/lib/python2.7/dist-packages/synapse/config/_base.py", line 338, in load_or_generate_config
Dez 28 19:00:42 rexergie python[31746]: generate_keys=generate_keys,
Dez 28 19:00:42 rexergie python[31746]: File "/usr/lib/python2.7/dist-packages/synapse/config/_base.py", line 382, in read_config_files
Dez 28 19:00:42 rexergie python[31746]: self.invoke_all("read_config", config)
Dez 28 19:00:42 rexergie python[31746]: File "/usr/lib/python2.7/dist-packages/synapse/config/_base.py", line 162, in invoke_all
Dez 28 19:00:42 rexergie python[31746]: results.append(getattr(cls, name)(self, *args, **kargs))
Dez 28 19:00:42 rexergie python[31746]: File "/usr/lib/python2.7/dist-packages/synapse/config/password_auth_providers.py", line 34, in read_config
Dez 28 19:00:42 rexergie python[31746]: 'config': ldap_config,
Dez 28 19:00:42 rexergie python[31746]: TypeError: 'builtin_function_or_method' object has no attribute '__getitem__'
rexergie@rexergie:~$ sudo apt-cache policy matrix-synapse
matrix-synapse:
  Installiert:           0.25.1-1
  Installationskandidat: 0.25.1-1
rexometer commented 6 years ago

This fix matrix-org/synapse@6f05de0 is still missing for me in the debian package 0.26.0-1. Is no one else using this package with LDAP? Or is it working for you guys (@jkolo @agentpurple)?

Josue-T commented 6 years ago

@rexometer did you have upgraded your synapse app to the last version ? Because since 4 month ago the app moved from the debian package to pythonvirtualenvironnement.

rexometer commented 6 years ago

thanks @Josue-T for the fast reply. Not sure, I installed it via package-manager (added the repo http://matrix.org/packages/debian/) maybe 1,5 years ago and always updated it via apt-get. What else is needed to correctly update it?

misse commented 6 years ago

This affects me as well, I've followed the pip upgrade guide and I can't issue new logins through LDAP. My log only show me the 500 though it doesn't show me the trace from python, please instruct me on how to find more specific log entries.

matrix-synapse (0.26.0)

richvdh commented 6 years ago

For the record: this issue (internal server error) was introduced in v0.25.0 by 4c8f94a and fixed by #2679 in v0.26.0.

I have opened (and closed) a separate issue #2912 for the problem mentioned by @rexometer.

@Josue-T wrote:

Because since 4 month ago the app moved from the debian package to pythonvirtualenvironnement.

I don't know what this is referring to, and it doesn't really make much sense. There has been no moving of anything from a debian package to anywhere else. If you have installed with debian, then please continue to upgrade via debian - attempting to use pip to upgrade an installation made by the debian package will certainly lead to brokenness.

@misse you'll get better support for synapse administration in the matrix rooms than by commenting on a resolved issue, but your homeserver.log should show the python stacktrace.

misse commented 6 years ago

Thanks @richvdh

My homeserver.log doesn't show the stack trace and I still have the issue that is supposed to be fixed. I.e. I can't log in users via LDAP, I get the m_unknown message for riot but can't find anything else. I'll try to join the synapse admin room to figure this out.

misse commented 6 years ago

Issue solved by upgrading rest_auth_provider.py to the latest version (46e68c4cbeb4c027cf4d65e4ae883fdabe8762c1), upgrading mxisd to 0.6.1 and restarting synapse