Skip to content

Commit 7a23582

Browse files
authored
Get LDAP identity for console access/secret keys (#398)
- If MinIO is configured with LDAP then users and groups are external, and the credentials provided in the CONSOLE_ACCESS_KEY and CONSOLE_SECRET_KEY env vars will belong to an existing user in the active directory, therefore we need to authenticate first with `credentials.NewLDAPIdentity` - Fixed race condition bug in which TLS RootCAs certs were not loading correctly (certPool was always null) - Fixed TLS bug in which if Console was deployed without TLS enabled RootCAs certs were not loading - Initialize LDAP Admin credentials once - Initialize stsClient once
1 parent 8a6a75b commit 7a23582

File tree

12 files changed

+136
-233
lines changed

12 files changed

+136
-233
lines changed

DEVELOPMENT.md

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -11,40 +11,7 @@ $ docker run --rm -p 389:389 -p 636:636 --name my-openldap-container --detach os
1111
Run the `billy.ldif` file using `ldapadd` command to create a new user and assign it to a group.
1212

1313
```
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 consoleAdmin group (this already exists on minio and have a policy of s3::*)
36-
dn: cn=consoleAdmin,ou=groups,dc=example,dc=org
37-
objectClass: top
38-
objectClass: posixGroup
39-
gidNumber: 678
40-
# Assing group to new user
41-
dn: cn=consoleAdmin,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
14+
$ docker cp console/docs/ldap/billy.ldif my-openldap-container:/container/service/slapd/assets/test/billy.ldif
4815
$ 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
4916
```
5017

cmd/console/server.go

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ import (
2828
"github.com/minio/console/pkg/certs"
2929
"github.com/minio/console/restapi"
3030
"github.com/minio/console/restapi/operations"
31-
"github.com/minio/minio/cmd/logger"
32-
certsx "github.com/minio/minio/pkg/certs"
3331
)
3432

3533
// starts the server
@@ -107,22 +105,18 @@ func startServer(ctx *cli.Context) error {
107105
restapi.Hostname = ctx.String("host")
108106
restapi.Port = fmt.Sprintf("%v", ctx.Int("port"))
109107

110-
// Set all certs and CAs directories.
108+
// Set all certs and CAs directories path
111109
certs.GlobalCertsDir, _ = certs.NewConfigDirFromCtx(ctx, "certs-dir", certs.DefaultCertsDir.Get)
112110
certs.GlobalCertsCADir = &certs.ConfigDir{Path: filepath.Join(certs.GlobalCertsDir.Get(), certs.CertsCADir)}
113111

112+
// check if certs and CAs directories exists or can be created
114113
if err := certs.MkdirAllIgnorePerm(certs.GlobalCertsCADir.Get()); err != nil {
115114
log.Println(fmt.Sprintf("Unable to create certs CA directory at %s", certs.GlobalCertsCADir.Get()))
116115
}
116+
// load the certificates and the CAs
117+
restapi.GlobalRootCAs, restapi.GlobalPublicCerts, restapi.GlobalTLSCertsManager = certs.GetAllCertificatesAndCAs()
117118

118-
// load all CAs from ~/.console/certs/CAs
119-
restapi.GlobalRootCAs, err = certsx.GetRootCAs(certs.GlobalCertsCADir.Get())
120-
logger.FatalIf(err, "Failed to read root CAs (%v)", err)
121-
// load all certs from ~/.console/certs
122-
restapi.GlobalPublicCerts, restapi.GlobalTLSCertsManager, err = certs.GetTLSConfig()
123-
logger.FatalIf(err, "Unable to load the TLS configuration")
124-
125-
if len(restapi.GlobalPublicCerts) > 0 && restapi.GlobalRootCAs != nil {
119+
if len(restapi.GlobalPublicCerts) > 0 {
126120
// If TLS certificates are provided enforce the HTTPS schema, meaning console will redirect
127121
// plain HTTP connections to HTTPS server
128122
server.EnabledListeners = []string{"http", "https"}

docs/ldap/billy.ldif

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# LDIF fragment to create group branch under root
2+
dn: uid=billy,dc=example,dc=org
3+
uid: billy
4+
cn: billy
5+
sn: 3
6+
objectClass: top
7+
objectClass: posixAccount
8+
objectClass: inetOrgPerson
9+
loginShell: /bin/bash
10+
homeDirectory: /home/billy
11+
uidNumber: 14583102
12+
gidNumber: 14564100
13+
userPassword: {SSHA}j3lBh1Seqe4rqF1+NuWmjhvtAni1JC5A
14+
mail: billy@example.org
15+
gecos: Billy User
16+
17+
# Create base group
18+
dn: ou=groups,dc=example,dc=org
19+
objectclass:organizationalunit
20+
ou: groups
21+
description: generic groups branch
22+
23+
# create consoleAdmin group (this already exists on minio and have a policy of s3::*)
24+
dn: cn=consoleAdmin,ou=groups,dc=example,dc=org
25+
objectClass: top
26+
objectClass: posixGroup
27+
gidNumber: 678
28+
29+
# Assing group to new user
30+
dn: cn=consoleAdmin,ou=groups,dc=example,dc=org
31+
changetype: modify
32+
add: memberuid
33+
memberuid: billy
34+
35+

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ require (
1818
github.com/minio/kes v0.11.0
1919
github.com/minio/mc v0.0.0-20201119214335-d4f9ea859d6c
2020
github.com/minio/minio v0.0.0-20201102034248-d8e07f2c41c8
21-
github.com/minio/minio-go/v7 v7.0.6-0.20200929220449-755b5633803a
21+
github.com/minio/minio-go/v7 v7.0.6-0.20201119032702-6914cb678dde
2222
github.com/minio/operator v0.0.0-20201022162018-527e5c32132b
2323
github.com/mitchellh/go-homedir v1.1.0
2424
github.com/pquerna/cachecontrol v0.0.0-20180517163645-1555304b9b35 // indirect

0 commit comments

Comments
 (0)