Documentation
¶
Index ¶
- func GetCacheNames(requestedProtocol string, backends definitions.CacheNameBackend) (cacheNames config.StringSet)
- func GetUserAccountFromCache(ctx context.Context, username string, guid string) (accountName string)
- func InitHTTPClient()
- func LDAPAuthWorker(ctx context.Context, poolName string)
- func LDAPMainWorker(ctx context.Context, poolName string)
- func LoadCacheFromRedis(ctx context.Context, key string, ucp *bktype.PositivePasswordCache) (isRedisErr bool, err error)
- func LoaderModLDAP(ctx context.Context) lua.LGFunction
- func LookupUserAccountFromRedis(ctx context.Context, username string) (accountName string, err error)
- func LuaLDAPModify(ctx context.Context) lua.LGFunction
- func LuaLDAPSearch(ctx context.Context) lua.LGFunction
- func LuaMainWorker(ctx context.Context, backendName string) (err error)
- func ResolveAccountIdentifier(ctx context.Context, identifier string, guid string) (accountName string)
- func SaveUserDataToRedis(ctx context.Context, guid string, key string, ttl time.Duration, ...)
- func SaveWebAuthnToRedis(ctx context.Context, user *User, ttl time.Duration) error
- type Channel
- type LDAPChannel
- type LuaChannel
- type LuaChannelImpl
- type User
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetCacheNames ¶
func GetCacheNames(requestedProtocol string, backends definitions.CacheNameBackend) (cacheNames config.StringSet)
GetCacheNames retrieves cache names for the specified protocol from either LDAP, Lua, or both backends as per the input. If no cache names are found, a default cache name "__default__" is returned.
func GetUserAccountFromCache ¶ added in v1.5.2
func GetUserAccountFromCache(ctx context.Context, username string, guid string) (accountName string)
GetUserAccountFromCache fetches the user account name from Redis cache using the provided username. Logs errors and increments Redis read counter. Returns an empty string if the account name is not found or an error occurs.
func InitHTTPClient ¶ added in v1.3.0
func InitHTTPClient()
InitHTTPClient initializes the global httpClient variable with a pre-configured instance from util.NewHTTPClient.
func LDAPAuthWorker ¶
LDAPAuthWorker is responsible for handling LDAP authentication requests using a connection pool and concurrency control. It initializes the authentication connection pool, starts a resource management process, and handles requests or exits gracefully. It now uses a priority queue instead of channels for better request handling.
func LDAPMainWorker ¶
LDAPMainWorker orchestrates LDAP lookup operations, manages a connection pool, and processes incoming requests in a loop. It now uses a priority queue instead of channels for better request handling.
func LoadCacheFromRedis ¶
func LoadCacheFromRedis(ctx context.Context, key string, ucp *bktype.PositivePasswordCache) (isRedisErr bool, err error)
LoadCacheFromRedis retrieves cache data from Redis Hash based on a provided key and populates the given structure. It increments Redis read metrics and logs errors or debug information appropriately during the operation. Returns whether the error originated from Redis and any encountered error during retrieval or unmarshaling.
func LoaderModLDAP ¶ added in v1.2.2
func LoaderModLDAP(ctx context.Context) lua.LGFunction
LoaderModLDAP initializes and loads the LDAP module into the Lua state with predefined functions for LDAP operations.
func LookupUserAccountFromRedis ¶
func LookupUserAccountFromRedis(ctx context.Context, username string) (accountName string, err error)
LookupUserAccountFromRedis returns the user account value from the user Redis hash.
func LuaLDAPModify ¶ added in v1.5.5
LuaLDAPModify is a function that modifies LDAP entries based on the given Lua table input. It validates the input table, creates an LDAP modification request, and sends it via priority queue. The function returns results via Lua stack, "OK" on success, or an error message if the operation fails.
func LuaLDAPSearch ¶
LuaLDAPSearch initializes and registers an LDAP search function for Lua, handling inputs, validation, and processing.
func LuaMainWorker ¶
LuaMainWorker processes Lua script requests in a loop until the context is canceled. It compiles the Lua script and handles requests using a dedicated goroutine for each. It now uses a priority queue instead of channels for better request handling.
func ResolveAccountIdentifier ¶ added in v1.8.1
func ResolveAccountIdentifier(ctx context.Context, identifier string, guid string) (accountName string)
ResolveAccountIdentifier resolves an identifier that may be either a username or an account name. It first tries to look up a mapping in the USER hash; if not found, it treats the identifier as an account name.
func SaveUserDataToRedis ¶
func SaveUserDataToRedis(ctx context.Context, guid string, key string, ttl time.Duration, cache *bktype.PositivePasswordCache)
SaveUserDataToRedis is a generic routine to store a cache object on Redis using Redis Hash for better memory efficiency. It stores each field of the PositivePasswordCache structure as a separate hash field, with complex fields serialized as JSON.
Types ¶
type Channel ¶ added in v1.5.0
type Channel interface { // GetLdapChannel retrieves and returns the LDAPChannel instance associated with the implementation of the Channel interface. GetLdapChannel() LDAPChannel // GetLuaChannel retrieves and returns the LuaChannel instance associated with the Channel interface implementation. GetLuaChannel() LuaChannel }
Channel is an interface comprising methods to retrieve LDAPChannel and LuaChannel instances.
func GetChannel ¶ added in v1.5.0
func GetChannel() Channel
GetChannel returns a singleton instance of the Channel interface, initializing it if not already created.
func NewChannel ¶ added in v1.5.0
func NewChannel() Channel
NewChannel initializes and returns a new instance of the Channel interface implementation.
type LDAPChannel ¶ added in v1.5.0
type LDAPChannel interface { // GetLookupEndChan returns a channel that signals the completion of lookup operations. GetLookupEndChan(poolName string) chan bktype.Done // GetAuthEndChan returns the channel used to signal the completion of authentication operations. GetAuthEndChan(poolName string) chan bktype.Done // GetPoolNames retrieves and returns a list of names for all configured LDAP connection pools. GetPoolNames() []string // AddChannel creates and initializes all necessary channels for the specified LDAP connection pool by poolName. AddChannel(poolName string) error }
LDAPChannel defines an interface for managing LDAP-related channels for communication and operation handling.
func NewLDAPChannel ¶ added in v1.5.0
func NewLDAPChannel(poolName string) LDAPChannel
type LuaChannel ¶ added in v1.5.0
type LuaChannel interface { // GetLookupEndChan returns a channel used to signal the completion of lookup operations. GetLookupEndChan(backendName string) chan bktype.Done // GetBackendNames returns a list of all available backend names configured in the LuaChannel implementation. GetBackendNames() []string // AddChannel adds a new channel for the specified backend identified by the backendName. // Returns an error if the backendName is invalid or the channel could not be created. AddChannel(backendName string) error }
LuaChannel defines an interface for managing Lua-related channels used for communication and request handling.
func NewLuaChannel ¶ added in v1.5.0
func NewLuaChannel(backendName string) LuaChannel
NewLuaChannel creates and returns a new instance of LuaChannel, initialized as a LuaChannelImpl.
type LuaChannelImpl ¶ added in v1.5.0
type LuaChannelImpl struct {
// contains filtered or unexported fields
}
func (*LuaChannelImpl) AddChannel ¶ added in v1.5.0
func (c *LuaChannelImpl) AddChannel(backendName string) error
AddChannel initializes channels for request and completion handling for a specified backend name. Returns an error if the backend name is invalid.
func (*LuaChannelImpl) GetBackendNames ¶ added in v1.5.0
func (c *LuaChannelImpl) GetBackendNames() []string
GetBackendNames retrieves a list of backend names from the LuaChannelImpl's lookupEndChan map.
func (*LuaChannelImpl) GetLookupEndChan ¶ added in v1.5.0
func (c *LuaChannelImpl) GetLookupEndChan(backendName string) chan bktype.Done
GetLookupEndChan returns a channel of type Done that signals the end of a lookup operation.
type User ¶
type User struct { Id string `redis:"Id"` Name string `redis:"name"` DisplayName string `redis:"display_name"` Credentials []webauthn.Credential `redis:"credentials"` }
User represents the user model
func GetWebAuthnFromRedis ¶
GetWebAuthnFromRedis retrieves a User object from Redis Hash using the provided unique user ID. Returns the User object or an error if retrieval or unmarshaling fails.
func (*User) AddCredential ¶
func (u *User) AddCredential(cred webauthn.Credential)
AddCredential associates the credential to the user
func (*User) WebAuthnCredentials ¶
func (u *User) WebAuthnCredentials() []webauthn.Credential
WebAuthnCredentials returns credentials owned by the user
func (*User) WebAuthnDisplayName ¶
WebAuthnDisplayName returns the user's display name
func (*User) WebAuthnIcon ¶
WebAuthnIcon is not (yet) implemented
func (*User) WebAuthnName ¶
WebAuthnName returns the user's username