blob: 4c54723c71c1492fb8555c3500c16778e14b24df [file] [log] [blame]
Lance Bragstadf3f7c072018-03-30 20:56:04 +00001============================
2Deploying DevStack with LDAP
3============================
4
5The OpenStack Identity service has the ability to integrate with LDAP. The goal
6of this guide is to walk you through setting up an LDAP-backed OpenStack
7development environment.
8
9Introduction
10============
11
12LDAP support in keystone is read-only. You can use it to back an entire
13OpenStack deployment to a single LDAP server, or you can use it to back
14separate LDAP servers to specific keystone domains. Users within those domains
Lance Bragstad8e802da2019-01-04 15:21:43 +000015can authenticate against keystone, assume role assignments, and interact with
16other OpenStack services.
Lance Bragstadf3f7c072018-03-30 20:56:04 +000017
18Configuration
19=============
20
21To deploy an OpenLDAP server, make sure ``ldap`` is added to the list of
Lance Bragstad8e802da2019-01-04 15:21:43 +000022``ENABLED_SERVICES`` in the ``local.conf`` file::
Lance Bragstadf3f7c072018-03-30 20:56:04 +000023
24 enable_service ldap
25
26Devstack will require a password to set up an LDAP administrator. This
27administrative user is also the bind user specified in keystone's configuration
28files, similar to a ``keystone`` user for MySQL databases.
29
30Devstack 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
36At this point, devstack should have everything it needs to deploy OpenLDAP,
37bootstrap it with a minimal set of users, and configure it to back to a domain
Lance Bragstad8e802da2019-01-04 15:21:43 +000038in keystone. You can do this by running the ``stack.sh`` script::
Lance Bragstadf3f7c072018-03-30 20:56:04 +000039
Lance Bragstad8e802da2019-01-04 15:21:43 +000040 $ ./stack.sh
Lance Bragstadf3f7c072018-03-30 20:56:04 +000041
42Once ``stack.sh`` completes, you should have a running keystone deployment with
43a basic set of users. It is important to note that not all users will live
44within LDAP. Instead, keystone will back different domains to different
45identity sources. For example, the ``default`` domain will be backed by MySQL.
46This is usually where you'll find your administrative and services users. If
47you 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
50User Management
51===============
52
53Initially, there will only be two users in the LDAP server. The ``Manager``
54user is used by keystone to talk to OpenLDAP. The ``demo`` user is a generic
55user 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
57utilities installed by devstack (e.g. ``ldap-utils``) and LDIFs. The LDIFs used
58to create these users can be found in ``devstack/files/ldap/``.
59
60Listing Users
61-------------
62
63To list all users in LDAP directly, you can use ``ldapsearch`` with the LDAP
64user bootstrapped by devstack::
65
Lance Bragstad8e802da2019-01-04 15:21:43 +000066 $ ldapsearch -x -w LDAP_PASSWORD -D cn=Manager,dc=openstack,dc=org \
Lance Bragstadf3f7c072018-03-30 20:56:04 +000067 -H ldap://localhost -b dc=openstack,dc=org
68
69As you can see, devstack creates an OpenStack domain called ``openstack.org``
70as a container for the ``Manager`` and ``demo`` users.
71
72Creating Users
73--------------
74
75Since keystone's LDAP integration is read-only, users must be added directly to
76LDAP. Users added directly to OpenLDAP will automatically be placed into the
77``Users`` domain.
78
79LDIFs can be used to add users via the command line. The following is an
80example 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
94Now, we use the ``Manager`` user to create a user for Peter in LDAP::
95
Lance Bragstad8e802da2019-01-04 15:21:43 +000096 $ ldapadd -x -w LDAP_PASSWORD -D cn=Manager,dc=openstack,dc=org \
Lance Bragstadf3f7c072018-03-30 20:56:04 +000097 -H ldap://localhost -c -f peter.ldif.in
98
99We should be able to assign Peter roles on projects. After Peter has some level
100of authorization, he should be able to login to Horizon by specifying the
101``Users`` domain and using his ``peter`` username and password. Authorization
102can be given to Peter by creating a project within the ``Users`` domain and
103giving 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
122Deleting Users
123--------------
124
125We can use the same basic steps to remove users from LDAP, but instead of using
126LDIFs, we can just pass the ``dn`` of the user we want to delete::
127
Lance Bragstad8e802da2019-01-04 15:21:43 +0000128 $ ldapdelete -x -w LDAP_PASSWORD -D cn=Manager,dc=openstack,dc=org \
Lance Bragstadf3f7c072018-03-30 20:56:04 +0000129 -H ldap://localhost cn=peter,ou=Users,dc=openstack,dc=org
130
131Group Management
132================
133
134Like users, groups are considered specific identities. This means that groups
135also fall under the same read-only constraints as users and they can be managed
136directly with LDAP in the same way users are with LDIFs.
137
138Adding Groups
139-------------
140
141Let'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
153We can create the group using the same ``ldapadd`` command as we did with
154users::
155
Lance Bragstad8e802da2019-01-04 15:21:43 +0000156 $ ldapadd -x -w LDAP_PASSWORD -D cn=Manager,dc=openstack,dc=org \
Lance Bragstadf3f7c072018-03-30 20:56:04 +0000157 -H ldap://localhost -c -f guardian-group.ldif.in
158
159If we check the group membership in Horizon, we'll see that only Peter is a
160member of the ``guardians`` group, despite the whole crew being specified in
161the LDIF. Once those accounts are created in LDAP, they will automatically be
162added to the ``guardians`` group. They will also assume any role assignments
163given to the ``guardians`` group.
164
165Deleting Groups
166---------------
167
168Just like users, groups can be deleted using the ``dn``::
169
Lance Bragstad8e802da2019-01-04 15:21:43 +0000170 $ ldapdelete -x -w LDAP_PASSWORD -D cn=Manager,dc=openstack,dc=org \
Lance Bragstadf3f7c072018-03-30 20:56:04 +0000171 -H ldap://localhost cn=guardians,ou=UserGroups,dc=openstack,dc=org
172
173Note that this operation will not remove users within that group. It will only
174remove the group itself and the memberships any users had with that group.