ldap

package
v0.0.0-...-484a9e1 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Connection *ldap.Conn

Connection is used to access the LDAP directory tree for read & write access.

View Source
var SimpleConnection *ldap.Conn

SimpleConnection is used to authenticate users using a SimpleBind.

Functions

func EscapeDN

func EscapeDN(dn string) string

func EscapeSearch

func EscapeSearch(dn string) string

func FieldsToJSON

func FieldsToJSON(fields []Field) map[string]interface{}

func FieldsToLDAP

func FieldsToLDAP(fields []Field) map[string][]string

func UnescapeDN

func UnescapeDN(dn string) string

func ValidateDN

func ValidateDN(dn string) error

Types

type Config

type Config struct {
	ConnectionURI string
	TrustInsecure bool
	BindUsername  string
	BindPassword  string
}

func (Config) SetupPlugin

func (config Config) SetupPlugin() error

type Field

type Field interface {
	Setup() error
	New() Field              // Create a new field from this type. Throws an error on configuration problems.
	Name() string            // Get the user-specified unique name of this field, for the frontend API and errors/logging.
	Schema() api.FieldSchema // Get the frontend format instructions in JSON format - field.FromJSON(field.ToJSON().Value) should not change the value.
	GetViews() api.FieldViews

	FromLDAP(map[string][]string) error // Override the field's value from a source with LDAP format - when using field.FromLDAP(field.ToLDAP()), the result should be the same as before. Should throw an error only if the LDAP is in an invalid state.
	ToLDAP() map[string][]string        // Get the LDAP fields representing this field's value - when using field.FromLDAP(field.ToLDAP()), the result should be the same as before.
	FromJSON(interface{}) error         // Override the field's value from a JSON value - field.FromJSON(field.ToJSON().Value) should not change the value. Should throw an error if the value is invalid.
	ToJSON() interface{}                // Get the frontend-formatted value
}

Field represents an instance of a field, like "Max's main email address". It must be created by calling LDAPType.New().

type FilterField

type FilterField interface {
	Field
	Identify(string) string
}

type Resource

type Resource struct {
	Type   *ResourceType // The class this object is an instance of.
	Fields []Field       // The list of fields this object can have.
}

Resource is an instance of ResourceType, e.g. "the user Max". It must be created by calling ResourceType.New().

func (*Resource) Create

func (res *Resource) Create(id string) error

func (*Resource) Delete

func (res *Resource) Delete(id string, ctx api.Viewpoint) error

Delete the resource

func (*Resource) Field

func (res *Resource) Field(name string) Field

Field returns a field by its name

func (*Resource) FromBody

func (res *Resource) FromBody(body map[string]interface{}, viewpoint api.Viewpoint) map[string]error

Validate & apply the request body of a POST or PUT request & populate the ID

func (*Resource) ID

func (res *Resource) ID() string

func (*Resource) Read

func (res *Resource) Read(id string) error

func (*Resource) ToBody

func (res *Resource) ToBody(viewpoint api.Viewpoint) (map[string]interface{}, error)

Retrieve a response body for a GET request (calls read() and then converts it to a JSON-compatible format)

func (*Resource) Update

func (res *Resource) Update(id string) error

type ResourceType

type ResourceType struct {
	SearchBase      string
	SearchFilter    string
	DNTemplate      string   // A text/template for the object DNs (with the LDAP object's representation as the root context).
	ObjectClasses   []string // The LDAP object classes for objects of this type.
	Views           api.ResourceViews
	NameField       string
	EmailField      string
	MemberOfField   string
	IdentifierField string
	PasswordField   string
	Fields          []Field // The field types objects of this class can have.
}

ResourceType represents a resource type containing LDAP objects (e.g. users).

func (*ResourceType) Authenticate

func (resType *ResourceType) Authenticate(username string, password string) (api.User, error)

func (*ResourceType) FormatDN

func (resType *ResourceType) FormatDN(id string) string

func (*ResourceType) List

func (resType *ResourceType) List(query api.Query) ([]string, error)

func (*ResourceType) ListCheck

func (resType *ResourceType) ListCheck(viewpoint api.Viewpoint) error

func (*ResourceType) MatchDN

func (resType *ResourceType) MatchDN(dn string) bool

func (*ResourceType) New

func (resType *ResourceType) New() api.Resource

New creates an instance of this class.

func (*ResourceType) Schema

func (resType *ResourceType) Schema() []api.FieldSchema

func (*ResourceType) SetPassword

func (resType *ResourceType) SetPassword(username string, newPassword string) error

func (*ResourceType) Setup

func (resType *ResourceType) Setup() error

func (*ResourceType) Signup

func (resType *ResourceType) Signup(signup api.Signup, validateOnly bool) map[string]error

func (*ResourceType) UnwrapDN

func (resType *ResourceType) UnwrapDN(dn string) string

type UpdatableField

type UpdatableField interface {
	Field
	ApplyTemplates(context map[string]interface{}) error // Should be used to apply templates based on other fields after everything's done. Note that referencing other UpdatableFields might lead to issues.
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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