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
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
Click to show internal directories.
Click to hide internal directories.