Help us shape the future of Go! Take the 2026 Go Developer Survey

ldap

package
v1.17.2 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MockedSearchEntry func(source *Source, name, passwd string, directBind bool) *SearchResult
View Source
var SecurityProtocolNames = map[SecurityProtocol]string{
	SecurityProtocolUnencrypted: "Unencrypted",
	SecurityProtocolLDAPS:       "LDAPS",
	SecurityProtocolStartTLS:    "StartTLS",
}

SecurityProtocolNames contains the name of SecurityProtocol values.

Functions

This section is empty.

Types

type SearchResult

type SearchResult struct {
	Username     string   // Username
	Name         string   // Name
	Surname      string   // Surname
	Mail         string   // E-mail address
	SSHPublicKey []string // SSH Public Key
	IsAdmin      bool     // if user is administrator
	IsRestricted bool     // if user is restricted
	LowerName    string   // LowerName
	Avatar       []byte
	Groups       container.Set[string]
}

SearchResult : user data

type SecurityProtocol

type SecurityProtocol int

SecurityProtocol protocol type

const (
	SecurityProtocolUnencrypted SecurityProtocol = iota
	SecurityProtocolLDAPS
	SecurityProtocolStartTLS
)

Note: new type must be added at the end of list to maintain compatibility.

func (SecurityProtocol) Int

func (s SecurityProtocol) Int() int

Int returns the int value of the SecurityProtocol

func (SecurityProtocol) String

func (s SecurityProtocol) String() string

String returns the name of the SecurityProtocol

type Source

type Source struct {
	auth.ConfigBase `json:"-"`

	Name                  string // canonical name (ie. corporate.ad)
	Host                  string // LDAP host
	Port                  int    // port number
	SecurityProtocol      SecurityProtocol
	SkipVerify            bool
	BindDN                string // DN to bind with
	BindPasswordEncrypt   string // Encrypted Bind BN password
	BindPassword          string // Bind DN password
	UserBase              string // Base search path for users
	UserDN                string // Template for the DN of the user for simple auth
	AttributeUsername     string // Username attribute
	AttributeName         string // First name attribute
	AttributeSurname      string // Surname attribute
	AttributeMail         string // E-mail attribute
	AttributesInBind      bool   // fetch attributes in bind context (not user)
	AttributeSSHPublicKey string // LDAP SSH Public Key attribute
	AttributeAvatar       string
	SSHKeysAreVerified    bool   // true if SSH keys in LDAP are verified
	SearchPageSize        uint32 // Search with paging page size
	Filter                string // Query filter to validate entry
	AdminFilter           string // Query filter to check if user is admin
	RestrictedFilter      string // Query filter to check if user is restricted
	Enabled               bool   // if this source is disabled
	AllowDeactivateAll    bool   // Allow an empty search response to deactivate all users from this source
	GroupsEnabled         bool   // if the group checking is enabled
	GroupDN               string // Group Search Base
	GroupFilter           string // Group Name Filter
	GroupMemberUID        string // Group Attribute containing array of UserUID
	GroupTeamMap          string // Map LDAP groups to teams
	GroupTeamMapRemoval   bool   // Remove user from teams which are synchronized and user is not a member of the corresponding LDAP group
	UserUID               string // User Attribute listed in Group
}

Source Basic LDAP authentication service

func (*Source) Authenticate

func (source *Source) Authenticate(ctx context.Context, user *user_model.User, userName, password string) (*user_model.User, error)

Authenticate queries if login/password is valid against the LDAP directory pool, and create a local user if success when enabled.

func (*Source) FromDB

func (source *Source) FromDB(bs []byte) error

FromDB fills up a LDAPConfig from serialized format.

func (*Source) HasTLS

func (source *Source) HasTLS() bool

HasTLS returns if HasTLS

func (*Source) IsSkipVerify

func (source *Source) IsSkipVerify() bool

IsSkipVerify returns if SkipVerify is set

func (*Source) ProvidesSSHKeys

func (source *Source) ProvidesSSHKeys() bool

ProvidesSSHKeys returns if this source provides SSH Keys

func (*Source) SearchEntries

func (source *Source) SearchEntries() ([]*SearchResult, error)

SearchEntries : search an LDAP source for all users matching userFilter

func (*Source) SearchEntry

func (source *Source) SearchEntry(name, passwd string, directBind bool) *SearchResult

SearchEntry : search an LDAP source if an entry (name, passwd) is valid and in the specific filter

func (*Source) SecurityProtocolName

func (source *Source) SecurityProtocolName() string

SecurityProtocolName returns the name of configured security protocol.

func (*Source) Sync

func (source *Source) Sync(ctx context.Context, updateExisting bool) error

Sync causes this ldap source to synchronize its users with the db

func (*Source) ToDB

func (source *Source) ToDB() ([]byte, error)

ToDB exports a LDAPConfig to a serialized format.

func (*Source) UsePagedSearch

func (source *Source) UsePagedSearch() bool

UsePagedSearch returns if need to use paged search

func (*Source) UseTLS

func (source *Source) UseTLS() bool

UseTLS returns if UseTLS

Jump to

Keyboard shortcuts

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