repo

package
v0.0.0-...-c932893 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2022 License: GPL-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AttrsOrig

type AttrsOrig map[string][]string

type CacheAttrsNorm

type CacheAttrsNorm map[string][]interface{}

func (CacheAttrsNorm) ValueInt64

func (c CacheAttrsNorm) ValueInt64(name string) []int64

func (CacheAttrsNorm) ValueStr

func (c CacheAttrsNorm) ValueStr(name string) []string

type CacheAttrsOrig

type CacheAttrsOrig map[string][]string

type CacheEntry

type CacheEntry struct {
	ID          int64   `reindex:"id,,pk" json:"id"`
	Version     int64   `reindex:"rev" json:"rev"`
	ParentID    int64   `reindex:"parentId" json:"parentId"`
	Path        []int64 `reindex:"path,tree" json:"path"`
	IsContainer bool    `reindex:"isContainer" json:"isContainer"`
	RDNNorm     string  `reindex:"rdnNorm" json:"rdnNorm"`
	RDNOrig     string  `reindex:"-" json:"rdnOrig"`
	AttrsNorm   struct {
	} `reindex:"attrsNorm" json:"attrsNorm"`
	AttrsOrig CacheAttrsOrig `reindex:"-" json:"attrsOrig"`
	Dummy     string         `reindex:"dummy" json:"-"`
}

type Changelog

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

func NewChangelog

func NewChangelog(ctx context.Context, s *schema.SchemaRegistry, dn *schema.DN, attrsOrig AttrsOrig) (*Changelog, error)

func (*Changelog) Add

func (c *Changelog) Add(sv *schema.SchemaValue) error

func (*Changelog) AddWithouCheck

func (c *Changelog) AddWithouCheck(sv *schema.SchemaValue) error

func (*Changelog) DN

func (c *Changelog) DN() *schema.DN

func (*Changelog) DNNorm

func (c *Changelog) DNNorm() string

func (*Changelog) Delete

func (c *Changelog) Delete(sv *schema.SchemaValue) error

Delete from current value(s) if the value matchs.

func (*Changelog) HasAttr

func (c *Changelog) HasAttr(attrName string) bool

func (*Changelog) NewDN

func (c *Changelog) NewDN() *schema.DN

func (*Changelog) NewEntry

func (c *Changelog) NewEntry() map[string]*schema.SchemaValue

func (*Changelog) ObjectClassesNorm

func (c *Changelog) ObjectClassesNorm() ([]string, bool)

func (*Changelog) Replace

func (c *Changelog) Replace(sv *schema.SchemaValue) error

Replace with the value(s).

func (*Changelog) Requester

func (c *Changelog) Requester() *schema.DN

func (*Changelog) Timestamp

func (c *Changelog) Timestamp() string

func (*Changelog) ToAttrsOrig

func (c *Changelog) ToAttrsOrig() AttrsOrig

func (*Changelog) ToDiff

func (c *Changelog) ToDiff() map[string]*ModOperation

func (*Changelog) ToMemberOfDiff

func (c *Changelog) ToMemberOfDiff() (add []string, del []string)

func (*Changelog) ToNewAttrsOrig

func (c *Changelog) ToNewAttrsOrig() AttrsOrig

func (*Changelog) UpdateDN

func (c *Changelog) UpdateDN(newDN *schema.DN)

func (*Changelog) Validate

func (c *Changelog) Validate() error

type DBAttrsNorm

type DBAttrsNorm = map[string][]string

type DBEntry

type DBEntry struct {
	ID           int64               `db:"id"`
	Version      int64               `db:"rev"`
	ParentID     int64               `db:"parent_id"`
	Path         pq.Int64Array       `db:"path"`
	IsContainer  bool                `db:"is_container"`
	RDNNorm      string              `db:"rdn_norm"`
	RDNOrig      string              `db:"rdn_orig"`
	AttrsOrig    types.JSONText      `db:"attrs_orig"`
	AttrsOrigMap map[string][]string `db:"-"` // for cache

}

type DBRepository

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

type DBRepositoryConfig

type DBRepositoryConfig struct {
	DBHostName     string
	DBPort         int
	DBUser         string
	DBPassword     string
	DBSchema       string
	DBName         string
	DBMaxOpenConns int
	DBMaxIdleConns int
	ServerID       string
	LogLevel       string
}

type DefaultRepository

type DefaultRepository struct {
	*DBRepository
}

func (*DefaultRepository) Association

Association resolves the association related attributes in the attributes. This is used for MOD operation.

func (*DefaultRepository) Bind

func (r *DefaultRepository) Bind(ctx context.Context, dn *schema.DN, callback func(current *FetchedCredential) error) error

Bind fetches the current bind entry by specified DN. Then execute callback with the entry. The callback is expected checking the credential, account lock status and so on. This is used for BIND operation.

func (*DefaultRepository) CacheAll

func (r *DefaultRepository) CacheAll(ctx context.Context) error

