handler

package
v2.3.2 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2024 License: MIT Imports: 31 Imported by: 4

Documentation

Index

Constants

View Source
const (
	Down ldapBackendStatus = iota
	Up
)

Variables

This section is empty.

Functions

func MaybeDecode

func MaybeDecode(value string) string

Types

type Handler

type Handler interface {
	// read support
	ldap.Binder
	ldap.Searcher
	ldap.Closer

	// write support
	ldap.Adder
	ldap.Modifier // Note: modifying eg the uid or cn might change the dn because the hierarchy is determined by the backend
	ldap.Deleter

	// helper
	HelperMaker
}

Handler is the common interface for all datastores

func NewConfigHandler

func NewConfigHandler(opts ...Option) Handler

NewConfigHandler creates a new config backed handler

func NewLdapHandler

func NewLdapHandler(opts ...Option) Handler

func NewOwnCloudHandler

func NewOwnCloudHandler(opts ...Option) Handler

type HandlerWrapper

type HandlerWrapper struct {
	Handlers []Handler
	Count    *int
}

TODO When I grow up, I want to handle pointers same as I would in C and not need a counter because I would not allocate statically but use idiomatic slicing instead

type HelperMaker

type HelperMaker interface {
	FindUser(ctx context.Context, userName string, searchByUPN bool) (bool, config.User, error)
	FindGroup(ctx context.Context, groupName string) (bool, config.Group, error)
}

type LDAPOpsHandler

type LDAPOpsHandler interface {
	GetBackend() config.Backend
	GetLog() *zerolog.Logger
	GetCfg() *config.Config
	GetYubikeyAuth() *yubigo.YubiAuth

	FindUser(ctx context.Context, userName string, searchByUPN bool) (f bool, u config.User, err error)
	FindGroup(ctx context.Context, groupName string) (f bool, g config.Group, err error)
	FindPosixAccounts(ctx context.Context, hierarchy string) (entrylist []*ldap.Entry, err error)
	FindPosixGroups(ctx context.Context, hierarchy string) (entrylist []*ldap.Entry, err error)
}

type LDAPOpsHelper

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

func NewLDAPOpsHelper

func NewLDAPOpsHelper(tracer trace.Tracer) LDAPOpsHelper

func (LDAPOpsHelper) Bind

func (l LDAPOpsHelper) Bind(ctx context.Context, h LDAPOpsHandler, bindDN, bindSimplePw string, conn net.Conn) (resultCode ldap.LDAPResultCode, err error)

func (LDAPOpsHelper) Search

func (l LDAPOpsHelper) Search(ctx context.Context, h LDAPOpsHandler, bindDN string, searchReq ldap.SearchRequest, conn net.Conn) (result ldap.ServerSearchResult, err error)

* TODO #1: * Is it possible to map, on-the-fly, ou= -> cn= to maintain backware compatibility? Could be a switch... * Or maybe sinmply configure in the .cfg file using the nameformat and groupformat settings? * In 3.0 we could change default from cn to ou * TODO #2: DONE * Returns values when scope==base or scope==sub on a group entry * TODO #3: DONE * Make sure that when scope==sub, we do not always return, but augment results instead * TODO #4: DONE * Handle groups as two distinct objectclasses like OLDAP does * Q: Does OLDAP return the groups twice when querying root+sub? * TODO #5: * Document roll out of schemas

type OCSGroupsResponse

type OCSGroupsResponse struct {
	Ocs struct {
		Meta struct {
			Message    interface{} `json:"message"`
			Statuscode int         `json:"statuscode"`
			Status     string      `json:"status"`
		} `json:"meta"`
		Data struct {
			Groups []string `json:"groups"`
		} `json:"data"`
	} `json:"ocs"`
}

type OCSUsersResponse

type OCSUsersResponse struct {
	Ocs struct {
		Data struct {
			Users []string `json:"users"`
		} `json:"data"`
		Meta struct {
			Statuscode int         `json:"statuscode"`
			Message    interface{} `json:"message"`
			Status     string      `json:"status"`
		} `json:"meta"`
	} `json:"ocs"`
}

type Option

type Option func(o *Options)

Option defines a single option function.

func Backend

func Backend(val config.Backend) Option

Backend is our current backend

func Config

func Config(val *config.Config) Option

Config provides a function to set the config option.

func Context

func Context(val *context.Context) Option

Context provides a function to set the context option.

func Handlers

func Handlers(val HandlerWrapper) Option

Handlers Our friendly handlers for all backends

func Helper

func Helper(val Handler) Option

Helper If we specified a helper, for instance for OTP injection

func LDAPHelper

func LDAPHelper(val LDAPOpsHelper) Option

LDAPHelper Global LDAP Handler

func Logger

func Logger(val *zerolog.Logger) Option

Logger provides a function to set the logger option.

func Monitor added in v2.3.1

func Monitor(val monitoring.MonitorInterface) Option

Monitor provides a function to set the monitor option.

func Tracer added in v2.3.1

func Tracer(val trace.Tracer) Option

Tracer provides a function to set the tracer option.

func YubiAuth

func YubiAuth(val *yubigo.YubiAuth) Option

YubiAuth provides a function to set the yubiauth option.

type Options

type Options struct {
	Backend    config.Backend
	Handlers   HandlerWrapper
	Logger     *zerolog.Logger
	Config     *config.Config
	Context    *context.Context
	YubiAuth   *yubigo.YubiAuth
	Helper     Handler
	LDAPHelper LDAPOpsHelper
	Monitor    monitoring.MonitorInterface
	Tracer     trace.Tracer
}

Options defines the available options for this package.

func NewOptions

func NewOptions(opts ...Option) Options

NewOptions initializes the available default options.

Jump to

Keyboard shortcuts

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