Cookbook to deploy a LDAP server (389 Directory Server) #115

Merged
greg merged 14 commits from feature/107-ldap_server into master 2019-12-23 17:50:23 +00:00
Owner

Initial version of the kosmos-dirsrv cookbook

It sets up 389 Directory Server, including a TLS cert acquired using Let's Encrypt in production (that requires ldap.kosmos.org pointing to the server's IP).

Extracted from #112 (I have removed the commits adding LDAP support to our services, this will be a separate PR)

Initial version of the kosmos-dirsrv cookbook It sets up 389 Directory Server, including a TLS cert acquired using Let's Encrypt in production (that requires ldap.kosmos.org pointing to the server's IP). Extracted from #112 (I have removed the commits adding LDAP support to our services, this will be a separate PR)
Owner

LGTM. A few questions:

  1. Has it been deployed to the actual production domain yet?
  2. If not, which machine should we run this on?
  3. Have you thought about replication yet? I.e. ldap2.kosmos.org for example.
LGTM. A few questions: 1. Has it been deployed to the actual production domain yet? 2. If not, which machine should we run this on? 3. Have you thought about replication yet? I.e. `ldap2.kosmos.org` for example.
Author
Owner

I haven't deployed it yet. I think we could start by running it on barnard, dirsrv doesn't take a lot of RAM (each instance takes around 30MB in my VM)

I got replication to work in my VM by using the Red Hat docs, I'm going to turn this into recipes, that's a lot of different LDIF files

