Documentation
¶
Overview ¶
Copyright 2025 SGNL.ai, Inc.
Copyright 2025 SGNL.ai, Inc.
Index ¶
- Constants
- func BytesToOctetString(data []byte) *string
- func DefaultEntityConfig() map[string]*EntityConfig
- func EntryToObject(e *ldap_v3.Entry, attrConfig map[string]*framework.AttributeConfig) (map[string]interface{}, *framework.Error)
- func GetTLSConfig(request *Request) (*tls.Config, *framework.Error)
- func NewAdapter(client grpc_proxy_v1.ProxyServiceClient, ttl, cleanupInterval time.Duration) framework.Adapter[Config]
- func OctetStringToBytes(octalString string) ([]byte, error)
- func ProcessLDAPSearchResult(result *ldap_v3.SearchResult, response *Response, request *Request) *framework.Error
- func SetFilters(request *Request) (string, *framework.Error)
- func StringAttrValuesToRequestedType(attr *ldap_v3.EntryAttribute, isList bool, attrType framework.AttributeType) (any, *framework.Error)
- type Adapter
- func (a *Adapter) GetPage(ctx context.Context, request *framework.Request[Config]) framework.Response
- func (a *Adapter) RequestPageFromDatasource(ctx context.Context, request *framework.Request[Config]) framework.Response
- func (a *Adapter) ValidateGetPageRequest(ctx context.Context, request *framework.Request[Config]) *framework.Error
- type Client
- type Config
- type ConnectionParams
- type Datasource
- type Dispatcher
- type EntityConfig
- type PageInfo
- type Proxy
- type Request
- type Requester
- type Response
- type Session
- type SessionPool
Constants ¶
const (
ErrorMsgAttributeTypeDoesNotMatchFmt = "Attribute '%s' was returned from the " +
"configured datasource as type %s; wanted type %s"
)
Variables ¶
This section is empty.
Functions ¶
func BytesToOctetString ¶
func DefaultEntityConfig ¶
func DefaultEntityConfig() map[string]*EntityConfig
defaultEntityConfig: if entityConfig is nil, defaulting to values that pull data from ActiveDirectory.
func EntryToObject ¶
func GetTLSConfig ¶ added in v1.39.0
GetTLSConfig creates a TLS config using certchain from the request.
func NewAdapter ¶
func NewAdapter(client grpc_proxy_v1.ProxyServiceClient, ttl, cleanupInterval time.Duration) framework.Adapter[Config]
NewAdapter instantiates a new Adapter. It is used to connect to a LDAP server and execute search queries. The client is not proxied by default. If you want to use a proxied client, you need to provide a grpc_proxy_v1.ProxyServiceClient instance. The adapter also manages a session pool to reuse LDAP connections.
func OctetStringToBytes ¶
func ProcessLDAPSearchResult ¶ added in v1.39.0
func SetFilters ¶
SetFilters configures the LDAP search filters based on the inputs received in entityConfig.
func StringAttrValuesToRequestedType ¶
func StringAttrValuesToRequestedType( attr *ldap_v3.EntryAttribute, isList bool, attrType framework.AttributeType, ) (any, *framework.Error)
Types ¶
type Adapter ¶
type Adapter struct {
ADClient Client
}
Adapter implements the framework.Adapter interface to query pages of objects from datasources.
func (*Adapter) GetPage ¶
func (a *Adapter) GetPage(ctx context.Context, request *framework.Request[Config]) framework.Response
GetPage is called by SGNL's ingestion service to query a page of objects from a datasource.
type Client ¶
type Client interface {
GetPage(ctx context.Context, request *Request) (*Response, *framework.Error)
}
Client is a client that allows querying the datasource which contains JSON objects.
func NewClient ¶
func NewClient(proxy grpc_proxy_v1.ProxyServiceClient, pool *SessionPool) Client
NewClient returns a Client to query the datasource.
type Config ¶
type Config struct {
// Common configuration
*config.CommonConfig
BaseDN string `json:"baseDN"`
// CertificateChain is a base64 encoded Certificates
CertificateChain string `json:"certificateChain,omitempty"`
// EntityConfigMap is an map containing the config required for each entity associated with this
// datasource. The key is the entity's external_name and value is EntityConfig.
EntityConfigMap map[string]*EntityConfig `json:"entityConfig"`
}
type ConnectionParams ¶
type ConnectionParams struct {
// Host is the Hostname of the datasource to query.
Host string `json:"host"`
// BaseDN is the Base DN of the datasource to query.
BaseDN string `json:"baseDN"`
// BindDN is the Bind DN of the datasource to query.
BindDN string `json:"bindDN"`
// BindPassword is the password of the datasource to query.
BindPassword string `json:"bindPassword"`
// IsLDAPS flag to check if connection is secured
IsLDAPS bool `json:"isLDAPS"`
// CertificateChain contains certificate chain to use for ldaps connection
CertificateChain string `json:"certificateChain,omitempty"`
}
type Datasource ¶
type Datasource struct {
Client Dispatcher
}
Datasource directly implements a Client interface to allow querying an external datasource.
type Dispatcher ¶ added in v1.39.0
Dispatcher is an interface that combines Proxy and Requester. It is used to determine if the LDAP request should be proxied or sent directly to the LDAP server. The IsProxied method checks if the LDAP request is proxied.
type EntityConfig ¶
type EntityConfig struct {
Query string `json:"query"`
CollectionAttribute *string `json:"collectionAttribute"`
MemberUniqueIDAttribute *string `json:"memberUniqueIdAttribute,omitempty"`
MemberOfUniqueIDAttribute *string `json:"memberOfUniqueIdAttribute,omitempty"`
MemberOf *string `json:"memberOf,omitempty"`
}
EntityConfig holds attributes which are used to create LDAP search filter.
type PageInfo ¶
type PageInfo struct {
// Collection is a map of the attributes of the collection entity.
Collection map[string]any `json:"collection"`
// NextPageCursor is the cursor to the next page of results.
NextPageCursor *string `json:"nextPageCursor"`
}
func ParseResponse ¶
func ParseResponse(searchResult *ldap_v3.SearchResult, attributes map[string]*framework.AttributeConfig) ( objects []map[string]any, pageInfo *PageInfo, err *framework.Error)
type Proxy ¶ added in v1.41.0
type Proxy interface {
ProxyRequest(ctx context.Context, ci *connector.ConnectorInfo, request *Request) (*Response, *framework.Error)
}
Proxy is an interface for LDAP proxy requests. It is used to send LDAP requests to a remote connector via the SGNL connector proxy.
type Request ¶
type Request struct {
// ConnectionParams contains LDAP specific params
ConnectionParams `json:"connectionParams"`
// BaseURL is the Base URL of the datasource to query.
BaseURL string `json:"baseURL"`
// PageSize is the maximum number of objects to return from the entity.
PageSize int64 `json:"pageSize"`
// EntityExternalID is the external ID of the entity.
// The external ID should match the API's resource name.
EntityExternalID string `json:"entityExternalID"`
// Cursor identifies the first object of the page to return, as returned by
// the last request for the entity.
// nil in the request for the first page.
Cursor *pagination.CompositeCursor[string] `json:"cursor,omitempty"`
// UniqueIDAttribute is a attribute which can be used to uniquely identify the Entity.
// This is specific to ldap server implementation
UniqueIDAttribute string `json:"uniqueIDAttribute"`
// EntityConfigMap is an map containing the config required for each entity associated with this
// datasource. The key is the entity's external_name and value is EntityConfig.
EntityConfigMap map[string]*EntityConfig `json:"entityConfigMap,omitempty"`
// Attributes contains the list of attributes to request along with the current request.
Attributes []*framework.AttributeConfig `json:"attributes,omitempty"`
// RequestTimeoutSeconds is the timeout duration for requests made to datasources.
// This should be set to the number of seconds to wait before timing out.
RequestTimeoutSeconds int `json:"requestTimeoutSeconds"`
}
Request is a request to the datasource.
type Requester ¶ added in v1.41.0
type Requester interface {
Request(ctx context.Context, request *Request) (*Response, *framework.Error)
}
Requester is an interface for LDAP requests. It is used to send LDAP requests directly to a publicly accessible LDAP server.
func NewLDAPRequester ¶ added in v1.41.0
NewLDAPRequester creates a new LDAP Requester instance. It is used to create a new LDAP client for making LDAP search requests. It also manages a session pool to reuse LDAP connections.
type Response ¶
type Response struct {
// TODO: Update the comment once we support LDAP status with adapter-framework
// StatusCode is an HTTP status code.
StatusCode int `json:"statusCode"`
// RetryAfterHeader is the Retry-After response HTTP header, if set.
RetryAfterHeader string `json:"retryAfterHeader"`
// Objects is the list of
// May be empty.
Objects []map[string]any `json:"objects,omitempty"`
// NextCursor is the cursor that identifies the first object of the next page.
// nil if this is the last page in this full sync.
NextCursor *pagination.CompositeCursor[string] `json:"nextCursor"`
}
Response is a response returned by the datasource.
type SessionPool ¶ added in v1.43.0
type SessionPool struct {
// contains filtered or unexported fields
}
func NewSessionPool ¶ added in v1.43.0
func NewSessionPool(ttl, cleanupInterval time.Duration) *SessionPool
func (*SessionPool) Delete ¶ added in v1.43.0
func (sp *SessionPool) Delete(key string)
func (*SessionPool) SessionCount ¶ added in v1.43.0
func (sp *SessionPool) SessionCount() int
func (*SessionPool) Set ¶ added in v1.43.0
func (sp *SessionPool) Set(key string, session *Session)
func (*SessionPool) UpdateKey ¶ added in v1.43.0
func (sp *SessionPool) UpdateKey(oldKey, newKey string)