handler

package
v2.1.0-etecs.3 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2021 License: MIT Imports: 29 Imported by: 0

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(userName string, searchByUPN bool) (bool, config.User, error)
	FindGroup(groupName string) (bool, config.Group, error)
}

type LDAPOpsHandler

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

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

type LDAPOpsHelper

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

func NewLDAPOpsHelper

func NewLDAPOpsHelper() LDAPOpsHelper

func (LDAPOpsHelper) Bind

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

func (LDAPOpsHelper) Search

func (l LDAPOpsHelper) Search(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

Our friendly handlers for all backends

func Helper

func Helper(val Handler) Option

If we specified a helper, for instance for OTP injection

func LDAPHelper

func LDAPHelper(val LDAPOpsHelper) Option

Global LDAP Handler

func Logger

func Logger(val *zap.Logger) Option

Logger provides a function to set the logger 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     *zap.Logger
	Config     *config.Config
	Context    *context.Context
	YubiAuth   *yubigo.YubiAuth
	Helper     Handler
	LDAPHelper LDAPOpsHelper
}

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