jsxc / xmpp-cloud-auth

:key: Authentication hub for Nextcloud+JSXC→Prosody, ejabberd, saslauthd, Postfix
https://www.jsxc.org
MIT License
60 stars 18 forks source link

No JSON object could be decoded #3

Closed wargreen closed 7 years ago

wargreen commented 7 years ago

Hello, and thanks for the code !

When i try to log in to the tchat via nextcloud it fail and i got, in extauth.err :

   obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python2.7/json/decoder.py", line 382, in raw_decode
    raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded
Traceback (most recent call last):
  File "/opt/ejabberd-cloud-auth/external_cloud.py", line 102, in <module>
    data = from_ejabberd()
  File "/opt/ejabberd-cloud-auth/external_cloud.py", line 18, in from_ejabberd
    (size,) = unpack('>h', input_length)
struct.error: unpack requires a string argument of length 2

Maybe my ejabberd.yml is wrong ? extauth_program: "/opt/ejabberd-cloud-auth/external_cloud.py --url=https://cloud.lebib.org/ocs/v2.php/cloud/ --secret=********* "

sualko commented 7 years ago

The url looks wrong. Where does it come from? Which cloud and version do you use?

wargreen commented 7 years ago

Oops, i've take the url from https://docs.nextcloud.com/server/11/admin_manual/configuration_user/user_provisioning_api.html and i've tried "v2" after this message :

2017-03-09 14:22:10.218 [error] <0.548.0>@extauth:loop:130 extauth call '[<<"auth">>,<<"wargreen">>,<<"lebib.org">>,<<"**********">>]' didn't receive response
2017-03-09 14:22:10.218 [info] <0.552.0>@ejabberd_c2s:wait_for_feature_request:757 ({socket_state,ejabberd_http_bind,{http_bind,<0.551.0>,{{0,0,0,0,0,0,0,1},51901}},ejabberd_http_bind}) Failed authentication for wargreen@lebib.org from IP ::1
2017-03-09 14:22:40.222 [info] <0.551.0>@ejabberd_http_bind:handle_info:519 Session timeout. Closing the HTTP bind session: <<"944cc0885d7ebcd00fa323c86feea36381971b54">>

Note, the password is in clear text in the log... It's a security issue in my sense.

I use Nextcloud 11.0.2.

sualko commented 7 years ago

This message (with the clear text password) is directly from ejabberd.

Is it working, because it's not clear from your post.

wargreen commented 7 years ago

But the login don't work, with the good password. Any idea ?

sualko commented 7 years ago

apparmor? Any log entries in /var/log/ejabberd/extauth.*?

wargreen commented 7 years ago

we run a debian testing, without apparmor. extauth.log :

INFO:root:Receive operation auth
INFO:requests.packages.urllib3.connectionpool:Starting new HTTPS connection (1): cloud.lebib.org
INFO:root:Start external auth script with endpoint: https://cloud.lebib.org/ocs/v1.php/cloud/
INFO:root:Log level: 20

In nextcloud, when we try to login to the tchat server, we got "Connection with the tchat server faild. Verrify your password" (free translate from french). This reponse is slower with a good login than a random login. is the login should be done with "wargreen@lebib.org" or just "wargreen" in the nextcloud side ?

sualko commented 7 years ago

This is the wrong endpoint. Did you update the nextcloud app according to the pull request? You find the correct value in your nc admin settings. It should be similar to localhost/nextcloud/index.php/apps/ojsxc/ajax/externalApi.php.

wargreen commented 7 years ago

After download and extract https://github.com/nextcloud/jsxc.nextcloud/tree/ejabberd-cloud-auth in place of the apps store's ojsxc app, i don't see the endpoint. Same after disable the redis cache.

sualko commented 7 years ago

Updating from github is not that easy (we have to change that in the future). At the moment I recommend to copy only modified files to your current app folder. Sorry for the inconvenience.

sualko commented 7 years ago

Hey, I released a beta version, if you like to try this again. Please reopen the issue if you have trouble.

wargreen commented 7 years ago

It's work well for me !