Documentation ¶
Overview ¶
Package ldap provides authentication strategy, to authenticate HTTP requests and builds, extracts user informations from LDAP Server.
Example ¶
cfg := Config{ BaseDN: "dc=example,dc=org", BindDN: "cn=readonly,dc=example,dc=org", URL: "ldap://127.0.0.1:389", BindPassword: "readonly", Filter: "(cn=%s)", } r, _ := http.NewRequest("GET", "/", nil) r.SetBasicAuth("admin", "admin") info, err := New(&cfg).Authenticate(r.Context(), r) fmt.Println(info, err != nil)
Output: <nil> true
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrEntries = errors.New("strategies/ldap: Search user DN does not exist or too many entries returned")
ErrEntries is returned by ldap authenticate function, When search result return user DN does not exist or too many entries returned.
Functions ¶
func GetAuthenticateFunc ¶
func GetAuthenticateFunc(cfg *Config, opts ...auth.Option) basic.AuthenticateFunc
GetAuthenticateFunc return function to authenticate request using LDAP. The returned function typically used with the basic strategy.
Types ¶
type Config ¶
type Config struct { // Port LDAP server port. // Deprecated: Use URL instead. Port string // Host LDAP server host. // Deprecated: Use URL instead. Host string // Specify LDAP URL URL string // TLS configuration, if nil connect without TLS. TLS *tls.Config // BindDN represents LDAP DN for searching for the user DN. // Typically read only user DN. BindDN string // BindPassword LDAP password for searching for the user DN. // Typically read only user password. BindPassword string // Attributes used for users. Attributes []string // BaseDN LDAP domain to use for users. BaseDN string // Filter for the User Object Filter. // if username nedded more than once use fmt index pattern (%[1]s). // Otherwise %s. Filter string }
Config define the configuration to connect to LDAP.
Click to show internal directories.
Click to hide internal directories.