middleware

package
v0.0.7 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuthN

func AuthN(verifier TokenVerifier) func(http.HandlerFunc) http.HandlerFunc

AuthN returns an HTTP middleware that verifies a locally issued JWT, extracts the embedded session and user claims, and rejects revoked or expired sessions or users. If any check fails, a 401 Unauthorized response is returned with a WWW-Authenticate header containing the error details.

func ClaimsFromContext

func ClaimsFromContext(ctx context.Context) map[string]any

ClaimsFromContext returns JWT claims stored by the auth middleware.

func NewBearerAuth

func NewBearerAuth(verifier TokenVerifier) *bearerAuth

func NewMiddleware

func NewMiddleware(verifier TokenVerifier) func(http.HandlerFunc) http.HandlerFunc

NewMiddleware is kept as a compatibility wrapper for existing callers.

func SessionFromContext

func SessionFromContext(ctx context.Context) *schema.Session

SessionFromContext returns the authenticated session stored by the auth middleware.

func UserFromContext

func UserFromContext(ctx context.Context) *schema.User

UserFromContext returns the authenticated user stored by the auth middleware.

Types

type Policy

type Policy interface {
	MatchUser(*schema.User) error
}

A policy object is used to implement authorization checks on the user

func MatchScopes

func MatchScopes(required ...string) Policy

type TokenVerifier

type TokenVerifier interface {
	Issuer() (string, error)
	OIDCVerify(token, issuer string) (map[string]any, error)
}

TokenVerifier validates and decodes a bearer JWT token.

Jump to

Keyboard shortcuts

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