aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2020-11-05 10:35:27 -0500
committerDrew DeVault <sir@cmpwn.com>2020-11-05 10:35:27 -0500
commit5a8d1572b1297c3a72fd33ee42d15e6368a52936 (patch)
tree2e412767b64d54f7d1722cdb18eb9a7fc7625953
parent643047402d0f19965b768b44dbb070148fa2977f (diff)
downloadalps-5a8d1572b1297c3a72fd33ee42d15e6368a52936.tar.gz
alps-5a8d1572b1297c3a72fd33ee42d15e6368a52936.zip
Set SameSite and Secure on cookies
-rw-r--r--server.go5
1 files changed, 4 insertions, 1 deletions
diff --git a/server.go b/server.go
index 7a82d35..759a9bb 100644
--- a/server.go
+++ b/server.go
@@ -265,7 +265,8 @@ func (ctx *Context) SetSession(s *Session) {
cookie := http.Cookie{
Name: cookieName,
HttpOnly: true,
- // TODO: domain, secure
+ SameSite: http.SameSiteStrictMode,
+ Secure: ctx.IsTLS(),
}
if s != nil {
cookie.Value = s.token
@@ -285,6 +286,8 @@ func (ctx *Context) SetLoginToken(username, password string) {
Expires: time.Now().Add(30 * 24 * time.Hour),
Name: loginTokenCookieName,
HttpOnly: true,
+ SameSite: http.SameSiteStrictMode,
+ Secure: ctx.IsTLS(),
Path: "/login",
}
if username == "" {