func (*DefaultRepository) CacheAssociation

func (r *DefaultRepository) CacheAssociation(ctx context.Context, cacheTx *reindexer.Tx, dbTx *sqlx.Tx, memberOf []int64) error

func (*DefaultRepository) CacheEntry

func (r *DefaultRepository) CacheEntry(ctx context.Context, tx *reindexer.Tx, entry *DBEntry, ignoreParent bool) error

func (*DefaultRepository) CacheEntryByID

func (r *DefaultRepository) CacheEntryByID(ctx context.Context, cacheTx *reindexer.Tx, dbTx *sqlx.Tx, id int64, assoc bool) error

func (*DefaultRepository) CacheEntryBySubTree

func (r *DefaultRepository) CacheEntryBySubTree(ctx context.Context, cacheTx *reindexer.Tx, dbTx *sqlx.Tx, id int64) error

func (*DefaultRepository) DeleteByDN

func (r *DefaultRepository) DeleteByDN(ctx context.Context, dn *schema.DN) error

DeleteByDN deletes the entry by specified DN.

func (*DefaultRepository) DeleteCacheEntry

func (r *DefaultRepository) DeleteCacheEntry(ctx context.Context, cacheTx *reindexer.Tx, dbTx *sqlx.Tx, id, parentId int64, acc bool) (int, error)

func (*DefaultRepository) FindPPolicyByDN

func (r *DefaultRepository) FindPPolicyByDN(ctx context.Context, dn *schema.DN) (*schema.PPolicy, error)

FindPPolicyByDN returns the password policy entry by specified DN. This is used for password policy process.

func (*DefaultRepository) Init

func (r *DefaultRepository) Init() error

func (*DefaultRepository) Insert

func (r *DefaultRepository) Insert(ctx context.Context, changelog *Changelog) (int64, error)

Insert creates the entry by specified entry data.

func (*DefaultRepository) OnUpdate

func (r *DefaultRepository) OnUpdate(ctx context.Context, m *NotifyMessage) error

func (*DefaultRepository) RefreshCache

func (r *DefaultRepository) RefreshCache(ctx context.Context) error

func (*DefaultRepository) Search

func (r *DefaultRepository) Search(ctx context.Context, baseDN *schema.DN, option *SearchOption, handler func(entry *SearchEntry) error) (int32, int32, error)

Search handles search request by filter. This is used for SEARCH operation.

func (*DefaultRepository) Update

func (r *DefaultRepository) Update(ctx context.Context, dn *schema.DN, callback func(attrsOrig AttrsOrig) (*Changelog, error)) error

Update modifies the entry by specified change data. This is used for MOD operation.

func (*DefaultRepository) UpdateDN

func (r *DefaultRepository) UpdateDN(ctx context.Context, oldDN, newDN *schema.DN, oldRDN *schema.RelativeDN,
	callback func(attrsOrig AttrsOrig) (*Changelog, error)) error

UpdateRDN modifies the entry RDN by specified change data. This is used for MODRDN operation.

type FetchedCredential

type FetchedCredential struct {
	ID int64
	// Credential
	Credential []string
	// DN of the MemberOf
	MemberOf []*schema.DN
	// PPolicy related to this entry
	PPolicy              *schema.PPolicy
	PwdAccountLockedTime *time.Time
	LastPwdFailureTime   *time.Time
	PwdFailureCount      int
}

type FetchedDNOrig

type FetchedDNOrig struct {
	ID     int64  `db:"id"`
	DNOrig string `db:"dn_orig"`
}

type FilterContext

type FilterContext struct {
	context.Context
	// contains filtered or unexported fields
}

type FilterTranslator

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

func (*FilterTranslator) AnyMatch

func (t *FilterTranslator) AnyMatch(s *schema.AttributeType, q *reindexer.Query, val string, i int)

func (*FilterTranslator) ApproxMatch

func (t *FilterTranslator) ApproxMatch(ctx context.Context, s *schema.AttributeType, q *reindexer.Query, val string)

func (*FilterTranslator) EndsMatch

func (t *FilterTranslator) EndsMatch(s *schema.AttributeType, q *reindexer.Query, val string, i int)

func (*FilterTranslator) EqualityMatch

func (t *FilterTranslator) EqualityMatch(ctx context.Context, s *schema.AttributeType, q *reindexer.Query, val string)

func (*FilterTranslator) GreaterOrEqualMatch

func (t *FilterTranslator) GreaterOrEqualMatch(ctx context.Context, s *schema.AttributeType, q *reindexer.Query, val string)

func (*FilterTranslator) LessOrEqualMatch

func (t *FilterTranslator) LessOrEqualMatch(ctx context.Context, s *schema.AttributeType, q *reindexer.Query, val string)

func (*FilterTranslator) Name

func (*FilterTranslator) PresentMatch

func (t *FilterTranslator) PresentMatch(ctx context.Context, s *schema.AttributeType, q *reindexer.Query)

func (*FilterTranslator) StartsWithMatch

