mod_auth_ldap

2,175 views
Skip to first unread message

Stefan Hepp

unread,
Dec 13, 2010, 11:45:27 AM12/13/10
to prosody-dev
Hello,

I just hacked a version of mod_auth_ldap based on the one in the
prosody-modules repository, which can be found here:
http://scm.stefant.org/svn/tools/trunk/patches/prosody/mod_auth_ldap.lua

I am using ldap_search to find the DN of users, and ldap_bind to test
the password, which also works when userPassword is hashed.

Noticed two things:
I need to specify 'scope' for ldap-search, else the query fails
silently on my setup (I see a 'missing scope' message in strace but
nowhere else, and I have not found a way to get ldap-error-messages in
lualdap so far).

In core/usermanager.lua, function user_exists (line 77) I need to add

if not host or not hosts[host] then return false; end

else it tries to check for host e.g. 'conference.jabber.stefant.org'
which does not seem to have an entry in hosts, and in some rare cases
'host' and 'username' seem to be empty, which results in a stacktrace
in the log and no messages are delivered. No idea if this is a problem
due to my auth_ldap stuff or another bug in my prosody version.

I am using the prosody-0.8 debian package (version 1-1~nightly11) with
lualdap 1.1.0 on debian stable.

Regards, Stefan

Waqas Hussain

unread,
Dec 13, 2010, 2:33:54 PM12/13/10
to proso...@googlegroups.com
On Mon, Dec 13, 2010 at 9:45 PM, Stefan Hepp <ste...@stefant.org> wrote:
> Hello,
>
> I just hacked a version of mod_auth_ldap based on the one in the
> prosody-modules repository, which can be found here:
> http://scm.stefant.org/svn/tools/trunk/patches/prosody/mod_auth_ldap.lua
>

You also fixed a bug, which I have applied to the prosody-modules
version. Thanks:

http://code.google.com/p/prosody-modules/source/detail?r=ca6199d73d68dcffead55b4931590a3daaddc9c2

> I am using ldap_search to find the DN of users, and ldap_bind to test
> the password, which also works when userPassword is hashed.

Great. Send an hg bundle/patch here, or ask us in the Prosody room, so
we can get this into prosody-modules.

I see you create a new LDAP connection. Someone patched lualdap to add
a bind_simple() method to the ldap object:
http://prosody.im/patches/lualdap.patch

The intent for this module was to eventually both work this way, and
to provide added features when we have a non-hashed password
available. We can provide SASL DIGEST-MD5, SCRAM-SHA-1, etc, only when
we have access to a plain password.

> Noticed two things:
> I need to specify 'scope' for ldap-search, else the query fails
> silently on my setup (I see a 'missing scope' message in strace but
> nowhere else, and I have not found a way to get ldap-error-messages in
> lualdap so far).

We should get lualdap fixed then. I wrote mod_auth_ldap, but never
actually got around to testing it and any error cases.

> In core/usermanager.lua, function user_exists (line 77) I need to add
>
> if not host or not hosts[host] then return false; end
>
> else it tries to check for host e.g. 'conference.jabber.stefant.org'
> which does not seem to have an entry in hosts, and in some rare cases
> 'host' and 'username' seem to be empty, which results in a stacktrace
> in the log and no messages are delivered. No idea if this is a problem
> due to my auth_ldap stuff or another bug in my prosody version.
>

I'd like to see the trace.

> I am using the prosody-0.8 debian package (version 1-1~nightly11) with
> lualdap 1.1.0 on debian stable.
>
> Regards, Stefan
>

--
Waqas

Stefan Hepp

unread,
Jan 21, 2011, 11:49:25 AM1/21/11
to prosody-dev
Hello,

Finally got round to look into this again.

I updated the mod_auth_ldap module at (don't know how to upload files
here .. )
http://scm.stefant.org/svn/tools/trunk/patches/prosody/mod_auth_ldap.lua

It now works with prosody-0.8-rc1 without any patching of prosody, the
problems I had with the usermanager seem to be fixed now.

To use it, place the following in your prosody.cfg.lua
ldap_server = "servername";
ldap_base = "ou=People,dc=example,dc=org";
ldap_rootdn = "<admindn>"; -- optional
ldap_password = "<adminpw>"; -- optional
ldap_filter = "(authorizedService=jabber)"; -- optional
-- dont forget this one!
authentication = "ldap";

There are quite a few things which can be improved, like:
- More/better error handling?
- Make login-field configurable (instead of hardcoded 'uid')
- Optionally construct DN by given schema (like "uid=%s,ou=People,..")
to avoid first ldap_search if username defines the DN.
- Alternatively retrieve plaintext-password from ldap (by in plain()
handler instead of plain_text(), I guess) to support DIGEST, .. as you
mentioned above.

Maybe I will fix a few of the above points and create an hg patch for
it when I find some time..

Another nice feature for me would be to supply vcard user-infos (Name,
address,..) from LDAP, but I don't think that the auth-module is the
right place to do this (but any hints on how to implement such a
plugin are welcome ;) ), and there is also the non-trivial matter of
handling vcard-updates from the clients (deny/write back to LDAP/use
LDAP only as long as values are not changed by user ??).

