middleware

package
v1.1.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func JWTMiddleware

func JWTMiddleware(config JWTMiddlewareConfig) func(http.Handler) http.Handler

JWTMiddleware creates an HTTP middleware that parses JWTs and attaches the User to the context.

func UserFromContext

func UserFromContext(ctx context.Context) (*auth.User, bool)

UserFromContext retrieves the user from the context.

func WithUser

func WithUser(ctx context.Context, user *auth.User) context.Context

WithUser adds a user to the context.

Types

type JWTMiddlewareConfig

type JWTMiddlewareConfig struct {
	// SecretKey is used to verify the JWT signature.
	SecretKey []byte
	// Strict determines if requests without a valid token are rejected.
	// If false, invalid or missing tokens just mean no User is attached to context.
	Strict bool
}

JWTMiddlewareConfig holds configuration for the JWT middleware.

Jump to

Keyboard shortcuts

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