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) 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 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 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) 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.
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) 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
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 `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 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.