Lance Bragstad | f3f7c07 | 2018-03-30 20:56:04 +0000 | [diff] [blame] | 1 | ============================ |
| 2 | Deploying DevStack with LDAP |
| 3 | ============================ |
| 4 | |
| 5 | The OpenStack Identity service has the ability to integrate with LDAP. The goal |
| 6 | of this guide is to walk you through setting up an LDAP-backed OpenStack |
| 7 | development environment. |
| 8 | |
| 9 | Introduction |
| 10 | ============ |
| 11 | |
| 12 | LDAP support in keystone is read-only. You can use it to back an entire |
| 13 | OpenStack deployment to a single LDAP server, or you can use it to back |
| 14 | separate LDAP servers to specific keystone domains. Users within those domains |
Lance Bragstad | 8e802da | 2019-01-04 15:21:43 +0000 | [diff] [blame] | 15 | can authenticate against keystone, assume role assignments, and interact with |
| 16 | other OpenStack services. |
Lance Bragstad | f3f7c07 | 2018-03-30 20:56:04 +0000 | [diff] [blame] | 17 | |
| 18 | Configuration |
| 19 | ============= |
| 20 | |
| 21 | To deploy an OpenLDAP server, make sure ``ldap`` is added to the list of |
Lance Bragstad | 8e802da | 2019-01-04 15:21:43 +0000 | [diff] [blame] | 22 | ``ENABLED_SERVICES`` in the ``local.conf`` file:: |
Lance Bragstad | f3f7c07 | 2018-03-30 20:56:04 +0000 | [diff] [blame] | 23 | |
| 24 | enable_service ldap |
| 25 | |
| 26 | Devstack will require a password to set up an LDAP administrator. This |
| 27 | administrative user is also the bind user specified in keystone's configuration |
| 28 | files, similar to a ``keystone`` user for MySQL databases. |
| 29 | |
| 30 | Devstack will prompt you for a password when running ``stack.sh`` if |
| 31 | ``LDAP_PASSWORD`` is not set. You can add the following to your |
| 32 | ``local.conf``:: |
| 33 | |
| 34 | LDAP_PASSWORD=super_secret_password |
| 35 | |
| 36 | At this point, devstack should have everything it needs to deploy OpenLDAP, |
| 37 | bootstrap it with a minimal set of users, and configure it to back to a domain |
Lance Bragstad | 8e802da | 2019-01-04 15:21:43 +0000 | [diff] [blame] | 38 | in keystone. You can do this by running the ``stack.sh`` script:: |
Lance Bragstad | f3f7c07 | 2018-03-30 20:56:04 +0000 | [diff] [blame] | 39 | |
Lance Bragstad | 8e802da | 2019-01-04 15:21:43 +0000 | [diff] [blame] | 40 | $ ./stack.sh |
Lance Bragstad | f3f7c07 | 2018-03-30 20:56:04 +0000 | [diff] [blame] | 41 | |
| 42 | Once ``stack.sh`` completes, you should have a running keystone deployment with |
| 43 | a basic set of users. It is important to note that not all users will live |
| 44 | within LDAP. Instead, keystone will back different domains to different |
| 45 | identity sources. For example, the ``default`` domain will be backed by MySQL. |
| 46 | This is usually where you'll find your administrative and services users. If |
| 47 | you query keystone for a list of domains, you should see a domain called |
| 48 | ``Users``. This domain is set up by devstack and points to OpenLDAP. |
| 49 | |
| 50 | User Management |
| 51 | =============== |
| 52 | |
| 53 | Initially, there will only be two users in the LDAP server. The ``Manager`` |
| 54 | user is used by keystone to talk to OpenLDAP. The ``demo`` user is a generic |
| 55 | user that you should be able to see if you query keystone for users within the |
| 56 | ``Users`` domain. Both of these users were added to LDAP using basic LDAP |
| 57 | utilities installed by devstack (e.g. ``ldap-utils``) and LDIFs. The LDIFs used |
| 58 | to create these users can be found in ``devstack/files/ldap/``. |
| 59 | |
| 60 | Listing Users |
| 61 | ------------- |
| 62 | |
| 63 | To list all users in LDAP directly, you can use ``ldapsearch`` with the LDAP |
| 64 | user bootstrapped by devstack:: |
| 65 | |
Lance Bragstad | 8e802da | 2019-01-04 15:21:43 +0000 | [diff] [blame] | 66 | $ ldapsearch -x -w LDAP_PASSWORD -D cn=Manager,dc=openstack,dc=org \ |
Lance Bragstad | f3f7c07 | 2018-03-30 20:56:04 +0000 | [diff] [blame] | 67 | -H ldap://localhost -b dc=openstack,dc=org |
| 68 | |
| 69 | As you can see, devstack creates an OpenStack domain called ``openstack.org`` |
| 70 | as a container for the ``Manager`` and ``demo`` users. |
| 71 | |
| 72 | Creating Users |
| 73 | -------------- |
| 74 | |
| 75 | Since keystone's LDAP integration is read-only, users must be added directly to |
| 76 | LDAP. Users added directly to OpenLDAP will automatically be placed into the |
| 77 | ``Users`` domain. |
| 78 | |
| 79 | LDIFs can be used to add users via the command line. The following is an |
| 80 | example LDIF that can be used to create a new LDAP user, let's call it |
| 81 | ``peter.ldif.in``:: |
| 82 | |
| 83 | dn: cn=peter,ou=Users,dc=openstack,dc=org |
| 84 | cn: peter |
| 85 | displayName: Peter Quill |
| 86 | givenName: Peter Quill |
| 87 | mail: starlord@openstack.org |
| 88 | objectClass: inetOrgPerson |
| 89 | objectClass: top |
| 90 | sn: peter |
| 91 | uid: peter |
| 92 | userPassword: im-a-better-pilot-than-rocket |
| 93 | |
| 94 | Now, we use the ``Manager`` user to create a user for Peter in LDAP:: |
| 95 | |
Lance Bragstad | 8e802da | 2019-01-04 15:21:43 +0000 | [diff] [blame] | 96 | $ ldapadd -x -w LDAP_PASSWORD -D cn=Manager,dc=openstack,dc=org \ |
Lance Bragstad | f3f7c07 | 2018-03-30 20:56:04 +0000 | [diff] [blame] | 97 | -H ldap://localhost -c -f peter.ldif.in |
| 98 | |
| 99 | We should be able to assign Peter roles on projects. After Peter has some level |
| 100 | of authorization, he should be able to login to Horizon by specifying the |
| 101 | ``Users`` domain and using his ``peter`` username and password. Authorization |
| 102 | can be given to Peter by creating a project within the ``Users`` domain and |
| 103 | giving him a role assignment on that project:: |
| 104 | |
| 105 | $ openstack project create --domain Users awesome-mix-vol-1 |
| 106 | +-------------+----------------------------------+ |
| 107 | | Field | Value | |
| 108 | +-------------+----------------------------------+ |
| 109 | | description | | |
| 110 | | domain_id | 61a2de23107c46bea2d758167af707b9 | |
| 111 | | enabled | True | |
| 112 | | id | 7d422396d54945cdac8fe1e8e32baec4 | |
| 113 | | is_domain | False | |
| 114 | | name | awesome-mix-vol-1 | |
| 115 | | parent_id | 61a2de23107c46bea2d758167af707b9 | |
| 116 | | tags | [] | |
| 117 | +-------------+----------------------------------+ |
| 118 | $ openstack role add --user peter --user-domain Users \ |
| 119 | --project awesome-mix-vol-1 --project-domain Users admin |
| 120 | |
| 121 | |
| 122 | Deleting Users |
| 123 | -------------- |
| 124 | |
| 125 | We can use the same basic steps to remove users from LDAP, but instead of using |
| 126 | LDIFs, we can just pass the ``dn`` of the user we want to delete:: |
| 127 | |
Lance Bragstad | 8e802da | 2019-01-04 15:21:43 +0000 | [diff] [blame] | 128 | $ ldapdelete -x -w LDAP_PASSWORD -D cn=Manager,dc=openstack,dc=org \ |
Lance Bragstad | f3f7c07 | 2018-03-30 20:56:04 +0000 | [diff] [blame] | 129 | -H ldap://localhost cn=peter,ou=Users,dc=openstack,dc=org |
| 130 | |
| 131 | Group Management |
| 132 | ================ |
| 133 | |
| 134 | Like users, groups are considered specific identities. This means that groups |
| 135 | also fall under the same read-only constraints as users and they can be managed |
| 136 | directly with LDAP in the same way users are with LDIFs. |
| 137 | |
| 138 | Adding Groups |
| 139 | ------------- |
| 140 | |
| 141 | Let's define a specific group with the following LDIF:: |
| 142 | |
| 143 | dn: cn=guardians,ou=UserGroups,dc=openstack,dc=org |
| 144 | objectClass: groupOfNames |
| 145 | cn: guardians |
| 146 | description: Guardians of the Galaxy |
| 147 | member: cn=peter,dc=openstack,dc=org |
| 148 | member: cn=gamora,dc=openstack,dc=org |
| 149 | member: cn=drax,dc=openstack,dc=org |
| 150 | member: cn=rocket,dc=openstack,dc=org |
| 151 | member: cn=groot,dc=openstack,dc=org |
| 152 | |
| 153 | We can create the group using the same ``ldapadd`` command as we did with |
| 154 | users:: |
| 155 | |
Lance Bragstad | 8e802da | 2019-01-04 15:21:43 +0000 | [diff] [blame] | 156 | $ ldapadd -x -w LDAP_PASSWORD -D cn=Manager,dc=openstack,dc=org \ |
Lance Bragstad | f3f7c07 | 2018-03-30 20:56:04 +0000 | [diff] [blame] | 157 | -H ldap://localhost -c -f guardian-group.ldif.in |
| 158 | |
| 159 | If we check the group membership in Horizon, we'll see that only Peter is a |
| 160 | member of the ``guardians`` group, despite the whole crew being specified in |
| 161 | the LDIF. Once those accounts are created in LDAP, they will automatically be |
| 162 | added to the ``guardians`` group. They will also assume any role assignments |
| 163 | given to the ``guardians`` group. |
| 164 | |
| 165 | Deleting Groups |
| 166 | --------------- |
| 167 | |
| 168 | Just like users, groups can be deleted using the ``dn``:: |
| 169 | |
Lance Bragstad | 8e802da | 2019-01-04 15:21:43 +0000 | [diff] [blame] | 170 | $ ldapdelete -x -w LDAP_PASSWORD -D cn=Manager,dc=openstack,dc=org \ |
Lance Bragstad | f3f7c07 | 2018-03-30 20:56:04 +0000 | [diff] [blame] | 171 | -H ldap://localhost cn=guardians,ou=UserGroups,dc=openstack,dc=org |
| 172 | |
| 173 | Note that this operation will not remove users within that group. It will only |
| 174 | remove the group itself and the memberships any users had with that group. |