Versions in this module Expand all Collapse all v0 v0.1.0 Jul 4, 2026 Changes in this version + var ErrInvalidSignature = errors.New("keycloakauth: invalid signature") + var ErrMalformedToken = errors.New("keycloakauth: malformed token") + var ErrMissingToken = errors.New("keycloakauth: missing bearer token") + var ErrTokenExpired = errors.New("keycloakauth: token expired") + var ErrTokenNotYetValid = errors.New("keycloakauth: token not valid yet") + var ErrUnknownKey = errors.New("keycloakauth: token signed with unknown key") + var ErrWrongAudience = errors.New("keycloakauth: wrong audience") + var ErrWrongIssuer = errors.New("keycloakauth: wrong issuer") + func NewContext(ctx context.Context, c *Claims) context.Context + func RequireClientRole(clientID, role string) func(http.Handler) http.Handler + func RequireRealmRole(role string) func(http.Handler) http.Handler + type Claims struct + Email string + Expiry time.Time + PreferredUsername string + Raw map[string]any + RealmRoles []string + Subject string + func FromContext(ctx context.Context) (*Claims, bool) + func (c *Claims) ClientRoles(clientID string) []string + func (c *Claims) HasClientRole(clientID, role string) bool + func (c *Claims) HasRealmRole(role string) bool + type Config struct + BaseURL string + Realm string + type Option func(*Verifier) + func WithAudience(aud string) Option + func WithErrorHandler(f func(http.ResponseWriter, *http.Request, error)) Option + func WithHTTPClient(h *http.Client) Option + func WithIssuer(iss string) Option + func WithLeeway(d time.Duration) Option + func WithRefetchInterval(d time.Duration) Option + type Verifier struct + func New(ctx context.Context, cfg Config, opts ...Option) (*Verifier, error) + func (v *Verifier) Middleware(next http.Handler) http.Handler + func (v *Verifier) Verify(ctx context.Context, rawToken string) (*Claims, error)