Rocket.Chat icon indicating copy to clipboard operation
Rocket.Chat copied to clipboard

LDAP (Ad) don't work with latest version: 0.14.0

Open valessiobrito opened this issue 10 years ago • 38 comments

Latest stable build or the beta development build (today)

LDAP: Error [Error: Meteor code must always run within a Fiber. Try wrapping callbacks that you pass to non-Meteor libraries with Meteor.bindEnvironment.] [Error: Meteor code must always run within a Fiber. Try wrapping callbacks that you pass to non-Meteor libraries with Meteor.bindEnvironment.] [LDAP] Falling back to standard account base stream error Error during WebSocket handshake: Unexpected response code: 400

/opt/Rocket.Chat/programs/server/node_modules/fibers/future.js:226 throw new Error('Future resolved more than once'); ^ Error: Future resolved more than once at Object.Future.return (/opt/Rocket.Chat/programs/server/node_modules/fibers/future.js:226:10) at Client. (packages/rocketchat_ldap/ldap_server.js:98:1) at Client.emit (events.js:95:17) at Socket.onSocketError (/opt/Rocket.Chat/programs/server/npm/rocketchat_ldap/node_modules/ldapjs/lib/client/client.js:1169:12) at Socket.emit (events.js:95:17) at net.js:441:14 at process._tickDomainCallback (node.js:492:13)

valessiobrito avatar Jan 18 '16 23:01 valessiobrito

Confirmed with docker tags 0.14.0, latest, develop. The last working docker tag is 0.13.0

adyp avatar Jan 19 '16 00:01 adyp

I have same issue with 0.14.10, worked with 0.13.0. I tried to enable SSL in both ways, Reject Unauthorized true and false.

Situation currently in logs LDAP without SSL:

Bind before search cn=admin,dc=ldap,dc=ldap,dc=ldap password
LDAP: Error [Error: Meteor code must always run within a Fiber. Try wrapping callbacks that you pass to non-Meteor libraries with Meteor.bindEnvironment.]
[Error: Meteor code must always run within a Fiber. Try wrapping callbacks that you pass to non-Meteor libraries with Meteor.bindEnvironment.]
[LDAP] Falling back to standard account base

LDAP with SSL Reject Unauthorized true or false:

Exception while invoking method 'login' TypeError: Object [object global] has no method '_send'
    at starttls (/usr/share/Rocket.Chat/programs/server/npm/rocketchat_ldap/node_modules/ldapjs/lib/client/client.js:955:15)
    at packages/meteor/helpers.js:118:1
    at startTLS (packages/rocketchat_ldap/ldap_server.js:58:1)
    at [object Object].LDAP.ldapCheck (packages/rocketchat_ldap/ldap_server.js:94:1)
    at [object Object].__coffeescriptShare (packages/rocketchat_ldap/ldap_server.js:256:1)
    at accounts_server.js:462:32
    at tryLoginMethod (accounts_server.js:239:14)
    at AccountsServer.Ap._runLoginHandlers (accounts_server.js:459:18)
    at [object Object].methods.login (accounts_server.js:522:27)
    at maybeAuditArgumentChecks (livedata_server.js:1698:12)

tuudik avatar Jan 19 '16 07:01 tuudik

+1, same problem here

andrzejwp avatar Jan 19 '16 08:01 andrzejwp

same problem. LDAP worked with 0.13.0 but not with 0.14.0

miscs avatar Jan 19 '16 10:01 miscs

Thanks, we will fix that on 0.14.1 in a couple hours.

marceloschmidt avatar Jan 19 '16 11:01 marceloschmidt

Any workarounds until then?

tuudik avatar Jan 19 '16 12:01 tuudik

Guys, I updated the code, can you try again? The update is in develop branch and if you are using docker wait some minutes to docker build the container.

rodrigok avatar Jan 19 '16 13:01 rodrigok

For me the issue still occurs, tried with TLS and without. Same errors. I used package from: https://rocket.chat/releases/develop/download

tuudik avatar Jan 19 '16 13:01 tuudik

Seems like I didnt get the package with the updates, I checked programs/server/packages/rocketchat_ldap.js and wount it was old when compared to https://github.com/RocketChat/Rocket.Chat/commit/cdf762270455b9fb0d351074798dd3f85b184dc5

I then changed the file with vim accordingly, restarted rocket, but the issue still persisted with same errors as I copied above when used with TLS.

When I disabled TLS, it started to work. :)

tuudik avatar Jan 19 '16 14:01 tuudik

Ok, I need access to some LDAP server to test this.

rodrigok avatar Jan 19 '16 14:01 rodrigok

