header

package
v4.2.14-rc0 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: GPL-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package header implements the in-tree authorizer that reads the scope of a request from a header set by a trusted gateway. It is exactly as safe as the network path in front of it: the gateway must strip or replace the scope header on every client-reachable path

Index

Constants

View Source
const (
	// Type is the name the authorizer is registered under
	Type = "header"

	// DefaultScopeHeader is the header carrying the comma-separated host IDs of the scope
	DefaultScopeHeader = "X-GoProbe-Allowed-Hosts"

	// DefaultPrincipalHeader is the header carrying the principal
	DefaultPrincipalHeader = "X-GoProbe-Principal"

	// UnknownPrincipal is reported when the principal header is absent or empty
	UnknownPrincipal = "unknown"

	// MaxPrincipalLength is the number of runes a principal is capped at before it is stored
	// and logged
	MaxPrincipalLength = 256
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Authorizer

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

Authorizer reads the scope and the principal of a request from gateway-set headers

func New

func New(cfgPath string) (*Authorizer, error)

New loads the config file at cfgPath and returns the authorizer it describes

func NewFromConfig

func NewFromConfig(cfg Config) (*Authorizer, error)

NewFromConfig returns the authorizer described by cfg

func (*Authorizer) Authorize

func (a *Authorizer) Authorize(_ context.Context, req authz.Request) (authz.Scope, error)

Authorize turns the scope header into a Scope. A scope header that is missing, empty or present more than once is forbidden: a gateway that appends instead of replacing the header must not let a client-set value through

type Config

type Config struct {
	// Trusted acknowledges that clients cannot set the scope header. The authorizer refuses
	// to initialise unless it is true
	Trusted bool `yaml:"trusted"`

	// ScopeHeader names the header carrying the scope. Empty: DefaultScopeHeader
	ScopeHeader string `yaml:"scope_header"`

	// PrincipalHeader names the header carrying the principal. Empty: DefaultPrincipalHeader
	PrincipalHeader string `yaml:"principal_header"`
}

Config is the file schema of the header authorizer

Jump to

Keyboard shortcuts

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