ldap

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	URL                  string `bson:"url" json:"url"`
	SkipVerify           bool   `bson:"skip_verify" json:"skip_verify"`
	BaseDN               string `bson:"base_dn" json:"base_dn"`
	AdditionalUsersDN    string `bson:"additional_users_dn" json:"additional_users_dn"`
	UsersFilter          string `bson:"users_filter" json:"users_filter"`
	AdditionalGroupsDN   string `bson:"additional_groups_dn" json:"additional_groups_dn"`
	GroupsFilter         string `bson:"groups_filter" json:"groups_filter"`
	GroupNameAttribute   string `bson:"group_name_attribute" json:"group_name_attribute"`
	UsernameAttribute    string `bson:"username_attribute" json:"username_attribute"`
	MailAttribute        string `bson:"mail_attribute" json:"mail_attribute"`
	DisplayNameAttribute string `bson:"display_name_attribute" json:"display_name_attribute"`
	User                 string `bson:"user" json:"user"`
	Password             string `bson:"password" json:"password"`
}

Config represents the configuration related to LDAP server.

func NewDefaultConfig

func NewDefaultConfig() *Config

NewDefaultConfig represents the default LDAP config.

func (*Config) Desensitize

func (c *Config) Desensitize()

Desensitize todo

func (*Config) GetBaseDNFromUser

func (c *Config) GetBaseDNFromUser() string

GetBaseDNFromUser 从用户中获取BaseDN

func (*Config) Validate

func (c *Config) Validate() error

Validate todo

type Connection

type Connection interface {
	Bind(username, password string) error
	Close()

	Search(searchRequest *ldap.SearchRequest) (*ldap.SearchResult, error)
	Modify(modifyRequest *ldap.ModifyRequest) error
}

Connection interface representing a connection to the ldap.

type ConnectionImpl

type ConnectionImpl struct {
	// contains filtered or unexported fields
}

ConnectionImpl the production implementation of an ldap connection.

func NewLDAPConnectionImpl

func NewLDAPConnectionImpl(conn *ldap.Conn) *ConnectionImpl

NewLDAPConnectionImpl create a new ldap connection.

func (*ConnectionImpl) Bind

func (lc *ConnectionImpl) Bind(username, password string) error

Bind binds ldap connection to a username/password.

func (*ConnectionImpl) Close

func (lc *ConnectionImpl) Close()

Close closes a ldap connection.

func (*ConnectionImpl) Modify

func (lc *ConnectionImpl) Modify(modifyRequest *ldap.ModifyRequest) error

Modify modifies an ldap object.

func (*ConnectionImpl) Search

func (lc *ConnectionImpl) Search(searchRequest *ldap.SearchRequest) (*ldap.SearchResult, error)

Search searches a ldap server.

type Provider

type Provider struct {
	// contains filtered or unexported fields
}

Provider todo

func NewProvider

func NewProvider(conf *Config) *Provider

NewProvider todo

func (*Provider) CheckConnect

func (p *Provider) CheckConnect() error

CheckConnect todo

func (*Provider) CheckUserPassword

func (p *Provider) CheckUserPassword(inputUsername string, password string) (bool, error)

CheckUserPassword checks if provided password matches for the given user.

func (*Provider) GetDetails

func (p *Provider) GetDetails(inputUsername string) (*UserProfile, error)

GetDetails retrieve the groups a user belongs to.

func (*Provider) UpdatePassword

func (p *Provider) UpdatePassword(inputUsername string, newPassword string) error

UpdatePassword update the password of the given user.

type UserProfile

type UserProfile struct {
	DN          string
	Emails      []string
	Username    string
	DisplayName string
	Groups      []string
}

UserProfile todo

type UserProvider

type UserProvider interface {
	CheckConnect() error
	CheckUserPassword(username string, password string) (bool, error)
	GetDetails(username string) (*UserProfile, error)
	UpdatePassword(username string, newPassword string) error
}

UserProvider LDAP provider

Jump to

Keyboard shortcuts

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