|
| 1 | +https://github.com/rroemhild/docker-test-openldap |
| 2 | + |
| 3 | +# OpenLDAP Docker Image for testing |
| 4 | + |
| 5 | +This Docker image provides an OpenLDAP Server for testing LDAP applications, i.e. unit tests. The server is initialized with the example domain `planetexpress.com` with data from the [Futurama Wiki][futuramawikia]. |
| 6 | + |
| 7 | +Parts of the image are based on the work from Nick Stenning [docker-slapd][slapd] and Bertrand Gouny [docker-openldap][openldap]. |
| 8 | + |
| 9 | +The Flask extension [flask-ldapconn][flaskldapconn] use this image for unit tests. |
| 10 | + |
| 11 | +[slapd]: https://github.com/nickstenning/docker-slapd |
| 12 | +[openldap]: https://github.com/osixia/docker-openldap |
| 13 | +[flaskldapconn]: https://github.com/rroemhild/flask-ldapconn |
| 14 | +[futuramawikia]: http://futurama.wikia.com |
| 15 | + |
| 16 | + |
| 17 | +## Features |
| 18 | + |
| 19 | +* Initialized with data from Futurama |
| 20 | +* Support for LDAP over TLS (STARTTLS) using a self-signed cert, or valid certificates (LetsEncrypt, etc) |
| 21 | +* memberOf overlay support |
| 22 | +* MS-AD style groups support |
| 23 | +* Supports Forced STARTTLS |
| 24 | +* Supports custom domain and custom directory structure |
| 25 | + |
| 26 | + |
| 27 | +## Usage |
| 28 | + |
| 29 | +``` |
| 30 | +docker pull ghcr.io/rroemhild/docker-test-openldap:master |
| 31 | +docker run --rm -p 10389:10389 -p 10636:10636 ghcr.io/rroemhild/docker-test-openldap:master |
| 32 | +``` |
| 33 | + |
| 34 | +## Testing |
| 35 | + |
| 36 | +``` |
| 37 | +# Enforce StartTLS with self-signed cert |
| 38 | +LDAPTLS_REQCERT=never ldapsearch -H ldap://localhost:10389 -ZZ -x -b "ou=people,dc=planetexpress,dc=com" -D "cn=admin,dc=planetexpress,dc=com" -w GoodNewsEveryone "(objectClass=inetOrgPerson)" |
| 39 | +
|
| 40 | +
|
| 41 | +# List all Users |
| 42 | +ldapsearch -H ldap://localhost:10389 -x -b "ou=people,dc=planetexpress,dc=com" -D "cn=admin,dc=planetexpress,dc=com" -w GoodNewsEveryone "(objectClass=inetOrgPerson)" |
| 43 | +
|
| 44 | +# Request StartTLS |
| 45 | +ldapsearch -H ldap://localhost:10389 -Z -x -b "ou=people,dc=planetexpress,dc=com" -D "cn=admin,dc=planetexpress,dc=com" -w GoodNewsEveryone "(objectClass=inetOrgPerson)" |
| 46 | +
|
| 47 | +# Enforce StartTLS |
| 48 | +ldapsearch -H ldap://localhost:10389 -ZZ -x -b "ou=people,dc=planetexpress,dc=com" -D "cn=admin,dc=planetexpress,dc=com" -w GoodNewsEveryone "(objectClass=inetOrgPerson)" |
| 49 | +
|
| 50 | +``` |
| 51 | + |
| 52 | +## Exposed ports |
| 53 | + |
| 54 | +* 10389 (ldap) |
| 55 | +* 10636 (ldaps) |
| 56 | + |
| 57 | +## Exposed volumes |
| 58 | + |
| 59 | +* /etc/ldap/slapd.d |
| 60 | +* /etc/ldap/ssl |
| 61 | +* /var/lib/ldap |
| 62 | +* /run/slapd |
| 63 | + |
| 64 | + |
| 65 | +## LDAP structure |
| 66 | + |
| 67 | +### dc=planetexpress,dc=com |
| 68 | + |
| 69 | +| Admin | Secret | |
| 70 | +| ---------------- | ---------------- | |
| 71 | +| cn=admin,dc=planetexpress,dc=com | GoodNewsEveryone | |
| 72 | + |
| 73 | +### ou=people,dc=planetexpress,dc=com |
| 74 | + |
| 75 | +#### cn=Hubert J. Farnsworth,ou=people,dc=planetexpress,dc=com |
| 76 | + |
| 77 | +| Attribute | Value | |
| 78 | +| ---------------- | ---------------- | |
| 79 | +| objectClass | inetOrgPerson | |
| 80 | +| cn | Hubert J. Farnsworth | |
| 81 | +| sn | Farnsworth | |
| 82 | +| description | Human | |
| 83 | +| displayName | Professor Farnsworth | |
| 84 | +| employeeType | Owner | |
| 85 | +| employeeType | Founder | |
| 86 | +| givenName | Hubert | |
| 87 | +| jpegPhoto | JPEG-Photo (630x507 Pixel, 26780 Bytes) | |
| 88 | + |
| 89 | + |
| 90 | +| ou | Office Management | |
| 91 | +| title | Professor | |
| 92 | +| uid | professor | |
| 93 | +| userPassword | professor | |
| 94 | + |
| 95 | + |
| 96 | +### cn=Philip J. Fry,ou=people,dc=planetexpress,dc=com |
| 97 | + |
| 98 | +| Attribute | Value | |
| 99 | +| ---------------- | ---------------- | |
| 100 | +| objectClass | inetOrgPerson | |
| 101 | +| cn | Philip J. Fry | |
| 102 | +| sn | Fry | |
| 103 | +| description | Human | |
| 104 | +| displayName | Fry | |
| 105 | +| employeeType | Delivery boy | |
| 106 | +| givenName | Philip | |
| 107 | +| jpegPhoto | JPEG-Photo (429x350 Pixel, 22132 Bytes) | |
| 108 | + |
| 109 | +| ou | Delivering Crew | |
| 110 | +| uid | fry | |
| 111 | +| userPassword | fry | |
| 112 | + |
| 113 | + |
| 114 | +### cn=John A. Zoidberg,ou=people,dc=planetexpress,dc=com |
| 115 | + |
| 116 | +| Attribute | Value | |
| 117 | +| ---------------- | ---------------- | |
| 118 | +| objectClass | inetOrgPerson | |
| 119 | +| cn | John A. Zoidberg | |
| 120 | +| sn | Zoidberg | |
| 121 | +| description | Decapodian | |
| 122 | +| displayName | Zoidberg | |
| 123 | +| employeeType | Doctor | |
| 124 | +| givenName | John | |
| 125 | +| jpegPhoto | JPEG-Photo (343x280 Pixel, 26438 Bytes) | |
| 126 | + |
| 127 | +| ou | Staff | |
| 128 | +| title | Ph. D. | |
| 129 | +| uid | zoidberg | |
| 130 | +| userPassword | zoidberg | |
| 131 | + |
| 132 | +### cn=Hermes Conrad,ou=people,dc=planetexpress,dc=com |
| 133 | + |
| 134 | +| Attribute | Value | |
| 135 | +| ---------------- | ---------------- | |
| 136 | +| objectClass | inetOrgPerson | |
| 137 | +| cn | Hermes Conrad | |
| 138 | +| sn | Conrad | |
| 139 | +| description | Human | |
| 140 | +| employeeType | Bureaucrat | |
| 141 | +| employeeType | Accountant | |
| 142 | +| givenName | Hermes | |
| 143 | + |
| 144 | +| ou | Office Management | |
| 145 | +| uid | hermes | |
| 146 | +| userPassword | hermes | |
| 147 | + |
| 148 | +### cn=Turanga Leela,ou=people,dc=planetexpress,dc=com |
| 149 | + |
| 150 | +| Attribute | Value | |
| 151 | +| ---------------- | ---------------- | |
| 152 | +| objectClass | inetOrgPerson | |
| 153 | +| cn | Turanga Leela | |
| 154 | +| sn | Turanga | |
| 155 | +| description | Mutant | |
| 156 | +| employeeType | Captain | |
| 157 | +| employeeType | Pilot | |
| 158 | +| givenName | Leela | |
| 159 | +| jpegPhoto | JPEG-Photo (429x350 Pixel, 26526 Bytes) | |
| 160 | + |
| 161 | +| ou | Delivering Crew | |
| 162 | +| uid | leela | |
| 163 | +| userPassword | leela | |
| 164 | + |
| 165 | +### cn=Bender Bending Rodríguez,ou=people,dc=planetexpress,dc=com |
| 166 | + |
| 167 | +| Attribute | Value | |
| 168 | +| ---------------- | ---------------- | |
| 169 | +| objectClass | inetOrgPerson | |
| 170 | +| cn | Bender Bending Rodríguez | |
| 171 | +| sn | Rodríguez | |
| 172 | +| description | Robot | |
| 173 | +| employeeType | Ship's Robot | |
| 174 | +| givenName | Bender | |
| 175 | +| jpegPhoto | JPEG-Photo (436x570 Pixel, 26819 Bytes) | |
| 176 | + |
| 177 | +| ou | Delivering Crew | |
| 178 | +| uid | bender | |
| 179 | +| userPassword | bender | |
| 180 | + |
| 181 | +### cn=Amy Wong+sn=Kroker,ou=people,dc=planetexpress,dc=com |
| 182 | + |
| 183 | +Amy has a multi-valued DN |
| 184 | + |
| 185 | +| Attribute | Value | |
| 186 | +| ---------------- | ---------------- | |
| 187 | +| objectClass | inetOrgPerson | |
| 188 | +| cn | Amy Wong | |
| 189 | +| sn | Kroker | |
| 190 | +| description | Human | |
| 191 | +| givenName | Amy | |
| 192 | + |
| 193 | +| ou | Intern | |
| 194 | +| uid | amy | |
| 195 | +| userPassword | amy | |
| 196 | + |
| 197 | +### cn=admin_staff,ou=people,dc=planetexpress,dc=com |
| 198 | + |
| 199 | +| Attribute | Value | |
| 200 | +| ---------------- | ---------------- | |
| 201 | +| objectClass | Group | |
| 202 | +| cn | admin_staff | |
| 203 | +| member | cn=Hubert J. Farnsworth,ou=people,dc=planetexpress,dc=com | |
| 204 | +| member | cn=Hermes Conrad,ou=people,dc=planetexpress,dc=com | |
| 205 | + |
| 206 | +### cn=ship_crew,ou=people,dc=planetexpress,dc=com |
| 207 | + |
| 208 | +| Attribute | Value | |
| 209 | +| ---------------- | ---------------- | |
| 210 | +| objectClass | Group | |
| 211 | +| cn | ship_crew | |
| 212 | +| member | cn=Turanga Leela,ou=people,dc=planetexpress,dc=com | |
| 213 | +| member | cn=Philip J. Fry,ou=people,dc=planetexpress,dc=com | |
| 214 | +| member | cn=Bender Bending Rodríguez,ou=people,dc=planetexpress,dc=com | |
| 215 | + |
| 216 | + |
| 217 | +## JAAS configuration |
| 218 | + |
| 219 | +In case you want to use this OpenLDAP server for testing with a Java-based |
| 220 | +application using JAAS and the `LdapLoginModule`, here's a working configuration |
| 221 | +file you can use to connect. |
| 222 | + |
| 223 | +``` |
| 224 | +other { |
| 225 | + com.sun.security.auth.module.LdapLoginModule REQUIRED |
| 226 | + userProvider="ldap://localhost:10389/ou=people,dc=planetexpress,dc=com" |
| 227 | + userFilter="(&(uid={USERNAME})(objectClass=inetOrgPerson))" |
| 228 | + useSSL=false |
| 229 | + java.naming.security.principal="cn=admin,dc=planetexpress,dc=com" |
| 230 | + java.naming.security.credentials="GoodNewsEveryone" |
| 231 | + debug=true |
| 232 | + ; |
| 233 | +}; |
| 234 | +``` |
| 235 | + |
| 236 | +This config uses the admin credentials to connect to the OpenLDAP server and to |
| 237 | +submit the search query for the user that enters their credentials. As username |
| 238 | +the `uid` attribute of each entry is used. |
0 commit comments