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 NewAdapter() framework.Adapter[Config]
- func OctetStringToBytes(octalString string) ([]byte, error)
- func ResultCodeToHTTPStatusCode(ldapError *ldap_v3.Error) int
- 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 EntityConfig
- type PageInfo
- type Request
- type Response
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 NewAdapter ¶
NewAdapter instantiates a new Adapter.
func OctetStringToBytes ¶
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.
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
// BaseDN is the Base DN of the datasource to query.
BaseDN string
// BindDN is the Bind DN of the datasource to query.
BindDN string
// BindPassword is the password of the datasource to query.
BindPassword string
// IsLDAPS flag to check if connection is secured
IsLDAPS bool
// CertificateChain contains certificate chain to use for ldaps connection
CertificateChain string
}
type Datasource ¶
type Datasource struct{}
Datasource directly implements a Client interface to allow querying an external datasource.
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 Request ¶
type Request struct {
// ConnectionParams contains LDAP specific params
ConnectionParams
// BaseURL is the Base URL of the datasource to query.
BaseURL string
// PageSize is the maximum number of objects to return from the entity.
PageSize int64
// EntityExternalID is the external ID of the entity.
// The external ID should match the API's resource name.
EntityExternalID string
// 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]
// UniqueIDAttribute is a attribute which can be used to uniquely identify the Entity.
// This is specific to ldap server implementation
UniqueIDAttribute string
// 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
// Attributes contains the list of attributes to request along with the current request.
Attributes []*framework.AttributeConfig
// 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
}
Request is a request to the datasource.
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
// RetryAfterHeader is the Retry-After response HTTP header, if set.
RetryAfterHeader string
// Objects is the list of
// May be empty.
Objects []map[string]any
// 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]
}
Response is a response returned by the datasource.