Skip to content

Commit 6bbdd3d

Browse files
committed
minor: sessions: set SameSite to Lax when sharable with subdomains is not disabled.
1 parent c781be7 commit 6bbdd3d

File tree

4 files changed

+7
-3
lines changed

4 files changed

+7
-3
lines changed

_examples/file-server/embedding-files-into-app/main_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func (r resource) loadFromBase(dir string) string {
5454
result := string(b)
5555

5656
if runtime.GOOS != "windows" {
57-
// result = strings.Replace(result, "\n", "\r\n", -1)
57+
result = strings.Replace(result, "\n", "\r\n", -1)
5858
}
5959
return result
6060
}

_examples/file-server/embedding-gziped-files-into-app/main_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func (r resource) loadFromBase(dir string) string {
5555
result := string(b)
5656

5757
if runtime.GOOS != "windows" {
58-
// result = strings.Replace(result, "\n", "\r\n", -1)
58+
result = strings.Replace(result, "\n", "\r\n", -1)
5959
}
6060
return result
6161
}

_examples/file-server/single-page-application/embedded-single-page-application/main_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func (r resource) loadFromBase(dir string) string {
4747
}
4848
result := string(b)
4949
if runtime.GOOS != "windows" {
50-
// result = strings.Replace(result, "\n", "\r\n", -1)
50+
result = strings.Replace(result, "\n", "\r\n", -1)
5151
}
5252
return result
5353
}

sessions/sessions.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ func (s *Sessions) updateCookie(ctx context.Context, sid string, expires time.Du
4545
cookie.Path = "/"
4646
cookie.Domain = formatCookieDomain(ctx, s.config.DisableSubdomainPersistence)
4747
cookie.HttpOnly = true
48+
if !s.config.DisableSubdomainPersistence {
49+
cookie.SameSite = http.SameSiteLaxMode // allow subdomain sharing.
50+
}
51+
4852
// MaxAge=0 means no 'Max-Age' attribute specified.
4953
// MaxAge<0 means delete cookie now, equivalently 'Max-Age: 0'
5054
// MaxAge>0 means Max-Age attribute present and given in seconds

0 commit comments

Comments
 (0)