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
- func BaseURL(serverURL string) string
- func IsConnectionPrincipal(u user.Info) bool
- func IsSCIMPath(path string) bool
- func WriteError(w http.ResponseWriter, status int, detail string)
- func WriteUnauthorized(w http.ResponseWriter)
- func WriteUnavailable(w http.ResponseWriter, detail string)
- type Authenticator
- type ConfiguredAuthProviderGetter
- type Environment
- type Error
- type Handler
- type UnavailableError
Constants ¶
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 ¶
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 ¶
IsConnectionPrincipal reports whether a principal is a SCIM connection's, whose UID is the connection ID.
func IsSCIMPath ¶
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.
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.
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
Source Files
¶
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. |