Skip to content

Commit

Permalink
Set cookie samesite to STRICT to precent CSRF
Browse files Browse the repository at this point in the history
Found by huntr.dev
  • Loading branch information
tianzhou committed Oct 18, 2021
1 parent d21ac42 commit fd1d920
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions server/jwt.go
Expand Up @@ -126,6 +126,7 @@ func setTokenCookie(c echo.Context, name, token string, expiration time.Time) {
// Http-only helps mitigate the risk of client side script accessing the protected cookie.
cookie.HttpOnly = true
cookie.Secure = true
cookie.SameSite = http.SameSiteStrictMode
c.SetCookie(cookie)
}

Expand All @@ -147,6 +148,7 @@ func setUserCookie(c echo.Context, user *api.Principal, expiration time.Time) {
cookie.Expires = expiration
cookie.Path = "/"
cookie.Secure = true
cookie.SameSite = http.SameSiteStrictMode
c.SetCookie(cookie)
}

Expand Down

0 comments on commit fd1d920

Please sign in to comment.