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) Capabilities(ctx context.Context) (Capabilities, error)
- func (c *Client) CreateGroup(ctx context.Context, set identity.PermissionSet) (Group, 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) FindUser(ctx context.Context, userName string) (User, error)
- func (c *Client) GetUser(ctx context.Context, id string) (User, error)
- func (c *Client) ListGroups(ctx context.Context, start, count int) (Page[Group], error)
- func (c *Client) ListUsers(ctx context.Context, 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 Group
- type Meta
- type Name
- type Operation
- type Page
- type Patch
- type Ref
- 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 {
Capabilities(context.Context) (Capabilities, error)
ListUsers(context.Context, int, int) (Page[User], error)
FindUser(context.Context, string) (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, int, int) (Page[Group], error)
CreateGroup(context.Context, identity.PermissionSet) (Group, error)
PatchGroup(context.Context, string, Patch) (Group, error)
}
Backend serves the resources behind Handler, which parses and answers the wire. 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); FindUser answers the one person whose userName is exact, and CreateUser is RFC 7644 §3.3 and answers ErrConflict to a taken userName; CreateGroup is RFC 7644 §3.3 and answers ErrConflict to a taken set; 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) Capabilities ¶
func (c *Client) Capabilities(ctx context.Context) (Capabilities, error)
Capabilities reads Holon's extension of the document of RFC 7644 §4.
func (*Client) CreateGroup ¶
CreateGroup is RFC 7644 §3.3.
func (*Client) CreateUser ¶
CreateUser is RFC 7644 §3.3.
func (*Client) DeleteUser ¶
DeleteUser is RFC 7644 §3.6.
func (*Client) FindUser ¶
FindUser is the userName eq filter of RFC 7644 §3.4.2.2; userName is unique, so nobody is ErrNotFound.
func (*Client) ListGroups ¶
ListGroups is RFC 7644 §3.4.2; start is 1-based.
func (*Client) PatchGroup ¶
PatchGroup is RFC 7644 §3.5.2.
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>", derived and read-only.
func (Group) PermissionSet ¶
func (g Group) PermissionSet() (identity.PermissionSet, error)
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 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.