-
Notifications
You must be signed in to change notification settings - Fork 141
CBG-4962 create cookie with SameSite=None if CORS enabled #7841
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
Changes from 1 commit
5648c98
f9f7980
c11cfdb
a70fed4
73ac226
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -125,7 +125,11 @@ func (h *handler) makeSessionWithTTL(user auth.User, expiry time.Duration) (sess | |||||||||||||||||||||||
| if err != nil { | ||||||||||||||||||||||||
| return "", err | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
| cookie := auth.MakeSessionCookie(session, h.db.Options.SecureCookieOverride, h.db.Options.SessionCookieHttpOnly) | ||||||||||||||||||||||||
| sameSite := http.SameSiteDefaultMode | ||||||||||||||||||||||||
| if !h.getCORSConfig().IsEmpty() { | ||||||||||||||||||||||||
| sameSite = http.SameSiteNoneMode | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
| cookie := auth.MakeSessionCookie(session, h.db.Options.SecureCookieOverride, h.db.Options.SessionCookieHttpOnly, sameSite) | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
| if !h.getCORSConfig().IsEmpty() { | |
| sameSite = http.SameSiteNoneMode | |
| } | |
| cookie := auth.MakeSessionCookie(session, h.db.Options.SecureCookieOverride, h.db.Options.SessionCookieHttpOnly, sameSite) | |
| secure := h.db.Options.SecureCookieOverride | |
| if !h.getCORSConfig().IsEmpty() { | |
| sameSite = http.SameSiteNoneMode | |
| // When SameSite=None, Secure must be true for browser compatibility. | |
| secure = true | |
| } | |
| cookie := auth.MakeSessionCookie(session, secure, h.db.Options.SessionCookieHttpOnly, sameSite) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had to go verify that http.Cookie doesn't emit the SameSite attribute when SameSiteDefaultMode is specified, to ensure we won't see any functional change for users not using CORS or setting the flag.
It's possible that's worth mentioning the default handling in a function description comment, to make that clear. (on the fence about the necessity of that, take it or leave it)