Skip to content

Commit

Permalink
Set SameSite=Lax for cookie, fix rarely infinity redirect with SSO
Browse files Browse the repository at this point in the history
  • Loading branch information
Jipok committed Feb 14, 2024
1 parent 872ba20 commit 3361b44
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions auth-handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,14 @@ func SSO3(w http.ResponseWriter, req *http.Request) bool {
}
// We give the user an authorization token from another domain
// TODO no 3th redirect
http.SetCookie(w, &http.Cookie{Name: "jauth_token", Value: parts[0], HttpOnly: true, SameSite: http.SameSiteStrictMode, Path: "/"})
http.SetCookie(w, &http.Cookie{
Name: "jauth_token",
Value: parts[0],
HttpOnly: true,
Secure: true,
SameSite: http.SameSiteLaxMode,
Path: "/",
})
// Redirect to the user's original page
http.Redirect(w, req, url, http.StatusFound)
return true
Expand Down Expand Up @@ -373,7 +380,7 @@ func provideCookieWithNewToken(w http.ResponseWriter, req *http.Request, usernam
Value: token,
HttpOnly: true,
Secure: true,
SameSite: http.SameSiteStrictMode,
SameSite: http.SameSiteLaxMode,
Path: "/",
})
// MaxAge: -1 mean deleting cookie
Expand Down

0 comments on commit 3361b44

Please sign in to comment.