middleware

package
v0.5.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CORSMiddleware

func CORSMiddleware(config CORSConfig) func(http.Handler) http.Handler

CORSMiddleware creates a CORS middleware with the given configuration

func GetOwnerSubjectFromContext

func GetOwnerSubjectFromContext(ctx context.Context) (string, bool)

GetOwnerSubjectFromContext extracts the authenticated owner's subject (UID) from the request context

func NewCORSMiddleware

func NewCORSMiddleware(allowedOrigins string) func(http.Handler) http.Handler

NewCORSMiddleware creates a CORS middleware with default configuration

func WithOwnerSubject added in v0.5.0

func WithOwnerSubject(ctx context.Context, subject string) context.Context

WithOwnerSubject returns a copy of ctx carrying the authenticated owner's subject (UID)

Types

type CORSConfig

type CORSConfig struct {
	AllowedOrigins   []string
	AllowedMethods   []string
	AllowedHeaders   []string
	ExposedHeaders   []string
	AllowCredentials bool
	MaxAge           int
}

CORSConfig holds the CORS configuration

func DefaultCORSConfig

func DefaultCORSConfig(allowedOrigins string) CORSConfig

DefaultCORSConfig returns the default CORS configuration. The allowed origins can be overridden by setting the CORS_ALLOWED_ORIGINS environment variable (comma-separated).

type JWTAuthMiddleware

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

JWTAuthMiddleware provides HTTP middleware for JWT authentication

func NewJWTAuthMiddleware

func NewJWTAuthMiddleware(verifier *auth.JWTVerifier) *JWTAuthMiddleware

NewJWTAuthMiddleware creates a new JWT authentication middleware

func (*JWTAuthMiddleware) Authenticate

func (m *JWTAuthMiddleware) Authenticate(next http.Handler) http.Handler

Authenticate is the middleware function that validates JWT tokens

Jump to

Keyboard shortcuts

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