ldap

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ProviderName is the auth method reported by the LDAP credential provider.
	ProviderName = "ldap"

	DefaultUserFilter           = "(uid={username})"
	DefaultGroupFilter          = "(member={dn})"
	DefaultUsernameAttribute    = "uid"
	DefaultEmailAttribute       = "mail"
	DefaultDisplayNameAttribute = "displayName"
	DefaultGroupAttribute       = "cn"
	DefaultTimeout              = 10 * time.Second
)

Variables

View Source
var (
	ErrInvalidConfig      = errors.New("invalid ldap config")
	ErrInvalidCredentials = errors.New("invalid ldap credentials")
	ErrAmbiguousUser      = errors.New("ldap user search returned multiple entries")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	Enabled bool

	URL       string
	StartTLS  bool
	TLSConfig *tls.Config
	Timeout   time.Duration

	BindDN       string
	BindPassword string

	UserBaseDN string
	UserFilter string

	GroupBaseDN    string
	GroupFilter    string
	GroupAttribute string

	UsernameAttribute    string
	EmailAttribute       string
	DisplayNameAttribute string

	Dial DialFunc
}

Config configures the LDAP credential provider.

func ConfigFromEnv

func ConfigFromEnv(vars env.Environment) Config

ConfigFromEnv converts Caesium environment config into provider config.

type Conn

type Conn interface {
	Bind(username, password string) error
	Search(searchRequest *gldap.SearchRequest) (*gldap.SearchResult, error)
	StartTLS(config *tls.Config) error
	SetTimeout(timeout time.Duration)
	Close() error
}

Conn is the subset of go-ldap's connection used by the provider.

type DialFunc

type DialFunc func(ctx context.Context, cfg Config) (Conn, error)

DialFunc opens an LDAP connection. Tests can provide one to avoid a live LDAP server while still exercising bind/search flow.

type Provider

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

Provider implements Caesium credential authentication for LDAP directories.

func New

func New(cfg Config) (*Provider, error)

New constructs an LDAP credential provider. It does not connect to LDAP until Authenticate is called.

func (*Provider) Authenticate

func (p *Provider) Authenticate(ctx context.Context, username, password string) (*authpkg.ExternalIdentity, error)

Authenticate verifies user credentials with search-then-bind and returns a normalized external identity for the shared SSO completion path.

func (*Provider) Name

func (p *Provider) Name() string

Name reports the provider id used by the shared SSO completion path.

Jump to

Keyboard shortcuts

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