mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-13 03:24:26 +00:00
fix: set user agent cookie on host only (without subdomains) (#7297)
This PR changes the domain / prefix of the user agent cookie from including the subdomain to the domain only and therefore changing the prefix from __Secure to __Host. Note: As the cookie is used to determine existing session on the login UI, applying the change will require end-users to start a new session on the next login, since the existing ones cannot be retrieved anymore.
This commit is contained in:
parent
198bc017b8
commit
d5266ea51c
@ -147,6 +147,10 @@ func (c *CookieHandler) httpSetWithSameSite(w http.ResponseWriter, name, host, v
|
||||
secure := c.secureOnly || (sameSite == http.SameSiteNoneMode && domain == "localhost")
|
||||
// prefix the cookie for secure cookies (TLS only, therefore not for samesite none on http://localhost)
|
||||
prefixedName := SetCookiePrefix(name, c.secureOnly, c.prefix)
|
||||
// in case the host prefix is set, we need to make sure the domain is not set (otherwise the browser will reject the cookie)
|
||||
if secure && c.prefix == PrefixHost {
|
||||
domain = ""
|
||||
}
|
||||
http.SetCookie(w, &http.Cookie{
|
||||
Name: prefixedName,
|
||||
Value: value,
|
||||
|
@ -46,7 +46,7 @@ func NewUserAgentHandler(config *UserAgentCookieConfig, cookieKey []byte, idGene
|
||||
opts := []http_utils.CookieHandlerOpt{
|
||||
http_utils.WithEncryption(cookieKey, cookieKey),
|
||||
http_utils.WithMaxAge(int(config.MaxAge.Seconds())),
|
||||
http_utils.WithPrefix(http_utils.PrefixSecure),
|
||||
http_utils.WithPrefix(http_utils.PrefixHost),
|
||||
}
|
||||
if !externalSecure {
|
||||
opts = append(opts, http_utils.WithUnsecure())
|
||||
|
Loading…
Reference in New Issue
Block a user