middleware

package
v0.0.4 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 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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