Regards, Stefan

Matthew Wild

unread,
Feb 29, 2012, 2:02:32 PM2/29/12
to proso...@googlegroups.com
On 21 January 2011 16:49, Stefan Hepp <ste...@stefant.org> wrote:
> Hello,
>
> Finally got round to look into this again.
>
> I updated the mod_auth_ldap module at (don't know how to upload files
> here .. )
> http://scm.stefant.org/svn/tools/trunk/patches/prosody/mod_auth_ldap.lua
>

Stefan has moved the file, it is now at
http://scm.stefant.org/svn/tools/stuff/trunk/patches/prosody/mod_auth_ldap.lua
.

To avoid future confusion, I've given the file a header and copied it
to http://prosody.im/files/mod_auth_ldap.lua

Thanks Stefan, and to the person who discovered the broken link :)

The plan is still to probably merge these modules (this one and the
one in prosody-modules), but our efforts are all on getting Prosody
0.9 released at the moment.

Regards,
Matthew

Stian B. Barmen

unread,
Mar 5, 2014, 3:10:44 PM3/5/14
to proso...@googlegroups.com
Hello, 

I have been trying to get this to work with multiple versions of this plugin (not entirely obvious which one is the recommended one now!) but have limited success. Right now I am trying to authenticate against a Zentyal 3.3 server using OpenLDAP version on port 390. My debug shows that Prosody does not connect to port 390 even though I am configuring the port by setting servername 127.0.0.1:390 and ldap://127.0.0.1:390/ etc. Not sure how to get it to connect to the correct port? 

This is my config in the prosody.cfg.lua file:

authentication = "ldap"
ldap_server = "127.0.0.1:390"
ldap_rootdn = "cn=zentyal,dc=example,dc=local"
ldap_password = "xxxxxxxxxx"
ldap_base = "ou=Users,dc=example,dc=local"
ldap_mode = "bind"

Any tips on this? please? :) 

/stian

googl...@computerlyrik.de

unread,
Mar 7, 2014, 8:46:19 AM3/7/14
to proso...@googlegroups.com
Wrote a prosody-cookbook [2] (see chef[1]) for setting up prosody.

The setup for the ldap auth part is described here [3]
See for the config templates used by the recipe.

I am using the default ldap port - so can not reproduce your issue.
Perhaps it is a problem with lua-ldap (or your specific installed version?)

Just guessing.


[1] http://www.getchef.com/
[2] https://github.com/computerlyrik/chef-prosody
[3]
https://github.com/computerlyrik/chef-prosody/blob/master/recipes/ldap.rb
[4]
https://github.com/computerlyrik/chef-prosody/tree/master/templates/default
!DSPAM:5319cdac217327267020158!


Abel Paz

unread,
Apr 11, 2014, 5:29:49 AM4/11/14
to proso...@googlegroups.com
Hi everyone!

I'm having this error using mod_auth_ldap (latest version from https://code.google.com/p/prosody-modules/wiki/mod_auth_ldap ). It happens with no pattern, just sometimes.. happens (once or twice a day using it by 6 users).

Apr 11 11:20:21 mod_c2s error   Traceback[c2s]: /usr/lib/prosody/modules/mod_auth_ldap.lua:21: LuaLDAP: Can't contact LDAP server
stack traceback:
        [C]: in function 'search'
        /usr/lib/prosody/modules/mod_auth_ldap.lua:21: in function 'find_userdn'
        /usr/lib/prosody/modules/mod_auth_ldap.lua:40: in function 'test_password'
        /usr/lib/prosody/modules/mod_auth_ldap.lua:67: in function 'plain_test'
        /usr/lib/prosody/util/sasl/plain.lua:72: in function </usr/lib/prosody/util/sasl/plain.lua:38>
        (tail call): ?
        /usr/lib/prosody/modules/mod_saslauth.lua:77: in function </usr/lib/prosody/modules/mod_saslauth.lua:66>
        (tail call): ?
        /usr/lib/prosody/util/events.lua:67: in function 'fire_event'
        /usr/lib/prosody/core/stanza_router.lua:146: in function </usr/lib/prosody/core/stanza_router.lua:55>
        ...
        [C]: in function 'parse'
        /usr/lib/prosody/util/xmppstream.lua:255: in function 'feed'
        /usr/lib/prosody/modules/mod_c2s.lua:230: in function 'data'
        /usr/lib/prosody/modules/mod_c2s.lua:252: in function </usr/lib/prosody/modules/mod_c2s.lua:249>
        (tail call): ?
        /usr/lib/prosody/net/server_select.lua:848: in function </usr/lib/prosody/net/server_select.lua:830>
        [C]: in function 'xpcall'
        /usr/bin/prosody:373: in function 'loop'
        /usr/bin/prosody:403: in main chunk
        [C]: ?

Does somebody know why is this happening and how can I fix it?

Thank you very much in advance!

Best regards!
Abel.
Reply all
Reply to author
Forward
0 new messages