Documentation
¶
Overview ¶
Package origins reads the browser origins: the CORS settings every environment shares and, for each environment, its hosts and the browser origins it admits. They are written in the proxyfile, or in an origins file it names.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PatternPCRE ¶ added in v2.2.0
PatternPCRE is the PCRE2 expression of an origin pattern, which takes what PatternRegex takes. PatternRegex reads each * as .*, which PCRE2 tries at every length when the text does not match: 64 patterns of two * each stopped HAProxy 3.2.26 and 3.4.7 with one Origin of 8 KB, and held a worker of nginx 1.30.6 and 1.31.8 for 17 to 30 s with one of 6,321 bytes (measured). A text matches the pattern when it starts with the part before the first *, ends with the part after the last, and holds each part between them in order; the first place of each such part leaves the most room to the others, so each is matched there by an atomic group, which PCRE2 never tries again elsewhere, and the time grows with the Origin's length alone.
func PatternRegex ¶
PatternRegex keeps the meaning a Spring allowed-origin-pattern has: every character literal but *, which matches any run, dots included.
func SameOriginRegex ¶
SameOriginRegex admits the service's own origin on one of its hosts, on either scheme and any port.
Types ¶
type CORS ¶
type CORS struct {
AllowMethods, AllowHeaders, ExposeHeaders, MaxAge string
KeyPos map[string]model.Pos
}
CORS is the cors key: each value "" when not written. KeyPos is where each written key is, by its path (cors.max_age), which a generator names a value's refusal by, so that it points at the value's own key: in block style the cors mapping starts on its first key's line, another key's for every value but the first. KeyPos is nil when cors is not written.
type Environment ¶
type Environment struct {
Name string
Hosts, Origins, Patterns []string // nil when not written or empty
Pos model.Pos // the environment's mapping in an origins file; its key in the proxyfile
}
func (Environment) Listed ¶ added in v2.2.0
func (e Environment) Listed() bool
Listed says whether the environment admits origins by a list, origins or patterns: only such an environment answers a browser with CORS headers, so each generator writes those lines for it alone.
type File ¶
type File struct {
CORS CORS
Environments []Environment // written order
}
File is the origins after reading, from either place, with every rule below checked.
func Inline ¶
Inline reads the origins written in the proxyfile: environments is its origins mapping, which the format check accepted, and cors its cors mapping, or nil when not written. Each entry is one environment, named by its key.
func Read ¶
Read reads the origins file at path, which is JSON read as YAML so that a problem names its line. It returns the origins and the tree the format check accepted, in which render.Read finds the keys its target refuses, or the problems of the first step that finds any: reading the file, its syntax, the format check, then the rules below.