I haven't deployed it yet. I think we could start by running it on barnard, dirsrv doesn't take a lot of RAM (each instance takes around 30MB in my VM) I got replication to work in my VM by using [the Red Hat docs](https://access.redhat.com/documentation/en-us/red_hat_directory_server/10/html/administration_guide/managing_replication), I'm going to turn this into recipes, that's a lot of different LDIF files
Owner

I haven’t deployed it yet. I think we could start by running it on barnard, dirsrv doesn’t take a lot of RAM (each instance takes around 30MB in my VM)

Ok, sounds good.

I got replication to work in my VM by using the Red Hat docs, I’m going to turn this into recipes, that’s a lot of different LDIF files

Why would we need this from the start? Is it really that important? It was just a general question to learn if it's on the radar and if it's possible at all.

> I haven’t deployed it yet. I think we could start by running it on barnard, dirsrv doesn’t take a lot of RAM (each instance takes around 30MB in my VM) Ok, sounds good. > I got replication to work in my VM by using the Red Hat docs, I’m going to turn this into recipes, that’s a lot of different LDIF files Why would we need this from the start? Is it really that important? It was just a general question to learn if it's on the radar and if it's possible at all.
greg changed title from Cookbook to deploy a LDAP server (389 Directory Server) to WIP: Cookbook to deploy a LDAP server (389 Directory Server) 2019-12-04 16:48:08 +00:00
Author
Owner

I ran into a couple issues (see the commits from today), but this is now running on barnard as ldap.kosmos.org, with a TLS cert.

Example usage:

$ ldapsearch -x -w $password -D 'cn=Directory Manager' -b "ou=users,dc=kosmos,dc=org" -H "ldaps://ldap.kosmos.org" -v
ldap_initialize( ldaps://ldap.kosmos.org:636/??base )
filter: (objectclass=*)
requesting: All userApplication attributes
# extended LDIF
#
# LDAPv3
# base <ou=users,dc=kosmos,dc=org> with scope subtree
# filter: (objectclass=*)
# requesting: ALL
#

# users, kosmos.org
dn: ou=users,dc=kosmos,dc=org
objectClass: top
objectClass: organizationalUnit
ou: users

# search result
search: 2
result: 0 Success

# numResponses: 2
# numEntries: 1

I have just discovered this is missing the certbot hooks for cert renewal, I'm pushing that and then we can merge this one

I ran into a couple issues (see the commits from today), but this is now running on barnard as ldap.kosmos.org, with a TLS cert. Example usage: ``` $ ldapsearch -x -w $password -D 'cn=Directory Manager' -b "ou=users,dc=kosmos,dc=org" -H "ldaps://ldap.kosmos.org" -v ldap_initialize( ldaps://ldap.kosmos.org:636/??base ) filter: (objectclass=*) requesting: All userApplication attributes # extended LDIF # # LDAPv3 # base <ou=users,dc=kosmos,dc=org> with scope subtree # filter: (objectclass=*) # requesting: ALL # # users, kosmos.org dn: ou=users,dc=kosmos,dc=org objectClass: top objectClass: organizationalUnit ou: users # search result search: 2 result: 0 Success # numResponses: 2 # numEntries: 1 ``` I have just discovered this is missing the certbot hooks for cert renewal, I'm pushing that and then we can merge this one
greg changed title from WIP: Cookbook to deploy a LDAP server (389 Directory Server) to Cookbook to deploy a LDAP server (389 Directory Server) 2019-12-05 14:48:08 +00:00
Author
Owner

This should be good to merge now

This should be good to merge now
Owner

ldapsearch -x -w $password -D 'cn=Directory Manager' -b "ou=users,dc=kosmos,dc=org" -H "ldaps://ldap.kosmos.org" -v

I get the same result without having a password stored in that variable. Is that intended?

Also, where can I find the documentation for how it's set up in terms of admin accounts, where to find the passwords, etc.? I did a quick search through the changed files, but there doesn't seem to be anything in doc/.

> ldapsearch -x -w $password -D 'cn=Directory Manager' -b "ou=users,dc=kosmos,dc=org" -H "ldaps://ldap.kosmos.org" -v I get the same result without having a password stored in that variable. Is that intended? Also, where can I find the documentation for how it's set up in terms of admin accounts, where to find the passwords, etc.? I did a quick search through the changed files, but there doesn't seem to be anything in `doc/`.
Author
Owner

I get the same result without having a password stored in that variable. Is that intended?

The same result, meaning successful search results without a password? I can't reproduce that

Also, where can I find the documentation for how it’s set up in terms of admin accounts, where to find the passwords, etc.? I did a quick search through the changed files, but there doesn’t seem to be anything in doc/.

I have added doc/ldap.md with the instructions to get the admin password from the encrypted data bag

> I get the same result without having a password stored in that variable. Is that intended? The same result, meaning successful search results without a password? I can't reproduce that > Also, where can I find the documentation for how it’s set up in terms of admin accounts, where to find the passwords, etc.? I did a quick search through the changed files, but there doesn’t seem to be anything in doc/. I have added `doc/ldap.md` with the instructions to get the admin password from the encrypted data bag
Owner

The same result, meaning successful search results without a password? I can’t reproduce that

Yes, just the exact same output that you posted with the 2 search results. I used the empty $password variable, by just copying the bash command without defining $password first.

> The same result, meaning successful search results without a password? I can’t reproduce that Yes, just the exact same output that you posted with the 2 search results. I used the empty $password variable, by just copying the bash command without defining $password first.
Owner

I have added doc/ldap.md with the instructions to get the admin password from the encrypted data bag

> I have added doc/ldap.md with the instructions to get the admin password from the encrypted data bag
Owner

Get you some easy kredits for updating this one, too: https://wiki.kosmos.org/Infrastructure

Get you some easy kredits for updating this one, too: https://wiki.kosmos.org/Infrastructure
Author
Owner

@raucao I don't understand how you can get search results without the correct admin password. With an incorrect password I get ldap_bind: Invalid credentials (49) and with an empty one:

ldap_bind: Server is unwilling to perform (53)
        additional info: Unauthenticated binds are not allowed

Edit: I updated the Infra wiki page

@raucao I don't understand how you can get search results without the correct admin password. With an incorrect password I get `ldap_bind: Invalid credentials (49)` and with an empty one: ``` ldap_bind: Server is unwilling to perform (53) additional info: Unauthenticated binds are not allowed ``` Edit: I updated the Infra wiki page
Owner

I cannot tell you how it's possible. Only that it happened exactly as I described. I never looked up the password or copied it anywhere.

I cannot tell you how it's possible. Only that it happened exactly as I described. I never looked up the password or copied it anywhere.
Owner

I just double-checked, even though I was certain before. I can still do this by just SSHing into barnard, and without doing anything else, running ldapsearch -x -w $password -D 'cn=Directory Manager' -b "ou=users,dc=kosmos,dc=org" -H "ldaps://ldap.kosmos.org" -v will yield the result almost exactly as posted in the example:

basti@barnard:~$ echo $password

basti@barnard:~$ ldapsearch -x -w $password -D 'cn=Directory Manager' -b "ou=users,dc=kosmos,dc=org" -H "ldaps://ldap.kosmos.org" -v
ldap_initialize( ldaps://ldap.kosmos.org:636/??base )
filter: cn=Directory Manager
requesting: All userApplication attributes
# extended LDIF
#
# LDAPv3
# base <ou=users,dc=kosmos,dc=org> with scope subtree
# filter: cn=Directory Manager
# requesting: ALL
#

# search result
search: 2
result: 0 Success

# numResponses: 1
I just double-checked, even though I was certain before. I can still do this by just SSHing into barnard, and without doing anything else, running `ldapsearch -x -w $password -D 'cn=Directory Manager' -b "ou=users,dc=kosmos,dc=org" -H "ldaps://ldap.kosmos.org" -v` will yield the result almost exactly as posted in the example: ``` basti@barnard:~$ echo $password basti@barnard:~$ ldapsearch -x -w $password -D 'cn=Directory Manager' -b "ou=users,dc=kosmos,dc=org" -H "ldaps://ldap.kosmos.org" -v ldap_initialize( ldaps://ldap.kosmos.org:636/??base ) filter: cn=Directory Manager requesting: All userApplication attributes # extended LDIF # # LDAPv3 # base <ou=users,dc=kosmos,dc=org> with scope subtree # filter: cn=Directory Manager # requesting: ALL # # search result search: 2 result: 0 Success # numResponses: 1 ```
Author
Owner

Thanks, I can reproduce that on barnard. The search does not return actual results with that empty password variable, but it is successful, unlike with an empty/wrong password, or without a -w switch. It does not look like it is a problem since no results are returned on local requests without the correct password

This appears to happen because the server is running on localhost, with an empty password variable from another server the search isn't successful as on barnard.

kare@barnard:~$ host ldap.kosmos.org
ldap.kosmos.org is an alias for barnard.kosmos.org.
barnard.kosmos.org has address 127.0.1.1
Thanks, I can reproduce that on barnard. The search does not return actual results with that empty password variable, but it is successful, unlike with an empty/wrong password, or without a `-w` switch. It does not look like it is a problem since no results are returned on local requests without the correct password This appears to happen because the server is running on localhost, with an empty password variable from another server the search isn't successful as on barnard. ``` kare@barnard:~$ host ldap.kosmos.org ldap.kosmos.org is an alias for barnard.kosmos.org. barnard.kosmos.org has address 127.0.1.1 ```
Owner

It says "search result" and then shows some numbers. Running the same command with an actual password also doesn't yield "actual results" for me. Are you referring to different commands?

It says "search result" and then shows some numbers. Running the same command with an actual password also doesn't yield "actual results" for me. Are you referring to different commands?
Author
Owner

By actual results I mean this part:

# users, kosmos.org
dn: ou=users,dc=kosmos,dc=org
objectClass: top
objectClass: organizationalUnit
ou: users
By actual results I mean this part: ```ldif # users, kosmos.org dn: ou=users,dc=kosmos,dc=org objectClass: top objectClass: organizationalUnit ou: users ```
Owner

I still don't see what is the actual result in that. But OK.

I just want to make certain that we don't overlook a security issue there, and that people with shell access cannot randomly access all user data.

I still don't see what is the actual result in that. But OK. I just want to make certain that we don't overlook a security issue there, and that people with shell access cannot randomly access all user data.
Author
Owner

I got it, passing the empty unquoted variable as a password is the same as doing this:

$ ldapsearch -x -b "ou=users,dc=kosmos,dc=org" -H "ldap://ldap.kosmos.org" -v

This is called Anonymous Bind (https://access.redhat.com/documentation/en-US/Red_Hat_Directory_Server/8.2/html/Administration_Guide/configuring-special-binds.html#disabling-anonymous-binds). We can set nsslapd-allow-anonymous-access: off to disable it.

I got it, passing the empty unquoted variable as a password is the same as doing this: ``` $ ldapsearch -x -b "ou=users,dc=kosmos,dc=org" -H "ldap://ldap.kosmos.org" -v ``` This is called Anonymous Bind (https://access.redhat.com/documentation/en-US/Red_Hat_Directory_Server/8.2/html/Administration_Guide/configuring-special-binds.html#disabling-anonymous-binds). We can set `nsslapd-allow-anonymous-access: off` to disable it.
Author
Owner

I have set nsslapd-allow-anonymous-access: off on barnard, pushing the code changes

I have set `nsslapd-allow-anonymous-access: off` on barnard, pushing the code changes
Owner

That looks much better. 👍

That looks much better. :+1:
raucao approved these changes 2019-12-21 09:57:45 +00:00
raucao left a comment
Owner

I think we can merge it now.

I think we can merge it now.
greg closed this pull request 2019-12-23 17:50:22 +00:00
greg deleted branch feature/107-ldap_server 2019-12-23 17:50:31 +00:00
Sign in to join this conversation.
No reviewers
No Milestone
No project
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/chef#115
No description provided.