scim

package
v0.3.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 18, 2026 License: MIT Imports: 10 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package scim implements a minimal SCIM 2.0 provisioning client. idpzero acts as the SCIM client and pushes its configured users to an external SCIM service (the service provider). Only the User resource is supported.

Index

Constants

View Source
const (
	ActionCreated = "created"
	ActionUpdated = "updated"
	ActionFailed  = "failed"
)

Action describes what happened to a single user during a sync.

View Source
const (
	UserSchema  = "urn:ietf:params:scim:schemas:core:2.0:User"
	ListSchema  = "urn:ietf:params:scim:api:messages:2.0:ListResponse"
	ErrorSchema = "urn:ietf:params:scim:api:messages:2.0:Error"

	// ContentType is the media type SCIM uses for request and response bodies.
	ContentType = "application/scim+json"
)

SCIM schema URNs (RFC 7643 / 7644).

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is a minimal SCIM 2.0 client for the User resource. It targets a single service provider identified by its base URL (e.g. https://host/scim/v2).

func New

func New(endpoint, token string) *Client

New builds a SCIM client for the given endpoint. token is optional; when empty no Authorization header is sent.

func (*Client) Create

func (c *Client) Create(ctx context.Context, user User) (*User, error)

Create provisions a new user on the target.

func (*Client) FindByExternalID

func (c *Client) FindByExternalID(ctx context.Context, externalID string) (*User, error)

FindByExternalID looks up a user by its externalId, returning nil when no match exists. idpzero sets externalId to the user's Subject.

func (*Client) Replace

func (c *Client) Replace(ctx context.Context, id string, user User) (*User, error)

Replace overwrites an existing user (identified by its service-provider id).

type Email

type Email struct {
	Value   string `json:"value"`
	Type    string `json:"type,omitempty"`
	Primary bool   `json:"primary,omitempty"`
}

Email is a single SCIM multi-valued "emails" entry.

type ErrorResponse

type ErrorResponse struct {
	Schemas []string `json:"schemas"`
	Detail  string   `json:"detail"`
	Status  string   `json:"status"`
}

ErrorResponse is the SCIM error envelope returned on non-2xx responses.

type ListResponse

type ListResponse struct {
	Schemas      []string `json:"schemas"`
	TotalResults int      `json:"totalResults"`
	Resources    []User   `json:"Resources"`
}

ListResponse is the SCIM envelope returned by query/list operations.

type Name

type Name struct {
	Formatted  string `json:"formatted,omitempty"`
	GivenName  string `json:"givenName,omitempty"`
	MiddleName string `json:"middleName,omitempty"`
	FamilyName string `json:"familyName,omitempty"`
}

Name is the SCIM complex "name" attribute.

type PhoneNumber

type PhoneNumber struct {
	Value   string `json:"value"`
	Type    string `json:"type,omitempty"`
	Primary bool   `json:"primary,omitempty"`
}

PhoneNumber is a single SCIM multi-valued "phoneNumbers" entry.

type Report

type Report struct {
	RanAt    time.Time
	Endpoint string
	Results  []Result
	Failed   int
}

Report is the outcome of a full sync run.

func Sync

func Sync(ctx context.Context, c syncClient, endpoint string, users []*configuration.User) Report

Sync reconciles the given users against the target: each user is looked up by externalId and either created (when absent) or replaced (when present). A failure on one user is recorded and does not abort the run. RanAt is left zero for the caller to stamp.

type Result

type Result struct {
	Subject  string
	UserName string
	Action   string // created | updated | failed
	Err      string // populated when Action == failed
}

Result is the outcome of provisioning a single user.

type User

type User struct {
	Schemas      []string      `json:"schemas"`
	ID           string        `json:"id,omitempty"`         // assigned by the service provider
	ExternalID   string        `json:"externalId,omitempty"` // idpzero's stable subject
	UserName     string        `json:"userName"`
	DisplayName  string        `json:"displayName,omitempty"`
	Name         *Name         `json:"name,omitempty"`
	Emails       []Email       `json:"emails,omitempty"`
	PhoneNumbers []PhoneNumber `json:"phoneNumbers,omitempty"`
	Active       bool          `json:"active"`
}

User is a SCIM 2.0 core User resource. Only the subset of attributes idpzero can populate from its configured users is modelled here.

func ToSCIMUser

func ToSCIMUser(u *configuration.User) User

ToSCIMUser maps an idpzero configured user onto a SCIM 2.0 User resource.

The idpzero Subject is used as the SCIM externalId so provisioning is idempotent: the target is queried by externalId to decide between create and replace. Claim fields are optional pointers on the source, so every access is nil-guarded.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL