Documentation
¶
Overview ¶
Package scim is the part of SCIM 2.0 Holon needs from an identity backend: users, the groups that stand for permission sets, and what the backend can do. Resources follow the core schema of RFC 7643 and operations follow RFC 7644. Bulk (RFC 7644 §3.7), sorting (RFC 7644 §3.4.2.3), the /Schemas and /ResourceTypes endpoints (RFC 7644 §4) and the Enterprise User extension (RFC 7643 §4.3) are not needed, and Handler answers 501 for the endpoints.
Index ¶
- Variables
- func Handler(backend Backend, bearer string) http.Handler
- type Backend
- type Capabilities
- type Client
- func (c *Client) Config(ctx context.Context) (ServiceProviderConfig, error)
- func (c *Client) CreateUser(ctx context.Context, user User) (User, error)
- func (c *Client) DeleteUser(ctx context.Context, id string) error
- func (c *Client) GetUser(ctx context.Context, id string) (User, error)
- func (c *Client) ListGroups(ctx context.Context, filter Filter, start, count int) (Page[Group], error)
- func (c *Client) ListUsers(ctx context.Context, filter Filter, start, count int) (Page[User], error)
- func (c *Client) PatchGroup(ctx context.Context, id string, patch Patch) (Group, error)
- func (c *Client) PatchUser(ctx context.Context, id string, patch Patch) (User, error)
- type Email
- type Filter
- type Filtering
- type Group
- type Meta
- type Name
- type Operation
- type Page
- type Patch
- type Ref
- type ServiceProviderConfig
- type Supported
- type User
- type UserExtension
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func Handler ¶
Handler serves backend under /scim/v2 with the media type of RFC 7644 §3.1, creation per RFC 7644 §3.3, listing per RFC 7644 §3.4.2 with the pagination of RFC 7644 §3.4.2.4, PATCH per RFC 7644 §3.5.2, deletion per RFC 7644 §3.6 and errors per RFC 7644 §3.12. Every request carries the shared bearer. Read-only attributes in a request are ignored and a password is never returned, as RFC 7643 §7 requires of its mutability and returned settings.
Types ¶
type Backend ¶
type Backend interface {
Config(context.Context) (ServiceProviderConfig, error)
ListUsers(context.Context, Filter, int, int) (Page[User], error)
GetUser(context.Context, string) (User, error)
CreateUser(context.Context, User) (User, error)
PatchUser(context.Context, string, Patch) (User, error)
DeleteUser(context.Context, string) error
ListGroups(context.Context, Filter, int, int) (Page[Group], error)
PatchGroup(context.Context, string, Patch) (Group, error)
}
Backend serves the resources behind Handler. Ids are the backend's own. ListUsers and ListGroups receive a 1-based start index and a count of at most 200 (RFC 7644 §3.4.2.4). ListUsers answers ErrFilter to a Filter it cannot evaluate, and ListGroups only sees an empty Filter, because its fields are all User attributes; CreateUser is RFC 7644 §3.3 and answers ErrConflict to a taken userName; PatchUser and PatchGroup are RFC 7644 §3.5.2 and answer ErrInvalid to an operation they do not implement; DeleteUser is RFC 7644 §3.6. An unknown id is ErrNotFound.
type Capabilities ¶
type Capabilities struct {
Invitations bool `json:"invitations"`
Provider string `json:"provider,omitempty"`
}
Capabilities is read at request time: Invitations says the backend can send a setup message right now, Provider names the identity provider everyone signs in through when there is one.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client calls Handler from Holon's side and maps its responses back to the sentinel errors. An authentication failure or any other status is ErrUnavailable.
func NewClient ¶
NewClient returns a Client for the adapter at endpoint, the base URL that /scim/v2 hangs from.
func (*Client) Config ¶
func (c *Client) Config(ctx context.Context) (ServiceProviderConfig, error)
Config reads the document of RFC 7644 §4.
func (*Client) CreateUser ¶
CreateUser is RFC 7644 §3.3.
func (*Client) DeleteUser ¶
DeleteUser is RFC 7644 §3.6.
func (*Client) ListGroups ¶
func (c *Client) ListGroups(ctx context.Context, filter Filter, start, count int) (Page[Group], error)
ListGroups is RFC 7644 §3.4.2; start is 1-based. Any non-empty Filter is ErrFilter.
func (*Client) ListUsers ¶
func (c *Client) ListUsers(ctx context.Context, filter Filter, start, count int) (Page[User], error)
ListUsers is RFC 7644 §3.4.2; start is 1-based. A Filter with more than one field is ErrFilter.
func (*Client) PatchGroup ¶
PatchGroup is RFC 7644 §3.5.2.
type Filter ¶
Filter is the subset of the RFC 7644 §3.4.2.2 grammar Holon sends: userName eq "…", emails.value eq "…" or groups.value eq "<group id>", one at a time. Anything else is ErrFilter, which Handler answers with the invalidFilter scimType of RFC 7644 §3.12.
type Group ¶
type Group struct {
ID string `json:"id"`
ExternalID string `json:"externalId"`
DisplayName string `json:"displayName"`
Members []Ref `json:"members,omitempty"`
Meta Meta `json:"meta"`
}
Group is the core Group resource of RFC 7643 §4.2. Every Holon permission set is one Group: ExternalID is "<kind>/<uid>" and DisplayName is "<kind> <uid>", both derived and read-only. Registration creates groups; Holon only reads them and changes their members.
type Meta ¶
type Meta struct {
ResourceType string `json:"resourceType,omitempty"`
Created time.Time `json:"created,omitzero"`
LastModified time.Time `json:"lastModified,omitzero"`
}
Meta is the meta attribute of RFC 7643 §3.1.
type Name ¶
type Name struct {
GivenName string `json:"givenName,omitempty"`
FamilyName string `json:"familyName,omitempty"`
}
Name is the name attribute of RFC 7643 §4.1.1.
type Operation ¶
type Operation struct {
Op string `json:"op"`
Path string `json:"path,omitempty"`
Value json.RawMessage `json:"value,omitempty"`
}
Operation is one operation of RFC 7644 §3.5.2; Op is add, remove or replace.
type Page ¶
type Page[T any] struct { TotalResults int `json:"totalResults"` StartIndex int `json:"startIndex"` ItemsPerPage int `json:"itemsPerPage"` Resources []T `json:"Resources"` }
Page is the ListResponse of RFC 7644 §3.4.2 with the index pagination of RFC 7644 §3.4.2.4: StartIndex is 1-based and Handler caps the requested count at 200. A Backend fills TotalResults and Resources, and Handler the rest.
type Patch ¶
type Patch struct {
Operations []Operation `json:"Operations"`
}
Patch is the PatchOp of RFC 7644 §3.5.2. Holon sends five shapes: replace active, replace name, replace password, add members and remove members[value eq "<user id>"].
type Ref ¶
Ref is a reference to another resource as in the groups attribute of RFC 7643 §4.1.2 and the members attribute of RFC 7643 §4.2: Value is the referenced resource's id and Display its displayName.
type ServiceProviderConfig ¶
type ServiceProviderConfig struct {
Schemas []string `json:"schemas"`
Patch Supported `json:"patch"`
Bulk Supported `json:"bulk"`
Filter Filtering `json:"filter"`
ChangePassword Supported `json:"changePassword"`
Sort Supported `json:"sort"`
ETag Supported `json:"etag"`
Holon Capabilities `json:"urn:holon:params:scim:schemas:extension:capabilities:1.0"`
}
ServiceProviderConfig is RFC 7643 §5 plus Holon's capabilities extension. Handler sets Schemas, so a backend leaves it empty.
type Supported ¶
type Supported struct {
Supported bool `json:"supported"`
}
Supported is a boolean capability of RFC 7643 §5.
type User ¶
type User struct {
ID string `json:"id"` // RFC 7643 §3.1
ExternalID string `json:"externalId,omitempty"` // RFC 7643 §3.1
UserName string `json:"userName"` // RFC 7643 §4.1.1
Name *Name `json:"name,omitempty"` // RFC 7643 §4.1.1
Emails []Email `json:"emails,omitempty"` // RFC 7643 §4.1.2
Active bool `json:"active"` // RFC 7643 §4.1.1
Password string `json:"password,omitempty"` // RFC 7643 §4.1.1
Groups []Ref `json:"groups,omitempty"` // RFC 7643 §4.1.2
Holon *UserExtension `json:"urn:holon:params:scim:schemas:extension:user:1.0,omitempty"`
Meta Meta `json:"meta"` // RFC 7643 §3.1
}
User is the core User resource of RFC 7643 §4.1 limited to what Holon reads or writes, plus one Holon extension schema as RFC 7643 §3.3 allows. Holon sets userName to the email address. Password is write-only and temporary; Groups is read-only.
type UserExtension ¶
type UserExtension struct {
PendingSetup bool `json:"pendingSetup"`
}
UserExtension is Holon's read-only extension to User: PendingSetup is true until the person has chosen their own password.