ldap

package
v0.0.0-...-6a8978f Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2022 License: MIT Imports: 15 Imported by: 0

README

LDAP 认证

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

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 *domain.LdapConfig) *Provider

NewProvider todo

func (*Provider) CheckConnect

func (p *Provider) CheckConnect() error

CheckConnect todo

func (*Provider) CheckUserPassword

func (p *Provider) CheckUserPassword(inputUsername string, password string) (*UserProfile, 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 {
	// 测试LDAP Server是否可用
	// LDAP server地址
	// LDAP 管理账号 (Login DN/Password)
	CheckConnect() error
	// 用户密码校验
	CheckUserPassword(username string, password string) (bool, error)
	// ldap用户搜索
	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