Documentation ¶
Overview ¶
This package implements the founding blocks for defining SCIM resource types, and basic error types.
Index ¶
- Constants
- Variables
- func MetaAttributes() *metaAttr
- func Schemas() *schemaRegistry
- type Attribute
- func (attr *Attribute) Annotation(name string) (params map[string]interface{}, ok bool)
- func (attr *Attribute) CaseExact() bool
- func (attr *Attribute) CountCanonicalValues() int
- func (attr *Attribute) CountReferenceTypes() int
- func (attr *Attribute) CountSubAttributes() int
- func (attr *Attribute) DFS(callback func(attr *Attribute))
- func (attr *Attribute) DeriveElementAttribute() *Attribute
- func (attr *Attribute) Description() string
- func (attr *Attribute) Equals(other *Attribute) bool
- func (attr *Attribute) ExistsCanonicalValue(criteria func(canonicalValue string) bool) bool
- func (attr *Attribute) ExistsReferenceType(criteria func(referenceType string) bool) bool
- func (attr *Attribute) FindSubAttribute(criteria func(subAttr *Attribute) bool) *Attribute
- func (attr *Attribute) ForEachAnnotation(callback func(annotation string, params map[string]interface{}))
- func (attr *Attribute) ForEachCanonicalValues(callback func(canonicalValue string))
- func (attr *Attribute) ForEachReferenceTypes(callback func(referenceType string))
- func (attr *Attribute) ForEachSubAttribute(callback func(subAttribute *Attribute) error) error
- func (attr *Attribute) GoesBy(name string) bool
- func (attr *Attribute) ID() string
- func (attr *Attribute) IsElementAttributeOf(other *Attribute) bool
- func (attr *Attribute) Len() int
- func (attr *Attribute) Less(i, j int) bool
- func (attr *Attribute) MarshalJSON() ([]byte, error)
- func (attr *Attribute) MultiValued() bool
- func (attr *Attribute) Mutability() Mutability
- func (attr *Attribute) Name() string
- func (attr *Attribute) Path() string
- func (attr *Attribute) PublicValues() interface{}
- func (attr *Attribute) Required() bool
- func (attr *Attribute) Returned() Returned
- func (attr *Attribute) SubAttributeForName(name string) *Attribute
- func (attr *Attribute) Swap(i, j int)
- func (attr *Attribute) Type() Type
- func (attr *Attribute) Uniqueness() Uniqueness
- func (attr *Attribute) UnmarshalJSON(raw []byte) error
- type Error
- type Mutability
- type ResourceType
- func (t *ResourceType) CountExtensions() int
- func (t *ResourceType) Description() string
- func (t *ResourceType) Endpoint() string
- func (t *ResourceType) ForEachExtension(callback func(extension *Schema, required bool) error) error
- func (t *ResourceType) ID() string
- func (t *ResourceType) MarshalJSON() ([]byte, error)
- func (t *ResourceType) Name() string
- func (t *ResourceType) ResourceLocation() string
- func (t *ResourceType) ResourceTypeName() string
- func (t *ResourceType) Schema() *Schema
- func (t *ResourceType) SuperAttribute(includeCore bool) *Attribute
- func (t *ResourceType) UnmarshalJSON(raw []byte) error
- type Returned
- type Schema
- func (s *Schema) Description() string
- func (s *Schema) ForEachAttribute(callback func(attr *Attribute) error) error
- func (s *Schema) ID() string
- func (s *Schema) MarshalJSON() ([]byte, error)
- func (s *Schema) Name() string
- func (s *Schema) ResourceLocation() string
- func (s *Schema) ResourceTypeName() string
- func (s *Schema) UnmarshalJSON(raw []byte) error
- type ServiceProviderConfig
- type Type
- type Uniqueness
Constants ¶
const ApplicationScimJson = "application/scim+json"
SCIM defined standard content type
const CoreSchemaId = "core"
Reserved Id for core schema
const ISO8601 = "2006-01-02T15:04:05"
SCIM defined date format used to parse dateTime values.
Variables ¶
var ( // The specified filter syntax was invalid, or the specified attribute and filter comparison combination is not supported. ErrInvalidFilter = &Error{Status: 400, Type: "invalidFilter"} // The specified filter yields many more results than the server is willing to calculate or process. ErrTooMany = &Error{Status: 400, Type: "tooMany"} // One or more of the attribute values are already in use or are reserved. ErrUniqueness = &Error{Status: 409, Type: "uniqueness"} // The attempted modification is not compatible with the target attribute's mutability or current state (e.g., // modification of an "immutable" attribute with an existing value). ErrMutability = &Error{Status: 400, Type: "mutability"} // The request body message structure was invalid or did not conform to the request schema. ErrInvalidSyntax = &Error{Status: 400, Type: "invalidSyntax"} // The "path" attribute was invalid or malformed. ErrInvalidPath = &Error{Status: 400, Type: "invalidPath"} // The specified "path" did not yield an attribute or attribute value that could be operated on. This occurs when // the specified "path" value contains a filter that yields no match. ErrNoTarget = &Error{Status: 400, Type: "noTarget"} // A required value was missing, or the value specified was not compatible with the operation or attribute type. ErrInvalidValue = &Error{Status: 400, Type: "invalidValue"} // The resource was not found from persistence store. ErrNotFound = &Error{Status: 404, Type: "notFound"} // The specified request cannot be completed, due to the passing of sensitive information in a request URI. ErrSensitive = &Error{Status: 400, Type: "sensitive"} // The resource is in conflict with some pre conditions. ErrConflict = &Error{Status: 412, Type: "conflict"} // Server encountered internal error. ErrInternal = &Error{Status: 500, Type: "internal"} )
Error prototypes
Functions ¶
func MetaAttributes ¶
func MetaAttributes() *metaAttr
MetaAttributes returns a structure to access individual attributes about fields in Schema, Attribute and ResourceType. These attributes are known as meta attributes, because they describe things that are used to describe other resources.
Types ¶
type Attribute ¶
type Attribute struct {
// contains filtered or unexported fields
}
Attribute models a superset of defined SCIM attributes. It serves as the basic unit that describes data requirement this project.
In addition to attributes defined in SCIM, four additional attributes are defined: id, index, path and annotations. Id defines a unique identifier for this attribute, which by convention, should be the full URN name. Index defines a relative ascending sort index for the attribute among other attributes on the same level, which can be used to ensure proper ordering and nice presentation. Path is joined attribute names from the root, which is used to determine the full attribute name without further calculation. Annotations are of type map[string]map[string]interface{}, which is used as the major extension point to define additional behaviour. It is widely used by other processing mechanisms in this module. These four additional attributes have JSON names of "id", "_index", "_path" and "_annotations" respectively.
As an example, a typical attribute can be defined in JSON as:
{ "id": "urn:ietf:params:scim:schemas:core:2.0:User:name.familyName", "name": "familyName", "type": "string", "multiValued": false, "required": false, "caseExact": false, "mutability": "readWrite", "returned": "default", "uniqueness": "none", "_index": 1, "_path": "name.familyName", "_annotations": { "@Identity": {} } }
The above example defines a typical "name.familyName" attribute in the User resource type. It can be universally identified by "urn:ietf:params:scim:schemas:core:2.0:User:name.familyName"; can be placed at the second position (index 1) among sub attributes of "urn:ietf:params:scim:schemas:core:2.0:User:name"; has a path of "name.familyName" and has a single parameter-less annotation of "@Identity".
Because Attribute is at the core of the SCIM protocol, it is designed to be read only as much as possible. All data access, including iteration, search operations, need to be done via accessor methods. For simple fields, look for the methods corresponding to the field name. For example, field name can be accessed via method Name. For array fields, look for methods prefixed with ForEach, Exists and Count to perform iteration, search and get-length operations.
Attribute also introduces the notion of an element attribute. An element attribute is a derived attribute from a multiValued attribute in order to represent the data requirements of its elements. Because elements of multiValued properties can be generated and deleted on the fly, these attributes also need to be so. DeriveElementAttribute can be used to generate a new element attribute. IsElementAttributeOf can be used to check if the current attribute is a derived element attribute.
As of now, Attribute is parsed to and from JSON using special adapter structures that exposes and hides certain fields. This design is subject to change when we move to treat Schema as just another resource. See also:
issue https://github.com/imulab/go-scim/issues/40
func (*Attribute) Annotation ¶
Annotation returns the annotation parameters by the given name (case sensitive) and a boolean indicating whether this annotations exists.
func (*Attribute) CaseExact ¶
CaseExact returns true if the attribute's value is case sensitive. Case sensitivity only applies to string attributes.
func (*Attribute) CountCanonicalValues ¶
CountCanonicalValues returns the total number of canonical values defined.
func (*Attribute) CountReferenceTypes ¶
CountReferenceTypes returns the total number of reference types.
func (*Attribute) CountSubAttributes ¶
Return the total number of sub attributes.
func (*Attribute) DFS ¶
DFS perform a depth-first-traversal on the given attribute and invokes callback
func (*Attribute) DeriveElementAttribute ¶
DeriveElementAttribute create an element attribute of this attribute. This method is only meaningful when invoked on a multiValued attribute.
The derived element attribute will inherit most properties from this attribute except for id, multiValued and annotations. Id will be suffixed with "$elem". MultiValued will be set to false. Annotations will be derived from the parameters of "@ElementAnnotations" from this attribute.
For example, a multiValued attribute (certain fields omitted for brevity) like
{ "id": "urn:ietf:params:scim:schemas:core:2.0:User:emails", "name": "emails", "type": "complex", "multiValued": true, "_annotations": { "@ElementAnnotations": { "@StateSummary": {} } }, ... }
will derive an element attribute of:
{ "id": "urn:ietf:params:scim:schemas:core:2.0:User:emails$elem", "name": "emails", "type": "complex", "multiValued": false, "_annotations": { "@StateSummary": {} }, ... }
See also:
annotation.ElementAnnotations
func (*Attribute) Description ¶
Description returns human-readable text to describe the attribute.
func (*Attribute) ExistsCanonicalValue ¶
ExistsCanonicalValue returns true if the canonical value that meets the criteria exists; false otherwise.
func (*Attribute) ExistsReferenceType ¶
ExistsReferenceType returns true if the reference type that meets the criteria exists; false otherwise.
func (*Attribute) FindSubAttribute ¶
FindSubAttribute returns the sub attribute that matches the criteria, or returns nil if no sub attribute meets criteria.
func (*Attribute) ForEachAnnotation ¶
func (attr *Attribute) ForEachAnnotation(callback func(annotation string, params map[string]interface{}))
ForEachAnnotation iterates through annotations and invoke callback.
func (*Attribute) ForEachCanonicalValues ¶
ForEachCanonicalValues invokes callback function on each defined canonical values
func (*Attribute) ForEachReferenceTypes ¶
ForEachReferenceTypes invokes callback function on each defined reference types
func (*Attribute) ForEachSubAttribute ¶
ForEachSubAttribute invokes callback function on each sub attribute.
func (*Attribute) GoesBy ¶
GoesBy returns true if this attribute can be addressed by the given name.
func (*Attribute) ID ¶
ID returns the id of the attribute that globally identifies the attribute. Attribute ids are in the format of <schema_urn>:<full_path>. Core attributes has no need to prefix the schema URN. For instance, "schemas", "meta.version", "urn:ietf:params:scim:schemas:core:2.0:Group:displayName"
func (*Attribute) IsElementAttributeOf ¶
IsElementAttributeOf returns true if this attribute is the derived element attribute of the other attribute.
func (*Attribute) MarshalJSON ¶
func (*Attribute) MultiValued ¶
MultiValued return whether the attribute allows several instance of properties to be defined.
func (*Attribute) Mutability ¶
func (attr *Attribute) Mutability() Mutability
Mutability return the mutability definition of the attribute.
func (*Attribute) Path ¶
Path returns the full path of this attribute. The full path are the name of all attributes from the root to this attribute, delimited by period ("."). For instance, "id", "meta.version", "emails.value".
func (*Attribute) PublicValues ¶
func (attr *Attribute) PublicValues() interface{}
PublicValues returns a representation of this attribute's public values (non-extension) in a data structure that conforms to the definition of prop.Property#Raw. However, this method does not implement it.
func (*Attribute) SubAttributeForName ¶
Return the sub attribute that goes by the name, or nil
func (*Attribute) Uniqueness ¶
func (attr *Attribute) Uniqueness() Uniqueness
Uniqueness return the uniqueness definition of the attribute.
func (*Attribute) UnmarshalJSON ¶
type Error ¶
A SCIM error message. The structure is left completely open for convenience, but it is not recommended to create Error directly. To create an error, use the error prototypes (i.e. ErrInvalidFilter). If needed, wrap the error prototype by fmt.Errorf("additional detail: %w", err).
type Mutability ¶
type Mutability int
SCIM mutability definition
const ( MutabilityReadWrite Mutability = iota MutabilityReadOnly MutabilityWriteOnly MutabilityImmutable )
SCIM mutability attribute defined in RFC7643
func (Mutability) String ¶
func (m Mutability) String() string
type ResourceType ¶
type ResourceType struct {
// contains filtered or unexported fields
}
Resource type models the SCIM resource type. It is a collection of one main schema and zero or more schema extensions to describe a single type of SCIM resource.
To access the main schema of the resource type, call Schema method; to access the schema extensions, use ForEachExtension method.
A resource type can be used to generate a super attribute. A super attribute is a single valued complex typed attribute that encapsulates all attributes from its main schema and schema extensions as sub attributes. Among these, the top-level attributes from the main schema will be added to the super attribute as top level sub attributes. The top-level attributes from each schema extension will be first added to a container complex attribute as top level sub attributes, and then that single container complex attribute is added to the super attribute as a top level sub attribute.
For example, suppose we have a main schema containing attribute A1 and A2, a schema extension B containing attribute B1, and another schema extension C containing attribute C1 and C2. The super attribute will be in the structure of:
{ A1, A2, B { B1 }, C { C1, C2 } }
ResourceType is currently being parsed to and from JSON using special adapters. This design is subject to change when we move to treat ResourceType as just another resource. See also:
issue https://github.com/imulab/go-scim/issues/40
func (*ResourceType) CountExtensions ¶
func (t *ResourceType) CountExtensions() int
CountExtensions returns the total number of extensions
func (*ResourceType) Description ¶
func (t *ResourceType) Description() string
Return the description of the resource type
func (*ResourceType) Endpoint ¶
func (t *ResourceType) Endpoint() string
func (*ResourceType) ForEachExtension ¶
func (t *ResourceType) ForEachExtension(callback func(extension *Schema, required bool) error) error
ForEachExtension iterates through all schema extensions and invoke the callback.
func (*ResourceType) MarshalJSON ¶
func (t *ResourceType) MarshalJSON() ([]byte, error)
func (*ResourceType) Name ¶
func (t *ResourceType) Name() string
Return the name of the resource type
func (*ResourceType) ResourceLocation ¶
func (t *ResourceType) ResourceLocation() string
ResourceLocation returns the relative URI at which this ResourceType resource can be accessed. This value is formally defined in the specification and hence fixed.
func (*ResourceType) ResourceTypeName ¶
func (t *ResourceType) ResourceTypeName() string
ResourceTypeName returns the resource type of the ResourceType resource. This value is formally defined and hence fixed.
func (*ResourceType) Schema ¶
func (t *ResourceType) Schema() *Schema
Return the main schema of the resource type
func (*ResourceType) SuperAttribute ¶
func (t *ResourceType) SuperAttribute(includeCore bool) *Attribute
SuperAttribute return a virtual complex attribute that contains all schema attributes as its sub attributes.
func (*ResourceType) UnmarshalJSON ¶
func (t *ResourceType) UnmarshalJSON(raw []byte) error
type Returned ¶
type Returned int
SCIM returned definition
SCIM returned attribute defined in RFC7643
type Schema ¶
type Schema struct {
// contains filtered or unexported fields
}
Schema models a SCIM schema. It is the collection of one or more attributes. Schema structure is read only after construction. Schema can be identified by its id, and can be cached in a schema registry.
See also:
Schemas()
Schema is currently being parsed to and from JSON via special adapters. This design is subject to change when we move to treat Schema as just another resource. See also:
issue https://github.com/imulab/go-scim/issues/40
func (*Schema) Description ¶
Description returns the human-readable text that describes the schema.
func (*Schema) ForEachAttribute ¶
ForEachAttribute iterate all attributes in this schema and invoke callback function.
func (*Schema) MarshalJSON ¶
func (*Schema) ResourceLocation ¶
ResourceLocation returns the relative URI at which this Schema resource can be accessed. This value is formally defined in the specification and hence fixed.
func (*Schema) ResourceTypeName ¶
ResourceTypeName returns the resource type of the Schema resource. This value is formally defined and hence fixed.
func (*Schema) UnmarshalJSON ¶
type ServiceProviderConfig ¶
type ServiceProviderConfig struct { Schemas []string `json:"schemas"` DocURI string `json:"documentationUri"` Patch struct { Supported bool `json:"supported"` } `json:"patch"` Bulk struct { Supported bool `json:"supported"` MaxOp int `json:"maxOperations"` MaxPayload int `json:"maxPayloadSize"` } `json:"bulk"` Filter struct { Supported bool `json:"supported"` MaxResults int `json:"maxResults"` } `json:"filter"` ChangePassword struct { Supported bool `json:"supported"` } `json:"changePassword"` Sort struct { Supported bool `json:"supported"` } `json:"sort"` ETag struct { Supported bool `json:"supported"` } `json:"etag"` AuthSchemes []struct { Type string `json:"type"` Name string `json:"name"` Description string `json:"description"` SpecURI string `json:"specUri"` DocURI string `json:"documentationUri"` } `json:"authenticationSchemes"` }
Service provider config
type Type ¶
type Type int
A SCIM data type
type Uniqueness ¶
type Uniqueness int
SCIM uniqueness definition
const ( UniquenessNone Uniqueness = iota UniquenessServer UniquenessGlobal )
SCIM uniqueness attribute defined in RFC7643
func (Uniqueness) String ¶
func (u Uniqueness) String() string