sessionlabel

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package sessionlabel provides a framework-neutral trusted edge adapter for pseudonymising an application session before nginx writes access logs.

Index

Constants

View Source
const (
	HeaderName      = "X-Isutools-Session"
	EnvSourceCookie = "ISUTOOLS_SESSION_COOKIE"
	EnvHMACKey      = "ISUTOOLS_SESSION_HMAC_KEY"
	MinKeyBytes     = 32
	LabelBytes      = 18
	MaxSourceBytes  = 4096
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Adapter

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

Adapter is immutable and safe for concurrent requests.

func FromEnv

func FromEnv(getenv func(string) string) *Adapter

FromEnv resolves the adapter without retaining the getenv callback.

func New

func New(cookieName string, key []byte) *Adapter

New validates the source cookie and HMAC key. Invalid configuration is a fail-closed adapter that strips spoofed labels but emits no replacement.

func (*Adapter) Health

func (a *Adapter) Health() Health

func (*Adapter) Label

func (a *Adapter) Label(source string) (string, bool)

Label returns a fixed-length URL-safe pseudonym. False means fail closed.

func (*Adapter) Middleware

func (a *Adapter) Middleware(next http.Handler) http.Handler

Middleware always removes an untrusted client label. When the configured source cookie is present, it writes only its pseudonym to the trusted upstream response header consumed by nginx.

type Health

type Health struct {
	Enabled bool   `json:"enabled"`
	Reason  string `json:"reason"`
}

Health is bounded configuration state. It never includes a cookie, key, or raw environment value.

Jump to

Keyboard shortcuts

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