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 is the CSRF check for cookie-authenticated unsafe requests. Safe methods and bearer requests are exempt. Otherwise Origin or Referer must be trusted, and Sec-Fetch-Site decides when neither is sent. SameSite=Lax alone does not stop sibling subdomains.
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)