client/web: add security attributes on session cookie

Limit cookies to HTTP requests (not accessible from javascript).
Set SameSite to "Lax", which is similar to "Strict" but allows for
cookies to be included in requests that come from offsite links.  This
will be necessary when we link to the web client from the admin console.

Updates #10261
Fixes tailscale/corp#16265

Signed-off-by: Will Norris <will@tailscale.com>
pull/10543/head
Will Norris 12 months ago committed by Will Norris
parent 261b6f1e9f
commit c615fe2296

@ -498,7 +498,15 @@ func (s *Server) serveAPIAuthSessionNew(w http.ResponseWriter, r *http.Request)
Value: session.ID, Value: session.ID,
Raw: session.ID, Raw: session.ID,
Path: "/", Path: "/",
HttpOnly: true,
SameSite: http.SameSiteStrictMode,
Expires: session.expires(), Expires: session.expires(),
// We can't set Secure to true because we serve over HTTP
// (but only on Tailscale IPs, hence over encrypted
// connections that a LAN-local attacker cannot sniff).
// In the future, we could support HTTPS requests using
// the full MagicDNS hostname, and could set this.
// Secure: true,
}) })
} }

Loading…
Cancel
Save