oidc

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: May 1, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrUnauthorized = errors.New("unauthorized")

Functions

This section is empty.

Types

type AdminRule added in v0.3.3

type AdminRule struct {
	Key   string
	Value string
}

AdminRule describes the JWT claim that grants admin access. A principal is admin when the claim named Key equals Value.

type AuthHeader added in v0.3.3

type AuthHeader string

AuthHeader is the value of the HTTP Authorization header passed to Authenticate.

type Config

type Config struct {
	Issuer    string
	Audience  string
	JWKSURL   string
	AdminRule AdminRule
}

type Principal

type Principal struct {
	Subject string
	Claims  map[string]any
	IsAdmin bool
}

type StaticTokenValidator

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

StaticTokenValidator authenticates requests using a single shared secret token. Every valid request is assigned a fixed subject ("static") with admin privileges.

This is intentionally simple — suitable for single-operator evaluation and trusted internal networks. Use OIDC (Validator) for multi-user environments.

func NewStaticToken

func NewStaticToken(token string) *StaticTokenValidator

NewStaticToken creates a StaticTokenValidator. token must be non-empty.

func (*StaticTokenValidator) Authenticate

func (v *StaticTokenValidator) Authenticate(_ context.Context, h AuthHeader) (*Principal, error)

Authenticate accepts "Bearer <token>" where token matches the configured static secret. Emits a startup-style warning on every successful auth to remind operators to migrate to OIDC.

type Validator

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

func New

func New(cfg Config) *Validator

func (*Validator) Authenticate

func (v *Validator) Authenticate(ctx context.Context, h AuthHeader) (*Principal, error)

Jump to

Keyboard shortcuts

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