clerk

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HealthChecker

func HealthChecker(cfg Config, client *http.Client) ports.HealthChecker

HealthChecker returns a Clerk JWKS health checker or nil when disabled.

func WithSubject

func WithSubject(ctx context.Context, subj Subject) context.Context

WithSubject stores an authenticated subject in context.

Types

type Config

type Config struct {
	Enabled             bool
	JWKSURL             string
	Issuer              string
	Audience            string
	AllowedClockSkew    time.Duration
	JWKSRefreshTimeout  time.Duration
	JWKSRefreshInterval time.Duration
	SkipHeaderEnabled   bool
	SkipHeaderName      string
}

Config controls Clerk JWT validation.

func LoadConfig

func LoadConfig(loader *config.Loader) Config

LoadConfig reads Clerk config from environment.

type Middleware

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

Middleware validates Clerk-issued JWTs and stores the subject.

func NewMiddleware

func NewMiddleware(ctx context.Context, cfg Config, log ports.Logger) (*Middleware, error)

NewMiddleware creates a middleware instance.

func (*Middleware) Handler

func (m *Middleware) Handler(next http.Handler) http.Handler

Handler returns the http middleware.

func (*Middleware) OptionalHandler

func (m *Middleware) OptionalHandler(next http.Handler) http.Handler

OptionalHandler attaches a subject when a valid token is present, but allows requests without authentication to continue.

type Subject

type Subject struct {
	UserID   string
	Email    string
	First    string
	Last     string
	Language string
}

Subject contains the identity extracted from Clerk tokens.

func SubjectFromContext

func SubjectFromContext(ctx context.Context) (Subject, bool)

SubjectFromContext returns the subject if present.

Jump to

Keyboard shortcuts

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