ldapclient

package
v1.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 30, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Config
	// contains filtered or unexported fields
}

Client is a LDAP client (compatible with Active Directory).

func New

func New(cnf Config) *Client

New creates a new LDAP client.

func (*Client) Authenticate

func (cli *Client) Authenticate(ctx context.Context, username, password string) (bool, error)

Authenticate authenticates a user with a username and password. If no username or password in LDAP it returns false and no error.

func (*Client) FindOIDCClaims

func (cli *Client) FindOIDCClaims(ctx context.Context, username string) (map[string]interface{}, error)

FindOIDCClaims finds all OIDC claims for a user.

type Config

type Config struct {
	Endpoints  []string          `envconfig:"endpoints" required:"true" desc:"a LDAP's server URLs as \"<address>:<port>\""`
	BindDN     string            `envconfig:"binddn" desc:"a LDAP bind DN"`
	BindPass   string            `envconfig:"bindpw" json:"-" desc:"a LDAP bind password"`
	BaseDN     string            `envconfig:"basedn" required:"true" desc:"a LDAP base DN for searching users"`
	AttrClaims map[string]string `` /* 151-byte string literal not displayed */
	RoleBaseDN string            `envconfig:"role_basedn" required:"true" desc:"a LDAP base DN for searching roles"`
	RoleAttr   string            `envconfig:"role_attr" default:"description" desc:"a LDAP group's attribute that contains a role's name"`
	RoleClaim  string            `` /* 145-byte string literal not displayed */
	CacheSize  int               `envconfig:"cache_size" default:"512" desc:"a user info cache's size in KiB"`
	CacheTTL   time.Duration     `envconfig:"cache_ttl" default:"30m" desc:"a user info cache TTL"`
	IsTLS      bool              `envconfig:"is_tls" default:"false" desc:"should LDAP connection be established via TLS"`
}

Config is a LDAP configuration.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL