fix(19.3-06): production refuses an inferred insecure token cookie (WR-05)

- LoadCookieConfig refuses a Secure that resolves to false in production,
  also when inferred from an http or unset app.url, naming
  auth.cookie.secure and app.url
This commit is contained in:
Jakub Zych
2026-10-15 22:26:43 +02:00
parent e32940d90f
commit 4dae8331c5
4 changed files with 22 additions and 13 deletions

View File

@@ -52,8 +52,9 @@ type CookieConfigSource interface {
// be a valid cookie domain, so it is never dropped silently when the
// cookie is written.
// - auth.cookie.same_site: lax (default), strict or none, case-insensitive.
// - auth.cookie.secure: unset means true exactly when app.url is https; an
// explicit false is refused in the production environment.
// - auth.cookie.secure: unset means true exactly when app.url is https. In
// the production environment a Secure that resolves to false is refused,
// whether set explicitly or inferred from an http or unset app.url.
//
// same_site none without Secure is refused, as browsers drop such cookies.
// Every error names the key.
@@ -101,8 +102,11 @@ func LoadCookieConfig(src CookieConfigSource) (CookieConfig, error) {
if err != nil {
return cfg, err
}
if explicit && !secure && strings.EqualFold(strings.TrimSpace(src.Environment()), "production") {
return cfg, errors.New("bouncer: auth.cookie.secure: false is not allowed in the production environment")
if !secure && strings.EqualFold(strings.TrimSpace(src.Environment()), "production") {
if explicit {
return cfg, errors.New("bouncer: auth.cookie.secure: false is not allowed in the production environment")
}
return cfg, errors.New("bouncer: auth.cookie.secure resolves to false in the production environment: it is unset and app.url is not an https URL; set app.url to an https URL or auth.cookie.secure: true")
}
cfg.Secure = secure
if cfg.SameSite == http.SameSiteNoneMode && !cfg.Secure {