Documentation
¶
Overview ¶
Package ldapAuth a ldap authentication plugin. nolint
Index ¶
- Variables
- func Connect(config LdapServerConfig) (*ldap.Conn, error)
- func LdapCheckAllowedUsers(conn *ldap.Conn, config *Config, entry *ldap.Entry, username string) bool
- func LdapCheckUser(conn *ldap.Conn, config *Config, server LdapServerConfig, ...) (bool, *ldap.Entry, error)
- func LdapCheckUserAuthorized(conn *ldap.Conn, config *Config, entry *ldap.Entry, username string) (bool, error)
- func LdapCheckUserGroups(conn *ldap.Conn, config *Config, entry *ldap.Entry, username string) (bool, error)
- func New(ctx context.Context, next http.Handler, config *Config, name string) (http.Handler, error)
- func ParseSearchFilter(config *Config) (string, error)
- func RequireAuth(w http.ResponseWriter, req *http.Request, config *Config, err error)
- func SearchMode(conn *ldap.Conn, config *Config) (*ldap.SearchResult, error)
- func ServeAuthenicated(la *LdapAuth, session *sessions.Session, rw http.ResponseWriter, ...)
- func SetLogger(level string)
- type Config
- type LdapAuth
- type LdapServerConfig
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // LoggerDEBUG level. LoggerDEBUG = log.New(io.Discard, "DEBUG: ldapAuth: ", log.Ldate|log.Ltime|log.Lshortfile) // LoggerINFO level. LoggerINFO = log.New(io.Discard, "INFO: ldapAuth: ", log.Ldate|log.Ltime|log.Lshortfile) // LoggerWARNING level. LoggerWARNING = log.New(io.Discard, "WARNING: ldapAuth: ", log.Ldate|log.Ltime|log.Lshortfile) // LoggerERROR level. LoggerERROR = log.New(io.Discard, "ERROR: ldapAuth: ", log.Ldate|log.Ltime|log.Lshortfile) )
nolint
Functions ¶
func Connect ¶
func Connect(config LdapServerConfig) (*ldap.Conn, error)
Connect return a LDAP Connection.
func LdapCheckAllowedUsers ¶
func LdapCheckAllowedUsers(conn *ldap.Conn, config *Config, entry *ldap.Entry, username string) bool
LdapCheckAllowedUsers check if user is explicitly allowed in AllowedUsers list
func LdapCheckUser ¶
func LdapCheckUser(conn *ldap.Conn, config *Config, server LdapServerConfig, username, password string) (bool, *ldap.Entry, error)
LdapCheckUser check if user and password are correct.
func LdapCheckUserAuthorized ¶
func LdapCheckUserAuthorized(conn *ldap.Conn, config *Config, entry *ldap.Entry, username string) (bool, error)
LdapCheckUserAuthorized check if user is authorized post-authentication
func LdapCheckUserGroups ¶
func LdapCheckUserGroups(conn *ldap.Conn, config *Config, entry *ldap.Entry, username string) (bool, error)
LdapCheckUserGroups check if the is user is a member of any of the AllowedGroups list
func ParseSearchFilter ¶
ParseSearchFilter remove spaces and trailing from searchFilter.
func RequireAuth ¶
RequireAuth set Auth request.
func SearchMode ¶
SearchMode make search to LDAP and return results.
func ServeAuthenicated ¶
Types ¶
type Config ¶
type Config struct {
Enabled bool `json:"enabled,omitempty" yaml:"enabled,omitempty"`
LogLevel string `json:"logLevel,omitempty" yaml:"logLevel,omitempty"`
ServerList []LdapServerConfig `json:"serverList,omitempty" yaml:"serverList,omitempty"`
CacheTimeout uint32 `json:"cacheTimeout,omitempty" yaml:"cacheTimeout,omitempty"`
CacheCookieName string `json:"cacheCookieName,omitempty" yaml:"cacheCookieName,omitempty"`
CacheCookiePath string `json:"cacheCookiePath,omitempty" yaml:"cacheCookiePath,omitempty"`
CacheCookieSecure bool `json:"cacheCookieSecure,omitempty" yaml:"cacheCookieSecure,omitempty"`
CacheKey string `json:"cacheKey,omitempty" yaml:"cacheKey,omitempty"`
Attribute string `json:"attribute,omitempty" yaml:"attribute,omitempty"`
SearchFilter string `json:"searchFilter,omitempty" yaml:"searchFilter,omitempty"`
BaseDN string `json:"baseDn,omitempty" yaml:"baseDn,omitempty"`
BindDN string `json:"bindDn,omitempty" yaml:"bindDn,omitempty"`
BindPassword string `json:"bindPassword,omitempty" yaml:"bindPassword,omitempty"`
ForwardUsername bool `json:"forwardUsername,omitempty" yaml:"forwardUsername,omitempty"`
ForwardUsernameHeader string `json:"forwardUsernameHeader,omitempty" yaml:"forwardUsernameHeader,omitempty"`
ForwardAuthorization bool `json:"forwardAuthorization,omitempty" yaml:"forwardAuthorization,omitempty"`
ForwardExtraLdapHeaders bool `json:"forwardExtraLdapHeaders,omitempty" yaml:"forwardExtraLdapHeaders,omitempty"`
WWWAuthenticateHeader bool `json:"wwwAuthenticateHeader,omitempty" yaml:"wwwAuthenticateHeader,omitempty"`
WWWAuthenticateHeaderRealm string `json:"wwwAuthenticateHeaderRealm,omitempty" yaml:"wwwAuthenticateHeaderRealm,omitempty"`
EnableNestedGroupFilter bool `json:"enableNestedGroupsFilter,omitempty" yaml:"enableNestedGroupsFilter,omitempty"`
AllowedGroups []string `json:"allowedGroups,omitempty" yaml:"allowedGroups,omitempty"`
AllowedUsers []string `json:"allowedUsers,omitempty" yaml:"allowedUsers,omitempty"`
Username string
}
Config the plugin configuration.
func CreateConfig ¶
func CreateConfig() *Config
CreateConfig creates the default plugin configuration.
type LdapAuth ¶
type LdapAuth struct {
// contains filtered or unexported fields
}
LdapAuth Struct plugin.
type LdapServerConfig ¶
type LdapServerConfig struct {
URL string `json:"url,omitempty" yaml:"url,omitempty"`
Port uint16 `json:"port,omitempty" yaml:"port,omitempty"`
Weight uint16 `json:"weight,omitempty" yaml:"weight,omitempty"`
StartTLS bool `json:"startTls,omitempty" yaml:"startTls,omitempty"`
InsecureSkipVerify bool `json:"insecureSkipVerify,omitempty" yaml:"insecureSkipVerify,omitempty"`
MinVersionTLS string `json:"minVersionTls,omitempty" yaml:"minVersionTls,omitempty"`
MaxVersionTLS string `json:"maxVersionTls,omitempty" yaml:"maxVersionTls,omitempty"`
CertificateAuthority string `json:"certificateAuthority,omitempty" yaml:"certificateAuthority,omitempty"`
}
Click to show internal directories.
Click to hide internal directories.