I can confirm that LDAP issues have been resolved (I haven't checked with TLS enabled though).

andrzejwp avatar Jan 19 '16 21:01 andrzejwp

Tested with following version -- LDAP succeeds but only if the account was really auto-provisioned via an LDAP authentication (e.g. if it was registered with normal password then login will not be completed successfully). Fallback to classic password login works.

"version": "0.14.0",
commit": {
    "hash": "ad1ffbdc65e7ba9f5bcac5f224d682be85143b8c",
    "date": "Mon Jan 18 20:44:08 2016 -0200",
    "author": "Gabriel Engel",
    "subject": "Merge pull request #1966 from RocketChat/improvements/force_ssl_urls"
  },

adyp avatar Jan 19 '16 22:01 adyp

@rodrigok Unfortunately, I can't provide access to my LDAP server. Tho I did ask ldapjs dev for some ideas: https://github.com/mcavage/node-ldapjs/issues/339

It would appear that some of the Meteor stuff you're using is rebinding that function.
I don't believe that any of the public client methods support being bound to anything
but the client object itself.

Perhaps this could help?

tuudik avatar Jan 20 '16 15:01 tuudik

@tuudik you are right, I'm sorry, was my fault, I forgot the bind of the wrapAsync, as I can't test the code I didn't realized that, thanks.

The change: https://github.com/RocketChat/Rocket.Chat/commit/72a8b0ca4257eb9b08ccdb06871381469ad8c18b?ts=2

Can you update to the latest develop commit and try again?

rodrigok avatar Jan 20 '16 21:01 rodrigok

@rodrigok that didn't work for me. It at least fixed the server from crashing, but it doesn't seem to resolve #1984.

I did some testing and it looks like it's failing due to line 137 passing null instead of the email. My scenario is based against AD, so they log in with just a user name and checks against the sAMAccountName. In our case, the full user name isn't their email, so the domain is never split out on line 112.

It looks like this should be resolved by setting the defaultDomain option above, but I can't seem to find that in the UI or in the database.

jeffrapp avatar Jan 21 '16 03:01 jeffrapp

@rodrigok It's a little bit better already, I can see from openldap log that TLS connection is established, but after this, it's silence. Even nothing in RC log:

Jan 21 09:30:16 ldap slapd[13534]: conn=2195 fd=25 ACCEPT from IP=127.0.0.1:59301 (IP=0.0.0.0:110)
Jan 21 09:30:16 ldap slapd[13534]: conn=2195 op=0 EXT oid=1.3.6.1.4.1.1466.20037
Jan 21 09:30:16 ldap slapd[13534]: conn=2195 op=0 STARTTLS
Jan 21 09:30:16 ldap slapd[13534]: conn=2195 op=0 RESULT oid= err=0 text=
Jan 21 09:30:16 ldap slapd[13534]: conn=2195 fd=25 TLS established tls_ssf=256 ssf=256

It looks from that, after establishing TLS connection, RC is just standing still and not starting bind with ldap.

tuudik avatar Jan 21 '16 07:01 tuudik

@jeffrapp the email or domain isn't required to create account or login in RC, so this can't be de problem.

@tuudik there is no line starting with StartTLS Result in RC logs?

Sorry guys, this will be a long way since I'm not a LDAP expert and I don't have a LDAP server to test (I tried to install with no success).

rodrigok avatar Jan 21 '16 13:01 rodrigok

@rodrigok I think following the links above, you will be able to setup openldap with TLS about in 20 minutes: https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-openldap-and-phpldapadmin-on-an-ubuntu-14-04-server https://www.digitalocean.com/community/tutorials/how-to-encrypt-openldap-connections-using-starttls

And yeah, RC logs didnt react anyhow, not a single line, I had even debug enabled. Last line that appeared when opened the login page:

.....
[publish] userData -> userId: null , arguments:  {}
[methods] UserPresence:online -> userId: null , arguments:  {}

tuudik avatar Jan 21 '16 13:01 tuudik

LDAP Server Information (read-only access): Server: ldap.forumsys.com
Port: 389 Bind DN: cn=read-only-admin,dc=example,dc=com Bind Password: password

ll user passwords are password.

You may also bind to individual Users (uid) or the two Groups (ou) that include:

ou=mathematicians,dc=example,dc=com riemann gauss euler euclid

ou=scientists,dc=example,dc=com einstein newton galieleo tesla

source: http://www.forumsys.com/tutorials/integration-how-to/ldap/online-ldap-test-server/

valessiobrito avatar Jan 21 '16 13:01 valessiobrito

@valessiobrito I used this LDAP online server to develop our first version, but this server don't have TLS.

@tuudik In fact the problem isn't install the server, but how to configure, set users, groups, etc. If you can help me I can give you access to a linux server so you can configure the server as you have yours and we can get the same behaviour.

rodrigok avatar Jan 21 '16 13:01 rodrigok