#138: add Secure attribute to viewer cookie (vwr)
This commit is contained in:
@@ -141,9 +141,12 @@ func viewerCookieMiddleware(next http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
if c, err := r.Cookie("vwr"); err != nil || c.Value == "" {
|
||||
id := store.GenSlug(16)
|
||||
// #138: Secure keeps the viewer id off plain-HTTP requests
|
||||
// (all deployments are HTTPS-only behind traefik).
|
||||
http.SetCookie(w, &http.Cookie{
|
||||
Name: "vwr", Value: id, Path: "/",
|
||||
MaxAge: 31536000, HttpOnly: true, SameSite: http.SameSiteLaxMode,
|
||||
MaxAge: 31536000, HttpOnly: true, Secure: true,
|
||||
SameSite: http.SameSiteLaxMode,
|
||||
})
|
||||
r.AddCookie(&http.Cookie{Name: "vwr", Value: id})
|
||||
// remember that this cookie was minted here, not sent by the client
|
||||
|
||||
Reference in New Issue
Block a user