Skip to content
Snippets Groups Projects
Commit 54fb570f authored by Maksim Nabokikh's avatar Maksim Nabokikh Committed by m.nabokikh
Browse files

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: default avatarm.nabokikh <maksim.nabokikh@flant.com>
parent 257a821c
No related branches found
No related tags found
No related merge requests found
...@@ -121,8 +121,8 @@ jobs: ...@@ -121,8 +121,8 @@ jobs:
DEX_ETCD_ENDPOINTS: http://localhost:${{ job.services.etcd.ports[2379] }} DEX_ETCD_ENDPOINTS: http://localhost:${{ job.services.etcd.ports[2379] }}
DEX_LDAP_HOST: localhost DEX_LDAP_HOST: localhost
DEX_LDAP_PORT: 389 DEX_LDAP_PORT: 3890
DEX_LDAP_TLS_PORT: 636 DEX_LDAP_TLS_PORT: 6360
DEX_KEYSTONE_URL: http://localhost:${{ job.services.keystone.ports[5000] }} DEX_KEYSTONE_URL: http://localhost:${{ job.services.keystone.ports[5000] }}
DEX_KEYSTONE_ADMIN_URL: http://localhost:${{ job.services.keystone.ports[35357] }} DEX_KEYSTONE_ADMIN_URL: http://localhost:${{ job.services.keystone.ports[35357] }}
......
...@@ -322,10 +322,10 @@ func (c *ldapConnector) do(_ context.Context, f func(c *ldap.Conn) error) error ...@@ -322,10 +322,10 @@ func (c *ldapConnector) do(_ context.Context, f func(c *ldap.Conn) error) error
switch { switch {
case c.InsecureNoSSL: case c.InsecureNoSSL:
u := url.URL{Scheme: "ldap://", Host: c.Host} u := url.URL{Scheme: "ldap", Host: c.Host}
conn, err = ldap.DialURL(u.String()) conn, err = ldap.DialURL(u.String())
case c.StartTLS: case c.StartTLS:
u := url.URL{Scheme: "ldap://", Host: c.Host} u := url.URL{Scheme: "ldap", Host: c.Host}
conn, err = ldap.DialURL(u.String()) conn, err = ldap.DialURL(u.String())
if err != nil { if err != nil {
return fmt.Errorf("failed to connect: %v", err) 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 ...@@ -334,7 +334,7 @@ func (c *ldapConnector) do(_ context.Context, f func(c *ldap.Conn) error) error
return fmt.Errorf("start TLS failed: %v", err) return fmt.Errorf("start TLS failed: %v", err)
} }
default: default:
u := url.URL{Scheme: "ldaps://", Host: c.Host} u := url.URL{Scheme: "ldaps", Host: c.Host}
conn, err = ldap.DialURL(u.String(), ldap.DialWithTLSConfig(c.tlsConfig)) conn, err = ldap.DialURL(u.String(), ldap.DialWithTLSConfig(c.tlsConfig))
} }
if err != nil { if err != nil {
......
...@@ -11,8 +11,8 @@ services: ...@@ -11,8 +11,8 @@ services:
LDAP_TLS: "true" LDAP_TLS: "true"
LDAP_TLS_VERIFY_CLIENT: try LDAP_TLS_VERIFY_CLIENT: try
ports: ports:
- 389:389 - 3890:389
- 636:636 - 6360:636
volumes: volumes:
- ./connector/ldap/testdata/certs:/container/service/slapd/assets/certs - ./connector/ldap/testdata/certs:/container/service/slapd/assets/certs
- ./connector/ldap/testdata/schema.ldif:/container/service/slapd/assets/config/bootstrap/ldif/99-schema.ldif - ./connector/ldap/testdata/schema.ldif:/container/service/slapd/assets/config/bootstrap/ldif/99-schema.ldif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment