Skip to content

Commit d1f92e4

Browse files
committed
LDAP plugin: rename flag ldap-cacert to ldap-ca-cert-file, new flag ldap-insecure-skip-verify
1 parent 04f8a27 commit d1f92e4

File tree

2 files changed

+15
-13
lines changed

2 files changed

+15
-13
lines changed

cmd/plugin-auth-ldap/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ build/kafka-proxy server \
1313
--auth-local-enable \
1414
--auth-local-command=build/auth-ldap \
1515
--auth-local-param=--url=ldap://localhost:389 \
16-
--auth-local-param=--ldap-cacerts=/certs/ldap/pem \
16+
--auth-local-param=--ldap-ca-cert-file=/certs/ldap/ca-cert-file.pem \
1717
--auth-local-param=--start-tls=false \
1818
--auth-local-param=--search-ldap \
1919
--auth-local-param=--bind-dn=cn=admin,dc=example,dc=org \
@@ -25,8 +25,8 @@ build/kafka-proxy server \
2525
Setting the flag `--search-ldap` will search the user dn in LDAP, even if `--bind-dn` is not given. This is for LDAP
2626
installations that don't need a bind before allowing readonly actions.(and therefore don't have a readony user)
2727

28-
If `--ldap-cacerts` is set, a (chain of) certificates in PEM format needed to verify the LDAP server's identity
29-
is read from the file given. If the flag ist not set, TLS verification will be skipped
28+
If `--ldap-ca-cert-file` is set, a (chain of) certificates in PEM format needed to verify the LDAP server's identity
29+
is read from the file given. If the flag ist not set, TLS verification can be skipped if `ldap-insecure-skip-verify` flag is true.
3030

3131

3232

cmd/plugin-auth-ldap/main.go

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -194,12 +194,13 @@ func (pa LdapAuthenticator) DialLDAP() (*ldap.Conn, error) {
194194
}
195195

196196
type pluginMeta struct {
197-
url string
198-
cacert string
199-
startTLS bool
200-
upnDomain string
201-
userDN string
202-
userAttr string
197+
url string
198+
caCertFile string
199+
insecureSkipVerify bool
200+
startTLS bool
201+
upnDomain string
202+
userDN string
203+
userAttr string
203204

204205
searchLDAP bool
205206
bindDN string
@@ -212,7 +213,8 @@ func (f *pluginMeta) flagSet() *flag.FlagSet {
212213
fs := flag.NewFlagSet("auth plugin settings", flag.ContinueOnError)
213214

214215
fs.StringVar(&f.url, "url", "", "LDAP URL to connect to (eg: ldaps://127.0.0.1:636). Multiple URLs can be specified by concatenating them with commas.")
215-
fs.StringVar(&f.cacert, "ldap-cacert", "", "X509 CA certificate (PEM) to verify peer against")
216+
fs.StringVar(&f.caCertFile, "ldap-ca-cert-file", "", "X509 CA certificate (PEM) to verify peer against")
217+
fs.BoolVar(&f.insecureSkipVerify, "ldap-insecure-skip-verify", false, "It controls whether a client verifies the server's certificate chain and host name")
216218
fs.BoolVar(&f.startTLS, "start-tls", true, "Issue a StartTLS command after establishing unencrypted connection (optional)")
217219
fs.StringVar(&f.upnDomain, "upn-domain", "", "Enables userPrincipalDomain login with [username]@UPNDomain (optional)")
218220
fs.StringVar(&f.userDN, "user-dn", "", "LDAP domain to use for users (eg: cn=users,dc=example,dc=org)")
@@ -283,7 +285,7 @@ func main() {
283285
os.Exit(1)
284286
}
285287

286-
tlsConfig, err := getTlsConfig(pluginMeta.cacert)
288+
tlsConfig, err := getTlsConfig(pluginMeta.caCertFile, pluginMeta.insecureSkipVerify)
287289
if err != nil {
288290
logrus.Errorf("error %v getting TLS config", err)
289291
os.Exit(1)
@@ -311,9 +313,9 @@ func main() {
311313
})
312314
}
313315

314-
func getTlsConfig(caCertFile string) (*tls.Config, error) {
316+
func getTlsConfig(caCertFile string, insecureSkipVerify bool) (*tls.Config, error) {
315317
if caCertFile == "" {
316-
return &tls.Config{InsecureSkipVerify: true}, nil
318+
return &tls.Config{InsecureSkipVerify: insecureSkipVerify}, nil
317319
} else {
318320
certData, err := ioutil.ReadFile(caCertFile)
319321
if err != nil {

0 commit comments

Comments
 (0)