|
| 1 | +# LDAP authentication with MCS |
| 2 | + |
| 3 | +## Setup |
| 4 | + |
| 5 | +Run openLDAP with docker. |
| 6 | + |
| 7 | +``` |
| 8 | +$ docker run --rm -p 389:389 -p 636:636 --name my-openldap-container --detach osixia/openldap:1.3.0 |
| 9 | +``` |
| 10 | + |
| 11 | +Run the `billy.ldif` file using `ldapadd` command to create a new user and assign it to a group. |
| 12 | + |
| 13 | +``` |
| 14 | +$ cat > billy.ldif << EOF |
| 15 | +# LDIF fragment to create group branch under root |
| 16 | +dn: uid=billy,dc=example,dc=org |
| 17 | +uid: billy |
| 18 | +cn: billy |
| 19 | +sn: 3 |
| 20 | +objectClass: top |
| 21 | +objectClass: posixAccount |
| 22 | +objectClass: inetOrgPerson |
| 23 | +loginShell: /bin/bash |
| 24 | +homeDirectory: /home/billy |
| 25 | +uidNumber: 14583102 |
| 26 | +gidNumber: 14564100 |
| 27 | +userPassword: {SSHA}j3lBh1Seqe4rqF1+NuWmjhvtAni1JC5A |
| 28 | +mail: billy@example.org |
| 29 | +gecos: Billy User |
| 30 | +# Create base group |
| 31 | +dn: ou=groups,dc=example,dc=org |
| 32 | +objectclass:organizationalunit |
| 33 | +ou: groups |
| 34 | +description: generic groups branch |
| 35 | +# create mcsAdmin group (this already exists on minio and have a policy of s3::*) |
| 36 | +dn: cn=mcsAdmin,ou=groups,dc=example,dc=org |
| 37 | +objectClass: top |
| 38 | +objectClass: posixGroup |
| 39 | +gidNumber: 678 |
| 40 | +# Assing group to new user |
| 41 | +dn: cn=mcsAdmin,ou=groups,dc=example,dc=org |
| 42 | +changetype: modify |
| 43 | +add: memberuid |
| 44 | +memberuid: billy |
| 45 | +EOF |
| 46 | +
|
| 47 | +$ docker cp billy.ldif my-openldap-container:/container/service/slapd/assets/test/billy.ldif |
| 48 | +$ docker exec my-openldap-container ldapadd -x -D "cn=admin,dc=example,dc=org" -w admin -f /container/service/slapd/assets/test/billy.ldif -H ldap://localhost -ZZ |
| 49 | +``` |
| 50 | + |
| 51 | +Query the ldap server to check the user billy was created correctly and got assigned to the mcsAdmin group, you should get a list |
| 52 | +containing ldap users and groups. |
| 53 | + |
| 54 | +``` |
| 55 | +$ docker exec my-openldap-container ldapsearch -x -H ldap://localhost -b dc=example,dc=org -D "cn=admin,dc=example,dc=org" -w admin |
| 56 | +``` |
| 57 | + |
| 58 | +Query the ldap server again, this time filtering only for the user `billy`, you should see only 1 record. |
| 59 | + |
| 60 | +``` |
| 61 | +$ docker exec my-openldap-container ldapsearch -x -H ldap://localhost -b uid=billy,dc=example,dc=org -D "cn=admin,dc=example,dc=org" -w admin |
| 62 | +``` |
| 63 | + |
| 64 | +### Change the password for user billy |
| 65 | + |
| 66 | +Set the new password for `billy` to `minio123` and enter `admin` as the default `LDAP Password` |
| 67 | + |
| 68 | +``` |
| 69 | +$ docker exec -it my-openldap-container /bin/bash |
| 70 | +# ldappasswd -H ldap://localhost -x -D "cn=admin,dc=example,dc=org" -W -S "uid=billy,dc=example,dc=org" |
| 71 | +New password: |
| 72 | +Re-enter new password: |
| 73 | +Enter LDAP Password: |
| 74 | +``` |
| 75 | + |
| 76 | +### Add the mcsAdmin policy to user billy on MinIO |
| 77 | +``` |
| 78 | +$ cat > mcsAdmin.json << EOF |
| 79 | +{ |
| 80 | + "Version": "2012-10-17", |
| 81 | + "Statement": [ |
| 82 | + { |
| 83 | + "Action": [ |
| 84 | + "admin:*" |
| 85 | + ], |
| 86 | + "Effect": "Allow", |
| 87 | + "Sid": "" |
| 88 | + }, |
| 89 | + { |
| 90 | + "Action": [ |
| 91 | + "s3:*" |
| 92 | + ], |
| 93 | + "Effect": "Allow", |
| 94 | + "Resource": [ |
| 95 | + "arn:aws:s3:::*" |
| 96 | + ], |
| 97 | + "Sid": "" |
| 98 | + } |
| 99 | + ] |
| 100 | +} |
| 101 | +EOF |
| 102 | +$ mc admin policy add myminio mcsAdmin mcsAdmin.json |
| 103 | +$ mc admin policy set myminio mcsAdmin user=billy |
| 104 | +``` |
| 105 | + |
| 106 | +## Run MinIO |
| 107 | + |
| 108 | +``` |
| 109 | +export MINIO_ACCESS_KEY=minio |
| 110 | +export MINIO_SECRET_KEY=minio123 |
| 111 | +export MINIO_IDENTITY_LDAP_SERVER_ADDR='localhost:389' |
| 112 | +export MINIO_IDENTITY_LDAP_USERNAME_FORMAT='uid=%s,dc=example,dc=org' |
| 113 | +export MINIO_IDENTITY_LDAP_USERNAME_SEARCH_FILTER='(|(objectclass=posixAccount)(uid=%s))' |
| 114 | +export MINIO_IDENTITY_LDAP_TLS_SKIP_VERIFY=on |
| 115 | +export MINIO_IDENTITY_LDAP_SERVER_INSECURE=on |
| 116 | +./minio server ~/Data |
| 117 | +``` |
| 118 | + |
| 119 | +## Run MCS |
| 120 | + |
| 121 | +``` |
| 122 | +export MCS_ACCESS_KEY=minio |
| 123 | +export MCS_SECRET_KEY=minio123 |
| 124 | +... |
| 125 | +export MCS_LDAP_ENABLED=on |
| 126 | +./mcs server |
| 127 | +``` |
0 commit comments