Documentation
¶
Overview ¶
Package subject maps a user's identity at an issuer, one claim and its value, to the local user it belongs to. Callers build the key from the token they hold: the upstream_subject claim of an ID-JAG from a ToolHive authorization server, or the configured binding claim of a token that an identity provider issued directly.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrUnknown means no local user matches the Ref. Callers refuse the token. ErrUnknown = errors.New("unknown subject") // ErrAmbiguous means more than one local user matches the Ref. Callers // refuse the token. Directory-backed resolvers return it; the standalone // resolver never does. ErrAmbiguous = errors.New("ambiguous subject") // server error, not invalid_grant, so the client may retry. ErrUnavailable = errors.New("subject resolver unavailable") )
var ErrInvalidBindingClaim = errors.New("invalid binding claim")
ErrInvalidBindingClaim means a configured binding claim cannot identify a local user.
Functions ¶
func ValidateBindingClaim ¶
ValidateBindingClaim checks the claim that maps a token's subject to a local user, for the token issuer named by issuer. A known mutable claim name (such as email, preferred_username, upn, unique_name or name, in any letter case), an empty claim, or a claim with surrounding whitespace is refused. A claim that passes is not proven stable: prefer sub, oid or uid. A non-empty warning means the claim is sub on an Okta custom authorization server; the caller decides how to report it.
Types ¶
type Ref ¶
type Ref struct {
// Issuer is the issuer the claim belongs to. For an upstream_subject claim
// that is the identity provider, not the server that signed the token.
Issuer string
// Claim is the name of the claim, such as "sub".
Claim string
// Value is the claim's value.
Value string
}
Ref is a lookup key for a subject: one claim, with its value, from one issuer.
It has the shape of the https://toolhive.dev/upstream_subject claim ({iss, claim, value}). From ToolHive's own record of an upstream login (session.UpstreamSubject, tokenexchange.UpstreamIdentity) it is {Issuer, StableClaim, StableValue}; the raw sub is not part of the key.