Ver Fonte

Set cookie attribute SameSite to strict mode

Frédéric Guillot há 7 anos atrás
pai
commit
88e81d4d80
1 ficheiros alterados com 2 adições e 0 exclusões
  1. 2 0
      http/cookie/cookie.go

+ 2 - 0
http/cookie/cookie.go

@@ -27,6 +27,7 @@ func New(name, value string, isHTTPS bool, path string) *http.Cookie {
 		Secure:   isHTTPS,
 		HttpOnly: true,
 		Expires:  time.Now().Add(cookieDuration * 24 * time.Hour),
+		SameSite: http.SameSiteStrictMode,
 	}
 }
 
@@ -40,6 +41,7 @@ func Expired(name string, isHTTPS bool, path string) *http.Cookie {
 		HttpOnly: true,
 		MaxAge:   -1,
 		Expires:  time.Date(1970, 1, 1, 0, 0, 0, 0, time.UTC),
+		SameSite: http.SameSiteStrictMode,
 	}
 }