Versions in this module Expand all Collapse all v1 v1.0.0 Aug 25, 2026 Changes in this version + const MaxChallengeNameBytes + const MaxChallengeParameters + const MaxChallengeSchemeBytes + const MaxChallengeValueBytes + const MaxClaimCollection + const MaxClaimDepth + const MaxClaims + var ErrAmbiguousCredentials = errors.New("authentication: ambiguous credentials") + var ErrAuthenticationUnavailable = errors.New("authentication: validation unavailable") + var ErrCredentialsAbsent = errors.New("authentication: credentials absent") + var ErrCredentialsInvalid = errors.New("authentication: credentials invalid") + var ErrCredentialsRejected = errors.New("authentication: credentials rejected") + var ErrInvalidChallenge = errors.New("authentication: invalid challenge") + var ErrInvalidConfiguration = errors.New("authentication: invalid configuration") + var ErrInvalidPrincipal = errors.New("authentication: invalid principal") + func ContextWithPrincipal(ctx context.Context, principal Principal) context.Context + type APIKeyCredential struct + func NewAPIKeyCredential(keyID, key string) APIKeyCredential + func (APIKeyCredential) GoString() string + func (APIKeyCredential) Kind() CredentialKind + func (APIKeyCredential) String() string + func (c APIKeyCredential) Key() string + func (c APIKeyCredential) KeyID() string + type Authenticator interface + Authenticate func(context.Context, Credential) (Result, error) + type BasicCredential struct + func NewBasicCredential(username, password string) BasicCredential + func (BasicCredential) GoString() string + func (BasicCredential) Kind() CredentialKind + func (BasicCredential) String() string + func (c BasicCredential) Password() string + func (c BasicCredential) Username() string + type BearerCredential struct + func NewBearerCredential(token string) BearerCredential + func (BearerCredential) GoString() string + func (BearerCredential) Kind() CredentialKind + func (BearerCredential) String() string + func (c BearerCredential) Token() string + type Binding struct + Authenticator Authenticator + Kind CredentialKind + type Challenge struct + func NewChallenge(scheme string, parameters map[string]string) (Challenge, error) + func (c Challenge) Parameters() map[string]string + func (c Challenge) Scheme() string + type Clock interface + type Composite struct + func NewComposite(bindings []Binding) (*Composite, error) + func (c *Composite) Authenticate(ctx context.Context, credential Credential) (Result, error) + type Credential interface + Kind func() CredentialKind + type CredentialKind string + const CredentialAPIKey + const CredentialBasic + const CredentialBearer + type Event struct + Duration time.Duration + Failure FailureKind + Outcome Outcome + type Failure struct + func NewFailure(kind FailureKind, options ...FailureOption) *Failure + func (f *Failure) Challenges() []Challenge + func (f *Failure) Error() string + func (f *Failure) Is(target error) bool + func (f *Failure) Kind() FailureKind + func (f *Failure) Unwrap() error + type FailureKind string + const FailureAbsent + const FailureAmbiguous + const FailureInvalid + const FailureRejected + const FailureUnavailable + type FailureOption func(*Failure) + func WithChallenges(challenges ...Challenge) FailureOption + func WithFailureCause(cause error) FailureOption + type Instrumented struct + func NewInstrumented(authenticator Authenticator, instrumenter Instrumenter, clock Clock) (*Instrumented, error) + func (i *Instrumented) Authenticate(ctx context.Context, credential Credential) (Result, error) + type Instrumenter interface + Start func(context.Context, CredentialKind) (context.Context, func(Event)) + type Outcome string + const OutcomeAnonymous + const OutcomeAuthenticated + const OutcomeFailed + type Principal struct + func AnonymousPrincipal() Principal + func NewPrincipal(spec PrincipalSpec) (Principal, error) + func PrincipalFromContext(ctx context.Context) (Principal, bool) + func (p Principal) Audiences() []string + func (p Principal) AuthenticatedAt() time.Time + func (p Principal) Claims() map[string]any + func (p Principal) IsAnonymous() bool + func (p Principal) Issuer() string + func (p Principal) Method() string + func (p Principal) Scopes() []string + func (p Principal) Subject() string + func (p Principal) TenantHints() []string + type PrincipalSpec struct + Audiences []string + AuthenticatedAt time.Time + Claims map[string]any + Issuer string + Method string + Scopes []string + Subject string + TenantHints []string + type Result struct + func AnonymousResult() Result + func NewAuthenticatedResult(principal Principal) (Result, error) + func (r Result) Principal() (Principal, bool) + func (r Result) State() ResultState + type ResultState string + const ResultAnonymous + const ResultAuthenticated