ldap

package
v0.0.21 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2026 License: Apache-2.0 Imports: 13 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package ldap is a provider of an LDAP directory, which is signed in with a username and password, which is checked with a bind as the user, whose groups are the identity's.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseGroupScopes

func ParseGroupScopes(values ...string) (map[string][]string, error)

ParseGroupScopes returns the scopes of groups, from values of group=scope,scope, such as admins=ldap:read,ldap:write

Types

type Manager

type Manager interface {
	Get(ctx context.Context, dn string, attrs ...string) (*ldapschema.Object, error)
	GetUser(ctx context.Context, name string) (*ldapschema.Object, error)
	ListUsers(ctx context.Context, req ldapschema.UserListRequest) (*ldapschema.ObjectList, error)
	Bind(ctx context.Context, dn, password string) (*ldapschema.Object, error)
	ListGroups(ctx context.Context, req ldapschema.GroupListRequest) (*ldapschema.ObjectList, error)
	Status() ldapschema.Status
}

Manager is what the provider needs of an LDAP manager: a user, by name, a bind, which checks a password, the groups a user is in, and the directory's status, for the identity's issuer

type Opt

type Opt func(*Provider) error

Opt is an option of a provider

func WithName

func WithName(name, label string) Opt

WithName names the provider, which is in its paths, and labels it, to show, such as for a directory's name

type Provider

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

Provider is an LDAP directory, through its manager

func New

func New(manager Manager, opts ...Opt) (*Provider, error)

New returns the directory of the manager, named ldap, which needs users

func (*Provider) Exchange

func (p *Provider) Exchange(ctx context.Context, credential schema.Credential) (*schema.Identity, error)

Exchange checks the username's password, with a bind as the user, and returns its identity: by its DN, with its email address, name, and the groups it's in. A user who isn't found, and a password which isn't right, are the same error, so which isn't said.

func (*Provider) Meta

func (p *Provider) Meta() schema.ProviderMeta

Meta describes the provider

type Users

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

Users are the directory's users, as a user store, whose scopes are their groups'

func NewUsers

func NewUsers(manager Manager, scopes map[string][]string) (*Users, error)

NewUsers returns the users of the manager's directory, whose scopes are those of the groups they're in, which scopes has, by the groups' names, in any case

func (*Users) Scopes

func (u *Users) Scopes(_ context.Context, user *schema.User) ([]string, error)

Scopes returns the scopes of the groups the user is in, once each, in order

func (*Users) User

func (u *Users) User(ctx context.Context, identity *schema.Identity) (*schema.User, error)

User returns the user an identity is: one which signed in with the directory, by its DN, when its identifier is still the identity's subject, so it isn't another user with the DN, or one from another provider, by its verified email address, which is one user's mail. Others aren't found.

Jump to

Keyboard shortcuts

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