mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-02 03:27:54 +00:00
sdk/ldaputil: add request_timeout configuration option (#7909)
* sdk/ldaputil: add request_timeout configuration option * go mod vendor
This commit is contained in:
committed by
GitHub
parent
4e134b6a26
commit
6191cfaf91
@@ -11,6 +11,7 @@ import (
|
||||
"net/url"
|
||||
"strings"
|
||||
"text/template"
|
||||
"time"
|
||||
|
||||
"github.com/go-ldap/ldap/v3"
|
||||
"github.com/hashicorp/errwrap"
|
||||
@@ -85,6 +86,10 @@ func (c *Client) DialLDAP(cfg *ConfigEntry) (Connection, error) {
|
||||
retErr = multierror.Append(retErr, errwrap.Wrapf(fmt.Sprintf("error connecting to host %q: {{err}}", uut), err))
|
||||
}
|
||||
|
||||
if timeout := cfg.RequestTimeout; timeout > 0 {
|
||||
conn.SetTimeout(time.Duration(timeout) * time.Second)
|
||||
}
|
||||
|
||||
return conn, retErr.ErrorOrNil()
|
||||
}
|
||||
|
||||
@@ -205,7 +210,9 @@ func (c *Client) performLdapFilterGroupsSearch(cfg *ConfigEntry, conn Connection
|
||||
}
|
||||
|
||||
var renderedQuery bytes.Buffer
|
||||
t.Execute(&renderedQuery, context)
|
||||
if err := t.Execute(&renderedQuery, context); err != nil {
|
||||
return nil, errwrap.Wrapf("LDAP search failed due to template parsing error: {{error}}", err)
|
||||
}
|
||||
|
||||
if c.Logger.IsDebug() {
|
||||
c.Logger.Debug("searching", "groupdn", cfg.GroupDN, "rendered_query", renderedQuery.String())
|
||||
|
||||
Reference in New Issue
Block a user