mirror of
https://github.com/ClusterCockpit/cc-backend
synced 2026-01-28 06:51:45 +01:00
Do not warn about unencrypted auth when encrypted revsere proxy is used
This commit is contained in:
@@ -305,8 +305,13 @@ func (auth *Authentication) SaveSession(rw http.ResponseWriter, r *http.Request,
|
|||||||
if auth.SessionMaxAge != 0 {
|
if auth.SessionMaxAge != 0 {
|
||||||
session.Options.MaxAge = int(auth.SessionMaxAge.Seconds())
|
session.Options.MaxAge = int(auth.SessionMaxAge.Seconds())
|
||||||
}
|
}
|
||||||
if config.Keys.HTTPSCertFile == "" && config.Keys.HTTPSKeyFile == "" {
|
if r.TLS == nil && r.Header.Get("X-Forwarded-Proto") != "https" {
|
||||||
cclog.Warn("HTTPS not configured - session cookies will not have Secure flag set (insecure for production)")
|
// If neither TLS or an encrypted reverse proxy are used, do not mark cookies as secure.
|
||||||
|
cclog.Warn("Authenticating with unencrypted request. Session cookies will not have Secure flag set (insecure for production)")
|
||||||
|
if r.Header.Get("X-Forwarded-Proto") == "" {
|
||||||
|
// This warning will not be printed if e.g. X-Forwarded-Proto == http
|
||||||
|
cclog.Warn("If you are using a reverse proxy, make sure X-Forwarded-Proto is set")
|
||||||
|
}
|
||||||
session.Options.Secure = false
|
session.Options.Secure = false
|
||||||
}
|
}
|
||||||
session.Options.SameSite = http.SameSiteStrictMode
|
session.Options.SameSite = http.SameSiteStrictMode
|
||||||
|
|||||||
Reference in New Issue
Block a user