Documentation
¶
Overview ¶
Package httpsec holds the Secure cookie rewriting and the Origin allowlist check.
Index ¶
Constants ¶
const SecureCookieAttr = "Secure"
SecureCookieAttr is the cookie attribute CookieWriter appends.
Variables ¶
This section is empty.
Functions ¶
func NormalizeOrigins ¶
NormalizeOrigins canonicalizes Config.TrustedOrigins entries.
func OriginAllowed ¶
OriginAllowed implements the CSRF defence for cookie-authenticated state-changing requests. Safe methods and bearer-token requests are exempt. A request that carries cookies must present an Origin (or Referer) in the trusted set; with neither header, Sec-Fetch-Site decides when the browser sent it. SameSite=Lax alone does not stop sibling subdomains, which are same-site.
Types ¶
type CookieWriter ¶
type CookieWriter struct {
http.ResponseWriter
// contains filtered or unexported fields
}
CookieWriter adds the Secure attribute to every Set-Cookie header at write time, so handlers in internal packages need no per-request flag.
func NewCookieWriter ¶
func NewCookieWriter(w http.ResponseWriter) *CookieWriter
NewCookieWriter wraps w so every Set-Cookie carries Secure.
func (*CookieWriter) Flush ¶
func (w *CookieWriter) Flush()
func (*CookieWriter) Unwrap ¶
func (w *CookieWriter) Unwrap() http.ResponseWriter
Unwrap lets http.ResponseController reach Hijack and deadlines.
func (*CookieWriter) WriteHeader ¶
func (w *CookieWriter) WriteHeader(code int)