Skip to content

Commit 54fb570

Browse files
committed
Fix scheme for DialURL ldap connection (#3677)
* Use scheme without :// suffix * Make test ldap server listen on custom ports to avoid stepping into go-ldap defaults Signed-off-by: m.nabokikh <maksim.nabokikh@flant.com>
1 parent 257a821 commit 54fb570

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

.github/workflows/ci.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ jobs:
121121
DEX_ETCD_ENDPOINTS: http://localhost:${{ job.services.etcd.ports[2379] }}
122122

123123
DEX_LDAP_HOST: localhost
124-
DEX_LDAP_PORT: 389
125-
DEX_LDAP_TLS_PORT: 636
124+
DEX_LDAP_PORT: 3890
125+
DEX_LDAP_TLS_PORT: 6360
126126

127127
DEX_KEYSTONE_URL: http://localhost:${{ job.services.keystone.ports[5000] }}
128128
DEX_KEYSTONE_ADMIN_URL: http://localhost:${{ job.services.keystone.ports[35357] }}

connector/ldap/ldap.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -322,10 +322,10 @@ func (c *ldapConnector) do(_ context.Context, f func(c *ldap.Conn) error) error
322322

323323
switch {
324324
case c.InsecureNoSSL:
325-
u := url.URL{Scheme: "ldap://", Host: c.Host}
325+
u := url.URL{Scheme: "ldap", Host: c.Host}
326326
conn, err = ldap.DialURL(u.String())
327327
case c.StartTLS:
328-
u := url.URL{Scheme: "ldap://", Host: c.Host}
328+
u := url.URL{Scheme: "ldap", Host: c.Host}
329329
conn, err = ldap.DialURL(u.String())
330330
if err != nil {
331331
return fmt.Errorf("failed to connect: %v", err)
@@ -334,7 +334,7 @@ func (c *ldapConnector) do(_ context.Context, f func(c *ldap.Conn) error) error
334334
return fmt.Errorf("start TLS failed: %v", err)
335335
}
336336
default:
337-
u := url.URL{Scheme: "ldaps://", Host: c.Host}
337+
u := url.URL{Scheme: "ldaps", Host: c.Host}
338338
conn, err = ldap.DialURL(u.String(), ldap.DialWithTLSConfig(c.tlsConfig))
339339
}
340340
if err != nil {

docker-compose.test.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ services:
1111
LDAP_TLS: "true"
1212
LDAP_TLS_VERIFY_CLIENT: try
1313
ports:
14-
- 389:389
15-
- 636:636
14+
- 3890:389
15+
- 6360:636
1616
volumes:
1717
- ./connector/ldap/testdata/certs:/container/service/slapd/assets/certs
1818
- ./connector/ldap/testdata/schema.ldif:/container/service/slapd/assets/config/bootstrap/ldif/99-schema.ldif

0 commit comments

Comments
 (0)