LDAP mock server for local development #2

Closed
opened 2020-11-18 17:57:22 +00:00 by bumi · 4 comments
Owner

I've seen this ldab-server-mock written in JavaScript and was wondering if we can use that one for local development.

It seems to run and I get a "Invalid username or password." error, but I am not sure what exactly needs to go into the server.json and users.json files to work with out kosmos ldap settings. (cn? dc? ou? attributes?)

I've seen this [ldab-server-mock](https://github.com/veo-labs/ldap-server-mock) written in JavaScript and was wondering if we can use that one for local development. It seems to run and I get a "Invalid username or password." error, but I am not sure what exactly needs to go into the server.json and users.json files to work with out kosmos ldap settings. (cn? dc? ou? attributes?)
Owner

That server is just for tests, but could come in handy for sure. Currently, the very few specs that there are do not talk to LDAP at all, but just use mocks or direct Warden sign-ins.

Our LDAP entry layout is documented on the wiki here:

https://wiki.kosmos.org/Infrastructure:LDAP

We basically use cn as unique ID/username, and ou for the domain (kosmos.org vs. custom/pro domains like currently 5apps.com).

dn: cn=bumi,ou=kosmos.org,cn=users,dc=kosmos,dc=org

(Also see https://gitea.kosmos.org/kosmos/akkounts/src/branch/master/config/ldap.yml#L31-L32 for how it's configured with the devise LDAP plugin for example.)

That server is just for tests, but could come in handy for sure. Currently, the very few specs that there are do not talk to LDAP at all, but just use mocks or direct Warden sign-ins. Our LDAP entry layout is documented on the wiki here: https://wiki.kosmos.org/Infrastructure:LDAP We basically use `cn` as unique ID/username, and `ou` for the domain (kosmos.org vs. custom/pro domains like currently 5apps.com). ```ldif dn: cn=bumi,ou=kosmos.org,cn=users,dc=kosmos,dc=org ``` (Also see https://gitea.kosmos.org/kosmos/akkounts/src/branch/master/config/ldap.yml#L31-L32 for how it's configured with the devise LDAP plugin for example.)
raucao added the
idea
dev environment
labels 2020-11-18 18:16:48 +00:00
Author
Owner

yeah, I got:

server config:

{
  "port": 3004,
  "userLoginAttribute": "cn",
  "searchBase": "ou=kosmos.org,cn=users,dc=kosmos,dc=org",
  "searchFilter": "(&(objectclass=person)(cn={{username}}))"
}

users:

[
  {
    "dn": "cn=bumi,ou=kosmos.org,cn=users,dc=kosmos,dc=org",
    "cn": "bumi",
    "sn": "bumi",
    "objectClass": "top",
    "objectClass": "account",
    "objectClass": "person",
    "objectClass": "extensibleObject",
    "mail": "bumi@kosmos.org",
    "uid": "uidbumi",
    "userPassword": "secret",
    "xmpp": "enabled"
  }
]

but Devise::LDAP::Adapter.get_ldap_param(self.cn, "mail") returns nil. (in User#ldap_before_save)

yeah, I got: server config: ``` { "port": 3004, "userLoginAttribute": "cn", "searchBase": "ou=kosmos.org,cn=users,dc=kosmos,dc=org", "searchFilter": "(&(objectclass=person)(cn={{username}}))" } ``` users: ``` [ { "dn": "cn=bumi,ou=kosmos.org,cn=users,dc=kosmos,dc=org", "cn": "bumi", "sn": "bumi", "objectClass": "top", "objectClass": "account", "objectClass": "person", "objectClass": "extensibleObject", "mail": "bumi@kosmos.org", "uid": "uidbumi", "userPassword": "secret", "xmpp": "enabled" } ] ``` but `Devise::LDAP::Adapter.get_ldap_param(self.cn, "mail")` returns nil. (in User#ldap_before_save)
Owner

If it found the user and only that method failed, then maybe the mock server doesn't implement whatever that call translates to as an LDAP request?

Difficult to say from here, not having looked into the mock server at all yet.

If it found the user and only that method failed, then maybe the mock server doesn't implement whatever that call translates to as an LDAP request? Difficult to say from here, not having looked into the mock server at all yet.
Owner

@bumi I've solved the LDAP dev situation with Docker Compose and new seed tasks:

#74

Maybe you can try it out and let me know if it works for you? There's a quick start section in the README there, which just needs a few commands to have everything running, configured, and seeded.

@bumi I've solved the LDAP dev situation with Docker Compose and new seed tasks: https://gitea.kosmos.org/kosmos/akkounts/pulls/74 Maybe you can try it out and let me know if it works for you? There's a quick start section in the README there, which just needs a few commands to have everything running, configured, and seeded.
Sign in to join this conversation.
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: kosmos/akkounts#2
No description provided.