func (t *FilterTranslator) StartsWithMatch(s *schema.AttributeType, q *reindexer.Query, val string, i int)

type ModOperation

type ModOperation struct {
	Add     []string
	Replace []string
	Delete  []string
}

func (*ModOperation) IsAdd

func (m *ModOperation) IsAdd() bool

func (*ModOperation) IsClear

func (m *ModOperation) IsClear() bool

func (*ModOperation) IsDelete

func (m *ModOperation) IsDelete() bool

func (*ModOperation) IsReplace

func (m *ModOperation) IsReplace() bool

type NotifyMessage

type NotifyMessage struct {
	Issuer      string   `json:"iss"`
	ID          int64    `json:"id"`
	Op          NotifyOp `json:"op"`
	Rev         int64    `json:"rev"`
	Association bool     `json:"asc"`
	Dependant   []int64  `json:"dep"`
	Sub         bool     `json:"sub"`
}

func (*NotifyMessage) IsAdd

func (n *NotifyMessage) IsAdd() bool

func (*NotifyMessage) IsDel

func (n *NotifyMessage) IsDel() bool

func (*NotifyMessage) IsMod

func (n *NotifyMessage) IsMod() bool

type NotifyOp

type NotifyOp string
const (
	NotifyAdd    NotifyOp = "add"
	NotifyMod    NotifyOp = "mod"
	NotifyModRDN NotifyOp = "modrdn"
	NotifyDel    NotifyOp = "del"
)

type RDNCache

type RDNCache struct {
	ID       int64  `json:"id"`
	ParentID int64  `json:"parentId"`
	RDNOrig  string `json:"rdnOrig"`
}

type Repository

type Repository interface {
	// Init is called when initializing repository implementation.
	Init() error

	// Bind fetches the current bind entry by specified DN. Then execute callback with the entry.
	// The callback is expected checking the credential, account lock status and so on.
	// This is used for BIND operation.
	Bind(ctx context.Context, dn *schema.DN, callback func(current *FetchedCredential) error) error

	// FindPPolicyByDN returns the password policy entry by specified DN.
	// This is used for password policy process.
	FindPPolicyByDN(ctx context.Context, dn *schema.DN) (*schema.PPolicy, error)

	// Search handles search request by filter.
	// This is used for SEARCH operation.
	Search(ctx context.Context, baseDN *schema.DN, option *SearchOption, handler func(entry *SearchEntry) error) (int32, int32, error)

	// Update modifies the entry by specified change data.
	// This is used for MOD operation.
	Update(ctx context.Context, dn *schema.DN, callback func(attrsOrig AttrsOrig) (*Changelog, error)) error

	// Association resolves the association related attributes in the attributes.
	// This is used for MOD operation.
	Association(ctx context.Context, sv *schema.SchemaValue) (*schema.SchemaValue, error)

	// UpdateRDN modifies the entry DN by specified change data.
	// This is used for MODRDN operation.
	UpdateDN(ctx context.Context, oldDN, newDN *schema.DN, oldRDN *schema.RelativeDN, callback func(attrsOrig AttrsOrig) (*Changelog, error)) error

	// Insert creates the entry by specified entry data.
	Insert(ctx context.Context, entry *Changelog) (int64, error)

	// DeleteByDN deletes the entry by specified DN.
	DeleteByDN(ctx context.Context, dn *schema.DN) error

	OnUpdate(ctx context.Context, m *NotifyMessage) error
}

func NewRepository

func NewRepository(config *DBRepositoryConfig, sr *schema.SchemaRegistry) (Repository, error)

type SearchEntry

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

func NewSearchEntry

func NewSearchEntry(s *schema.SchemaRegistry, dnOrig string, attrsOrig CacheAttrsOrig) *SearchEntry

func (*SearchEntry) AttrOrig

func (s *SearchEntry) AttrOrig(attrName string) (string, []string, bool)

func (*SearchEntry) AttrsOrig

func (s *SearchEntry) AttrsOrig() CacheAttrsOrig

func (*SearchEntry) AttrsOrigWithoutOperationalAttrs

func (s *SearchEntry) AttrsOrigWithoutOperationalAttrs() AttrsOrig

func (*SearchEntry) DNOrig

func (s *SearchEntry) DNOrig() string

func (*SearchEntry) OperationalAttrsOrig

func (s *SearchEntry) OperationalAttrsOrig() AttrsOrig

type SearchOption

type SearchOption struct {
	Scope                      int
	Filter                     message.Filter
	PageSize                   int32
	Offset                     int32
	RequestedAssocation        []string
	IsMemberOfRequested        bool
	IsHasSubordinatesRequested bool
}

type StmtCache

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

For generic filter

func (*StmtCache) Get

func (m *StmtCache) Get(key string) (*sqlx.NamedStmt, bool)

func (*StmtCache) Put

func (m *StmtCache) Put(key string, value *sqlx.NamedStmt)

Jump to

Keyboard shortcuts

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