scim

package
v0.28.0 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2026 License: MIT Imports: 30 Imported by: 0

Documentation

Overview

Package scim serves a SCIM 2.0 endpoint for an auth provider's SCIM connection, as a facade over Obot's users, identities, groups, and memberships.

Index

Constants

View Source
const (
	// PathPrefix is the path under which the SCIM connection's resources are served. There is at most one connection,
	// so its base URL names none.
	PathPrefix = "/scim/v2/"
)

Variables

This section is empty.

Functions

func BaseURL

func BaseURL(serverURL string) string

BaseURL returns the base URL of the SCIM connection, which every SCIM request is relative to. The server URL is configured by hand, so any trailing slashes on it are dropped.

func IsConnectionPrincipal

func IsConnectionPrincipal(u user.Info) bool

IsConnectionPrincipal reports whether a principal is a SCIM connection's, whose UID is the connection ID.

func IsSCIMPath

func IsSCIMPath(path string) bool

IsSCIMPath reports whether a request path is served by the SCIM endpoint: the base URL, and every path below it.

func WriteError

func WriteError(w http.ResponseWriter, status int, detail string)

WriteError writes a SCIM error response with the given status. The API server uses it for the failures it answers before a SCIM request reaches the handler, such as authentication, rate limiting, and authorization.

func WriteUnauthorized

func WriteUnauthorized(w http.ResponseWriter)

WriteUnauthorized writes the response to a SCIM request that no connection's token authenticated.

func WriteUnavailable

func WriteUnavailable(w http.ResponseWriter, detail string)

WriteUnavailable writes the response to a SCIM request while the endpoint is unavailable, because no SCIM connection exists. The identity provider records the request as a failed task. Once a connection exists, requests with an earlier connection's token answer 401.

Types

type Authenticator

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

Authenticator authenticates requests to the SCIM endpoint with the bearer token of the SCIM connection. It runs ahead of every other authenticator and ends the chain on SCIM routes, so no cookie, Obot credential, redirect, or just-in-time user creation ever applies to them. Off SCIM routes, it declines.

func NewAuthenticator

func NewAuthenticator(gateway *gclient.Client) *Authenticator

NewAuthenticator returns the SCIM authenticator.

func (*Authenticator) AuthenticateRequest

func (a *Authenticator) AuthenticateRequest(req *http.Request) (*authenticator.Response, bool, error)

AuthenticateRequest yields the principal of the SCIM connection when the request carries its current or still-accepted previous token. There is at most one connection, so the path names none. A missing or invalid token and a connection without a token yield the anonymous principal, which authorization answers with 401. Without any connection, it returns an *UnavailableError before it looks at the token, and with more than one, an error.

type ConfiguredAuthProviderGetter

type ConfiguredAuthProviderGetter interface {
	GetConfiguredAuthProvider(ctx context.Context) (string, error)
}

ConfiguredAuthProviderGetter returns the name of the auth provider that serves sign-ins.

type Environment

type Environment interface {
	// ConfiguredAuthProvider returns the namespace and name of the auth provider that serves sign-ins, or empty strings
	// when none is configured.
	ConfiguredAuthProvider(ctx context.Context) (string, string, error)
	// UserLimit returns the installation's user limit, which SCIM user creation counts against.
	UserLimit(ctx context.Context) (gclient.UserLimit, error)
	// DefaultRole returns the role of new users.
	DefaultRole(ctx context.Context) (types2.Role, error)
}

Environment answers what a SCIM request needs from outside the gateway database.

func NewEnvironment

func NewEnvironment(authProviders ConfiguredAuthProviderGetter, userLimits gclient.UserLimitProvider, storage kclient.Client) Environment

NewEnvironment returns the Environment of a running Obot server.

type Error

type Error struct {
	Status   int
	ScimType string
	Detail   string
	// contains filtered or unexported fields
}

Error is a SCIM error response, as RFC 7644 section 3.12 defines it.

func (*Error) Error

func (e *Error) Error() string

type Handler

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

Handler serves the SCIM endpoint. The API server authenticates its requests with the SCIM authenticator, which accepts only the SCIM connection's bearer token, and authorizes them only for that connection's principal, so no cookie, Obot credential, redirect, or just-in-time user creation ever reaches it.

func NewHandler

func NewHandler(gateway *gclient.Client, env Environment, serverURL string) *Handler

NewHandler returns the SCIM handler. serverURL is Obot's public URL, which resource locations are built from.

func (*Handler) Serve

func (h *Handler) Serve(req api.Context) error

ANY /scim/v2 and /scim/v2/... Serves the SCIM endpoint of the SCIM connection, routing each request by its method and path. It writes every response itself, as a SCIM response, and never returns an error.

func (*Handler) ServeHTTP

func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request, principal user.Info)

ServeHTTP handles a request that principal made. Only the principal of a SCIM connection, which the SCIM authenticator yields, is served, for that connection.

type UnavailableError

type UnavailableError struct{}

UnavailableError reports a request to the SCIM endpoint while no SCIM connection exists. The API server answers it with 503.

func (*UnavailableError) Error

func (*UnavailableError) Error() string

Directories

Path Synopsis
Package adapter holds the provider-specific rules of SCIM connections.
Package adapter holds the provider-specific rules of SCIM connections.
adaptertest
Package adaptertest provides a SCIM adapter for tests of shared code that need rules no registered adapter has.
Package adaptertest provides a SCIM adapter for tests of shared code that need rules no registered adapter has.
Package setup sets up and administers the SCIM connections of auth providers.
Package setup sets up and administers the SCIM connections of auth providers.

Jump to

Keyboard shortcuts

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