make ldap cert check configurable, fix CodeQL warnings
This commit is contained in:
parent
588f8c7c70
commit
6ece6e5be9
|
@ -182,7 +182,7 @@ func (provider Provider) open() (*ldap.Conn, error) {
|
||||||
|
|
||||||
if provider.config.StartTLS {
|
if provider.config.StartTLS {
|
||||||
// Reconnect with TLS
|
// Reconnect with TLS
|
||||||
err = conn.StartTLS(&tls.Config{InsecureSkipVerify: true})
|
err = conn.StartTLS(&tls.Config{InsecureSkipVerify: !provider.config.CertValidation})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ const (
|
||||||
type Config struct {
|
type Config struct {
|
||||||
URL string `yaml:"url" envconfig:"LDAP_URL"`
|
URL string `yaml:"url" envconfig:"LDAP_URL"`
|
||||||
StartTLS bool `yaml:"startTLS" envconfig:"LDAP_STARTTLS"`
|
StartTLS bool `yaml:"startTLS" envconfig:"LDAP_STARTTLS"`
|
||||||
|
CertValidation bool `yaml:"certcheck" envconfig:"LDAP_CERT_VALIDATION"`
|
||||||
BaseDN string `yaml:"dn" envconfig:"LDAP_BASEDN"`
|
BaseDN string `yaml:"dn" envconfig:"LDAP_BASEDN"`
|
||||||
BindUser string `yaml:"user" envconfig:"LDAP_USER"`
|
BindUser string `yaml:"user" envconfig:"LDAP_USER"`
|
||||||
BindPass string `yaml:"pass" envconfig:"LDAP_PASSWORD"`
|
BindPass string `yaml:"pass" envconfig:"LDAP_PASSWORD"`
|
||||||
|
|
|
@ -23,7 +23,7 @@ func Open(cfg *Config) (*ldap.Conn, error) {
|
||||||
|
|
||||||
if cfg.StartTLS {
|
if cfg.StartTLS {
|
||||||
// Reconnect with TLS
|
// Reconnect with TLS
|
||||||
err = conn.StartTLS(&tls.Config{InsecureSkipVerify: true})
|
err = conn.StartTLS(&tls.Config{InsecureSkipVerify: !cfg.CertValidation})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "failed to star TLS on connection")
|
return nil, errors.Wrap(err, "failed to star TLS on connection")
|
||||||
}
|
}
|
||||||
|
@ -92,7 +92,7 @@ func IsActiveDirectoryUserDisabled(userAccountControl string) bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
uacInt, err := strconv.Atoi(userAccountControl)
|
uacInt, err := strconv.ParseInt(userAccountControl, 10, 32)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue