make ldap cert check configurable, fix CodeQL warnings

This commit is contained in:
Christoph Haas 2021-03-22 22:52:08 +01:00
parent 588f8c7c70
commit 6ece6e5be9
3 changed files with 9 additions and 8 deletions

View File

@ -182,7 +182,7 @@ func (provider Provider) open() (*ldap.Conn, error) {
if provider.config.StartTLS {
// Reconnect with TLS
err = conn.StartTLS(&tls.Config{InsecureSkipVerify: true})
err = conn.StartTLS(&tls.Config{InsecureSkipVerify: !provider.config.CertValidation})
if err != nil {
return nil, err
}

View File

@ -10,6 +10,7 @@ const (
type Config struct {
URL string `yaml:"url" envconfig:"LDAP_URL"`
StartTLS bool `yaml:"startTLS" envconfig:"LDAP_STARTTLS"`
CertValidation bool `yaml:"certcheck" envconfig:"LDAP_CERT_VALIDATION"`
BaseDN string `yaml:"dn" envconfig:"LDAP_BASEDN"`
BindUser string `yaml:"user" envconfig:"LDAP_USER"`
BindPass string `yaml:"pass" envconfig:"LDAP_PASSWORD"`

View File

@ -23,7 +23,7 @@ func Open(cfg *Config) (*ldap.Conn, error) {
if cfg.StartTLS {
// Reconnect with TLS
err = conn.StartTLS(&tls.Config{InsecureSkipVerify: true})
err = conn.StartTLS(&tls.Config{InsecureSkipVerify: !cfg.CertValidation})
if err != nil {
return nil, errors.Wrap(err, "failed to star TLS on connection")
}
@ -92,7 +92,7 @@ func IsActiveDirectoryUserDisabled(userAccountControl string) bool {
return false
}
uacInt, err := strconv.Atoi(userAccountControl)
uacInt, err := strconv.ParseInt(userAccountControl, 10, 32)
if err != nil {
return true
}