Documentation ¶
Index ¶
- Constants
- func CreateIDFromExternalID(resource string) (string, error)
- type Backend
- type IDGenerator
- type InMemoryBackend
- func (backend *InMemoryBackend) Clear(tenant string) error
- func (backend *InMemoryBackend) CountResources(tenant, resourceType string) int
- func (backend *InMemoryBackend) Create(tenant, resourceType, resource string) (string, error)
- func (backend *InMemoryBackend) Delete(tenant, resourceType, resourceID string) error
- func (backend *InMemoryBackend) GetParsedResource(tenant, resourceType string, id string) (interface{}, error)
- func (backend *InMemoryBackend) GetParsedResources(tenant, resourceType string) (map[string]interface{}, error)
- func (backend *InMemoryBackend) GetResource(tenant, resourceType string, id string) (string, error)
- func (backend *InMemoryBackend) GetResourceTypes(tenant string) []string
- func (backend *InMemoryBackend) GetResources(tenant, resourceType string) (map[string]string, error)
- func (backend *InMemoryBackend) Load(serializedForm []byte) error
- func (backend *InMemoryBackend) Serialize() ([]byte, error)
- func (backend *InMemoryBackend) Update(tenant, resourceType, resourceID, resource string) (string, error)
- type ObjectParser
- type ParsedResourceSet
- type ResourceSet
- type SCIMErrorType
- type SCIMTypedError
- type Server
- type TenantGetter
Constants ¶
const ( // ConflictError is returned when an attempt is made to create a resource that already exists ConflictError = iota // MissingResourceError is returned if the resource doesn't exist in the backend MissingResourceError // MalformedResourceError is returned if the client sent a resource that's invalid. // For instance missing required attributes or if an attribute has the wrong datatype MalformedResourceError )
Various types of errors the backend can return, which should result in different HTTP error codes according to the SCIM spec.
const SCIMDeprecatedMediaType = "application/json"
const SCIMMediaType = "application/scim+json"
Variables ¶
This section is empty.
Functions ¶
func CreateIDFromExternalID ¶
CreateIDFromExternalID will use the externalId attribute as internal ID
Types ¶
type Backend ¶
type Backend interface { Create(tenant, resourceType, resource string) (string, error) Update(tenant, resourceType, resourceID, resource string) (string, error) Delete(tenant, resourceType, resourceID string) error Clear(tenant string) error GetResources(tenant, resourceType string) (map[string]string, error) GetResource(tenant, resourceType string, id string) (string, error) GetParsedResources(tenant, resourceType string) (map[string]interface{}, error) GetParsedResource(tenant, resourceType string, id string) (interface{}, error) }
Backend is where the SCIM server stores, modifies and gets the resources
type IDGenerator ¶
IDGenerator is a function which takes a resource and generates an ID for the resource
type InMemoryBackend ¶
type InMemoryBackend struct {
// contains filtered or unexported fields
}
InMemoryBackend is a simple SCIM backend which stores all resources in memory
func NewInMemoryBackend ¶
func NewInMemoryBackend(gen IDGenerator, parser ObjectParser) *InMemoryBackend
NewInMemoryBackend allocates and returns a new InMemoryBackend
func (*InMemoryBackend) Clear ¶
func (backend *InMemoryBackend) Clear(tenant string) error
Clear will remove all resources for a given tenant in the backend
func (*InMemoryBackend) CountResources ¶
func (backend *InMemoryBackend) CountResources(tenant, resourceType string) int
CountResources returns number of objects for a resource type for a given tenant
func (*InMemoryBackend) Create ¶
func (backend *InMemoryBackend) Create(tenant, resourceType, resource string) (string, error)
Create will create a resource in the backend
func (*InMemoryBackend) Delete ¶
func (backend *InMemoryBackend) Delete(tenant, resourceType, resourceID string) error
Delete will delete a resource from the backend
func (*InMemoryBackend) GetParsedResource ¶
func (backend *InMemoryBackend) GetParsedResource(tenant, resourceType string, id string) (interface{}, error)
GetParsedResource returns a specific parsed resource for a given tenant If no ObjectParser was given, or if the ObjectParser returns nil for some resource types, the returned interface{} may be nil.
func (*InMemoryBackend) GetParsedResources ¶
func (backend *InMemoryBackend) GetParsedResources(tenant, resourceType string) (map[string]interface{}, error)
GetParsedResources returns all parsed resources If no ObjectParser was given, or if the ObjectParser returns nil for some resource types, the returned map may contain nils.
func (*InMemoryBackend) GetResource ¶
func (backend *InMemoryBackend) GetResource(tenant, resourceType string, id string) (string, error)
GetResource returns a specific resource for a given tenant
func (*InMemoryBackend) GetResourceTypes ¶
func (backend *InMemoryBackend) GetResourceTypes(tenant string) []string
GetResourceTypes returns the resource types for which we have objects for a given tenant
func (*InMemoryBackend) GetResources ¶
func (backend *InMemoryBackend) GetResources(tenant, resourceType string) (map[string]string, error)
GetResources returns all resources for a type
func (*InMemoryBackend) Load ¶
func (backend *InMemoryBackend) Load(serializedForm []byte) error
Load reads all resources from serialized form
func (*InMemoryBackend) Serialize ¶
func (backend *InMemoryBackend) Serialize() ([]byte, error)
Serialize returns all resources in a format which can later be read with Load()
type ObjectParser ¶
ObjectParser is a function which parses the resource from JSON to a Go object It is optional to supply an ObjectParser when creating the backend, and the ObjectParser doesn't need to be able to parse any resource type (it can just return nil for types it won't parse). In those cases the "parsed" representation of a resource will be nil in the backend.
type ParsedResourceSet ¶
A ParsedResourceSet contains all parsed resources for one tenant
type ResourceSet ¶
A ResourceSet contains all resources for one tenant
type SCIMErrorType ¶
type SCIMErrorType int
SCIMErrorType is a standard type of error the backend can return
type SCIMTypedError ¶
type SCIMTypedError interface { error Type() SCIMErrorType }
SCIMTypedError should be used by the backend when possible At least for the methods that modify resources the SCIM server needs to know what kind of error occurred so the correct error code can be given to the client
func NewError ¶
func NewError(t SCIMErrorType, msg string) SCIMTypedError
NewError creates a new SCIMTypedError
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is a light weight SCIM server
type TenantGetter ¶
A TenantGetter is a function which provides the authenticated tenant from the context Typically scimserverlite's http handler will sit behind a middleware which handles authentication and figures out which tenant the client represents. The middlware can then store the tenant in the context and provide a TenantGetter which retrieves it.
If no authentication is used the TenantGetter should simply return "".