devheaders

package
v2.1.0 Latest Latest
Warning

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

Go to latest
Published: May 2, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package devheaders provides development-only debug auth header middleware.

The middleware is disabled by default and requires explicit dangerous-bypass opt-in plus trusted-proxy configuration before it honors debug identity headers. Do not use it as production authentication.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Enabled         bool
	UserIDHeader    string
	EmailHeader     string
	FirstNameHeader string
	LastNameHeader  string
	DefaultLanguage string
	// AllowDangerousDevBypasses must be explicitly enabled for debug-header auth.
	AllowDangerousDevBypasses bool
	// TrustedProxies is a comma-separated list of direct peers allowed to supply
	// debug auth headers.
	TrustedProxies string
}

Config controls dev header-based auth.

func LoadConfig

func LoadConfig(loader *config.Loader) Config

LoadConfig reads dev-auth header config from environment.

type Middleware

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

Middleware injects an auth subject in local environments without a JWT provider.

func New

func New(cfg Config, log ports.Logger) (*Middleware, error)

New constructs the middleware.

func (*Middleware) Handler

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

Handler attaches a subject from debug headers if JWT auth is disabled.

func (*Middleware) OptionalHandler

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

OptionalHandler attaches a subject from debug headers if present, otherwise allows anonymous access.

Jump to

Keyboard shortcuts

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