Skip to content

Make JWT HTTPOnly again #138

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion api/handler/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func SetJWTCookie(c echo.Context, jwt service.JWT) error {
cookie := new(http.Cookie)
cookie.Name = "StringJWT"
cookie.Value = jwt.Token
// cookie.HttpOnly = true // due the short expiration time it is not needed to be http only
cookie.HttpOnly = true
cookie.Expires = jwt.ExpAt // we want the cookie to expire at the same time as the token
cookie.SameSite = getCookieSameSiteMode()
cookie.Path = "/" // Send cookie in every sub path request
Expand Down Expand Up @@ -60,6 +60,7 @@ func DeleteAuthCookies(c echo.Context) error {
cookie := new(http.Cookie)
cookie.Name = "StringJWT"
cookie.Value = ""
cookie.HttpOnly = true
cookie.Expires = time.Now()
cookie.SameSite = getCookieSameSiteMode()
cookie.Path = "/" // Send cookie in every sub path request
Expand All @@ -69,6 +70,7 @@ func DeleteAuthCookies(c echo.Context) error {
cookie = new(http.Cookie)
cookie.Name = "refresh_token"
cookie.Value = ""
cookie.HttpOnly = true
cookie.Expires = time.Now()
cookie.SameSite = getCookieSameSiteMode()
cookie.Path = "/login/" // Send cookie only in refresh path request
Expand Down