Documentation
¶
Overview ¶
Package mapper provides mapping between SCIM resources and CoreForge entities.
Index ¶
- Variables
- func ParseGroupID(id string) (uuid.UUID, error)
- func ParsePrincipalID(id string) (uuid.UUID, error)
- func ParseUserID(id string) (uuid.UUID, error)
- type Config
- type EnterpriseExtension
- type ExtensionMapper
- func (m *ExtensionMapper) FromMetadata(metadata map[string]any) *EnterpriseExtension
- func (m *ExtensionMapper) FromSCIM(ctx context.Context, enterprise *scim.EnterpriseUser) *EnterpriseExtension
- func (m *ExtensionMapper) ToMetadata(ext *EnterpriseExtension) map[string]any
- func (m *ExtensionMapper) ToSCIM(ctx context.Context, ext *EnterpriseExtension) *scim.EnterpriseUser
- type GroupMapper
- func (m *GroupMapper) ApplyPatch(ctx context.Context, org *identity.OrganizationInfo, ops []patch.Operation) (*identity.UpdateOrganizationInput, []MemberOperation, error)
- func (m *GroupMapper) FromSCIM(ctx context.Context, scimGroup *scim.Group) (*identity.CreateOrganizationInput, error)
- func (m *GroupMapper) ToSCIM(ctx context.Context, org *identity.OrganizationInfo) (*scim.Group, error)
- func (m *GroupMapper) ToSCIMWithMembers(ctx context.Context, org *identity.OrganizationInfo, ...) (*scim.Group, error)
- func (m *GroupMapper) ToSCIMWithMeta(ctx context.Context, org *identity.OrganizationInfo, ...) (*scim.Group, error)
- func (m *GroupMapper) ToUpdateInput(ctx context.Context, scimGroup *scim.Group) (*identity.UpdateOrganizationInput, error)
- type Mapper
- type MemberOperation
- type PrincipalUserMapper
- func (m *PrincipalUserMapper) ApplyPatch(ctx context.Context, p *principal.Principal, ops []patch.Operation) (*principal.UpdateHumanInput, error)
- func (m *PrincipalUserMapper) FromSCIM(ctx context.Context, scimUser *scim.User) (*principal.CreateHumanInput, error)
- func (m *PrincipalUserMapper) ToSCIM(ctx context.Context, p *principal.Principal) (*scim.User, error)
- func (m *PrincipalUserMapper) ToSCIMWithMeta(ctx context.Context, p *principal.Principal, createdAt, updatedAt time.Time) (*scim.User, error)
- func (m *PrincipalUserMapper) ToUpdateInput(ctx context.Context, scimUser *scim.User) (*principal.UpdateHumanInput, error)
- type UserMapper
- func (m *UserMapper) ApplyPatch(ctx context.Context, user *identity.UserInfo, ops []patch.Operation) (*identity.UpdateUserInput, error)
- func (m *UserMapper) FromSCIM(ctx context.Context, scimUser *scim.User) (*identity.CreateUserInput, error)
- func (m *UserMapper) ToSCIM(ctx context.Context, user *identity.UserInfo) (*scim.User, error)
- func (m *UserMapper) ToSCIMWithMeta(ctx context.Context, user *identity.UserInfo, createdAt, updatedAt time.Time) (*scim.User, error)
- func (m *UserMapper) ToUpdateInput(ctx context.Context, scimUser *scim.User) (*identity.UpdateUserInput, error)
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidPrincipalType = errors.New("principal must be of type human for SCIM User mapping")
ErrInvalidPrincipalType is returned when attempting to map a non-human principal to SCIM User.
Functions ¶
func ParseGroupID ¶
ParseGroupID parses a SCIM group ID to a UUID.
func ParsePrincipalID ¶
ParsePrincipalID parses a SCIM user ID to a UUID.
Types ¶
type Config ¶
type Config struct {
// BaseURL is the base URL for SCIM resources.
BaseURL string
// IncludeGroups determines whether to include group memberships in user resources.
IncludeGroups bool
// IncludeMembers determines whether to include members in group resources.
IncludeMembers bool
}
Config contains configuration for mappers.
func DefaultConfig ¶
func DefaultConfig() *Config
DefaultConfig returns the default mapper configuration.
type EnterpriseExtension ¶
type EnterpriseExtension struct {
EmployeeNumber string `json:"employee_number,omitempty"`
CostCenter string `json:"cost_center,omitempty"`
Organization string `json:"organization,omitempty"`
Division string `json:"division,omitempty"`
Department string `json:"department,omitempty"`
ManagerID string `json:"manager_id,omitempty"`
}
EnterpriseExtension contains enterprise user extension data. This is stored as metadata on the user in CoreForge.
func (*EnterpriseExtension) IsEmpty ¶
func (ext *EnterpriseExtension) IsEmpty() bool
IsEmpty returns true if the extension has no data.
type ExtensionMapper ¶
type ExtensionMapper struct {
// contains filtered or unexported fields
}
ExtensionMapper maps enterprise extension data.
func NewExtensionMapper ¶
func NewExtensionMapper(config *Config) *ExtensionMapper
NewExtensionMapper creates a new extension mapper.
func (*ExtensionMapper) FromMetadata ¶
func (m *ExtensionMapper) FromMetadata(metadata map[string]any) *EnterpriseExtension
FromMetadata converts a metadata map to enterprise extension.
func (*ExtensionMapper) FromSCIM ¶
func (m *ExtensionMapper) FromSCIM(ctx context.Context, enterprise *scim.EnterpriseUser) *EnterpriseExtension
FromSCIM converts SCIM EnterpriseUser to enterprise extension metadata.
func (*ExtensionMapper) ToMetadata ¶
func (m *ExtensionMapper) ToMetadata(ext *EnterpriseExtension) map[string]any
ToMetadata converts enterprise extension to a metadata map.
func (*ExtensionMapper) ToSCIM ¶
func (m *ExtensionMapper) ToSCIM(ctx context.Context, ext *EnterpriseExtension) *scim.EnterpriseUser
ToSCIM converts enterprise extension metadata to SCIM EnterpriseUser.
type GroupMapper ¶
type GroupMapper struct {
// contains filtered or unexported fields
}
GroupMapper maps between SCIM Group resources and CoreForge Organization entities.
func NewGroupMapper ¶
func NewGroupMapper(config *Config) *GroupMapper
NewGroupMapper creates a new group mapper.
func (*GroupMapper) ApplyPatch ¶
func (m *GroupMapper) ApplyPatch(ctx context.Context, org *identity.OrganizationInfo, ops []patch.Operation) (*identity.UpdateOrganizationInput, []MemberOperation, error)
ApplyPatch applies PATCH operations to an OrganizationInfo.
func (*GroupMapper) FromSCIM ¶
func (m *GroupMapper) FromSCIM(ctx context.Context, scimGroup *scim.Group) (*identity.CreateOrganizationInput, error)
FromSCIM converts a SCIM Group to a CoreForge CreateOrganizationInput.
func (*GroupMapper) ToSCIM ¶
func (m *GroupMapper) ToSCIM(ctx context.Context, org *identity.OrganizationInfo) (*scim.Group, error)
ToSCIM converts a CoreForge OrganizationInfo to a SCIM Group.
func (*GroupMapper) ToSCIMWithMembers ¶
func (m *GroupMapper) ToSCIMWithMembers(ctx context.Context, org *identity.OrganizationInfo, members []*identity.MembershipInfo, memberNames map[uuid.UUID]string) (*scim.Group, error)
ToSCIMWithMembers converts a CoreForge OrganizationInfo to a SCIM Group with members.
func (*GroupMapper) ToSCIMWithMeta ¶
func (m *GroupMapper) ToSCIMWithMeta(ctx context.Context, org *identity.OrganizationInfo, createdAt, updatedAt time.Time) (*scim.Group, error)
ToSCIMWithMeta converts a CoreForge OrganizationInfo to a SCIM Group with metadata timestamps.
func (*GroupMapper) ToUpdateInput ¶
func (m *GroupMapper) ToUpdateInput(ctx context.Context, scimGroup *scim.Group) (*identity.UpdateOrganizationInput, error)
ToUpdateInput converts a SCIM Group to a CoreForge UpdateOrganizationInput.
type Mapper ¶
type Mapper[S any, E any] interface { // ToSCIM converts a CoreForge entity to a SCIM resource. ToSCIM(ctx context.Context, entity E) (S, error) // FromSCIM converts a SCIM resource to a CoreForge entity or update input. // Returns an interface{} that can be either a create input or update input. FromSCIM(ctx context.Context, resource S) (any, error) // ApplyPatch applies PATCH operations to an entity. ApplyPatch(ctx context.Context, entity E, ops []patch.Operation) (E, error) }
Mapper defines the interface for mapping between SCIM resources and CoreForge entities.
type MemberOperation ¶
type MemberOperation struct {
Op patch.OperationType
UserID uuid.UUID
}
MemberOperation represents a member add/remove operation.
type PrincipalUserMapper ¶
type PrincipalUserMapper struct {
// contains filtered or unexported fields
}
PrincipalUserMapper maps between SCIM User resources and CoreForge Principal+Human entities. This mapper wraps the Principal-centric identity model where SCIM Users map to Principal(type=human) with an associated Human extension.
func NewPrincipalUserMapper ¶
func NewPrincipalUserMapper(config *Config) *PrincipalUserMapper
NewPrincipalUserMapper creates a new principal user mapper.
func (*PrincipalUserMapper) ApplyPatch ¶
func (m *PrincipalUserMapper) ApplyPatch(ctx context.Context, p *principal.Principal, ops []patch.Operation) (*principal.UpdateHumanInput, error)
ApplyPatch applies PATCH operations to a Principal and returns an UpdateHumanInput.
func (*PrincipalUserMapper) FromSCIM ¶
func (m *PrincipalUserMapper) FromSCIM(ctx context.Context, scimUser *scim.User) (*principal.CreateHumanInput, error)
FromSCIM converts a SCIM User to a CoreForge CreateHumanInput.
func (*PrincipalUserMapper) ToSCIM ¶
func (m *PrincipalUserMapper) ToSCIM(ctx context.Context, p *principal.Principal) (*scim.User, error)
ToSCIM converts a CoreForge Principal (with Human extension) to a SCIM User.
func (*PrincipalUserMapper) ToSCIMWithMeta ¶
func (m *PrincipalUserMapper) ToSCIMWithMeta(ctx context.Context, p *principal.Principal, createdAt, updatedAt time.Time) (*scim.User, error)
ToSCIMWithMeta converts a CoreForge Principal to a SCIM User with metadata timestamps.
func (*PrincipalUserMapper) ToUpdateInput ¶
func (m *PrincipalUserMapper) ToUpdateInput(ctx context.Context, scimUser *scim.User) (*principal.UpdateHumanInput, error)
ToUpdateInput converts a SCIM User to a CoreForge UpdateHumanInput.
type UserMapper ¶
type UserMapper struct {
// contains filtered or unexported fields
}
UserMapper maps between SCIM User resources and CoreForge User entities.
func NewUserMapper ¶
func NewUserMapper(config *Config) *UserMapper
NewUserMapper creates a new user mapper.
func (*UserMapper) ApplyPatch ¶
func (m *UserMapper) ApplyPatch(ctx context.Context, user *identity.UserInfo, ops []patch.Operation) (*identity.UpdateUserInput, error)
ApplyPatch applies PATCH operations to a UserInfo.
func (*UserMapper) FromSCIM ¶
func (m *UserMapper) FromSCIM(ctx context.Context, scimUser *scim.User) (*identity.CreateUserInput, error)
FromSCIM converts a SCIM User to a CoreForge CreateUserInput.
func (*UserMapper) ToSCIMWithMeta ¶
func (m *UserMapper) ToSCIMWithMeta(ctx context.Context, user *identity.UserInfo, createdAt, updatedAt time.Time) (*scim.User, error)
ToSCIMWithMeta converts a CoreForge UserInfo to a SCIM User with metadata timestamps.
func (*UserMapper) ToUpdateInput ¶
func (m *UserMapper) ToUpdateInput(ctx context.Context, scimUser *scim.User) (*identity.UpdateUserInput, error)
ToUpdateInput converts a SCIM User to a CoreForge UpdateUserInput.