kamax-matrix / matrix-synapse-rest-password-provider

Password Provider for Synapse fetching data from a REST endpoint
GNU Affero General Public License v3.0
36 stars 40 forks source link

AttributeError: 'Handlers' object has no attribute 'profile_handler' #3

Closed muellermartin closed 6 years ago

muellermartin commented 6 years ago

I'm trying to get the synapse Homeserver to work with a LDAP directory as authentication provider and mxisd seems to be appropriate for that. According to the manual this REST authentication provider is needed to make this work. Although the LDAP query seems to work, I get this exception in the synapse log:

2017-10-29 20:26:46,264 - rest_auth_provider - 46 - INFO - POST-0- Got password check for @mmueller:localhost
2017-10-29 20:26:46,296 - rest_auth_provider - 62 - INFO - POST-0- User @mmueller:localhost authenticated
2017-10-29 20:26:46,299 - rest_auth_provider - 76 - INFO - POST-0- User @mmueller:localhost already exists, registration skipped
2017-10-29 20:26:46,300 - rest_auth_provider - 79 - INFO - POST-0- Handling profile data
2017-10-29 20:26:46,301 - synapse.http.server - 139 - ERROR - POST-0- Failed handle request synapse.http.server._async_render on <synapse.rest.ClientRestResource object at 0x7fd4074ce1d0>: <XForwardedForRequest at 0x7fd406f531b8 method=POST uri=/_matrix/client/r0/login? clientproto=HTTP/1.1 site=8008>
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/synapse/http/server.py", line 116, in wrapped_request_handler
    yield request_handler(self, request, request_metrics)
  File "/usr/local/lib/python2.7/dist-packages/twisted/internet/defer.py", line 1384, in _inlineCallbacks
    result = result.throwExceptionIntoGenerator(g)
  File "/usr/local/lib/python2.7/dist-packages/twisted/python/failure.py", line 408, in throwExceptionIntoGenerator
    return g.throw(self.type, self.value, self.tb)
  File "/usr/local/lib/python2.7/dist-packages/synapse/http/server.py", line 257, in _async_render
    callback_return = yield callback(request, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/twisted/internet/defer.py", line 1384, in _inlineCallbacks
    result = result.throwExceptionIntoGenerator(g)
  File "/usr/local/lib/python2.7/dist-packages/twisted/python/failure.py", line 408, in throwExceptionIntoGenerator
    return g.throw(self.type, self.value, self.tb)
  File "/usr/local/lib/python2.7/dist-packages/synapse/rest/client/v1/login.py", line 140, in on_POST
    result = yield self.do_password_login(login_submission)
  File "/usr/local/lib/python2.7/dist-packages/twisted/internet/defer.py", line 1384, in _inlineCallbacks
    result = result.throwExceptionIntoGenerator(g)
  File "/usr/local/lib/python2.7/dist-packages/twisted/python/failure.py", line 408, in throwExceptionIntoGenerator
    return g.throw(self.type, self.value, self.tb)
  File "/usr/local/lib/python2.7/dist-packages/synapse/rest/client/v1/login.py", line 221, in do_password_login
    password=login_submission["password"],
  File "/usr/local/lib/python2.7/dist-packages/twisted/internet/defer.py", line 1384, in _inlineCallbacks
    result = result.throwExceptionIntoGenerator(g)
  File "/usr/local/lib/python2.7/dist-packages/twisted/python/failure.py", line 408, in throwExceptionIntoGenerator
    return g.throw(self.type, self.value, self.tb)
  File "/usr/local/lib/python2.7/dist-packages/synapse/handlers/auth.py", line 519, in _check_password
    is_valid = yield provider.check_password(user_id, password)
  File "/usr/local/lib/python2.7/dist-packages/twisted/internet/defer.py", line 1386, in _inlineCallbacks
    result = g.send(result)
  File "/usr/lib/python2.7/dist-packages/rest_auth_provider.py", line 82, in check_password
    store = yield self.account_handler.hs.get_handlers().profile_handler.store
AttributeError: 'Handlers' object has no attribute 'profile_handler'

Judging from the traceback, this issue seems to be caused by line 82 in rest_auth_provider.py

I was able to fix this issue by replacing that line with the following code:

            store = yield self.account_handler.hs.get_datastore()
maxidorius commented 6 years ago

Yes, synapse had a breaking change. Use tags:

muellermartin commented 6 years ago

Hm, so should this work with the master branch of this repository?

maxidorius commented 6 years ago

It should. what version of synapse do you have?

muellermartin commented 6 years ago

I'm using the Docker image silviof/docker-matrix which pulls the master branch of synapse.

maxidorius commented 6 years ago

They broke it again then :( To avoid having to constantly change the code, I only deal with released version of synapse, not master or develop.

muellermartin commented 6 years ago

Just for reference: The master's HEAD of synapse I'm currently using is at 632baf799ea876d2346e934dce90d6a24cb92e37.

To avoid having to constantly change the code, I only deal with released version of synapse, not master or develop.

I can totally understand that and this is the only sane thing to do ;)

maxidorius commented 6 years ago

Thanks for the pointers and the fix! Please leave this issue open so I can revisit it at the next release and fix.

muellermartin commented 6 years ago

You're welcome and thanks for your work on this authenticator and mxisd! I'll leave it open then.

maxidorius commented 6 years ago

Seems like newer stable versions are not affected, and was only a one-off in the master branch, closing.