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", Port: "389", Host: "127.0.0.1", 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 ¶
View Source
const StrategyKey = auth.StrategyKey("LDAP.Strategy")
StrategyKey export identifier for the LDAP strategy, commonly used when enable/add strategy to go-guardian authenticator.
Variables ¶
View Source
var ErrEntries = errors.New("LDAP: Serach 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 ¶
Types ¶
type Config ¶
type Config struct { // Port LDAP server port. Port string // Host LDAP server host. Host 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.