Skip to content

Commit

Permalink
minor: sessions: set SameSite to Lax when sharable with subdomains is…
Browse files Browse the repository at this point in the history
… not disabled.
  • Loading branch information
kataras committed Aug 16, 2019
1 parent c781be7 commit 6bbdd3d
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func (r resource) loadFromBase(dir string) string {
result := string(b)

if runtime.GOOS != "windows" {
// result = strings.Replace(result, "\n", "\r\n", -1)
result = strings.Replace(result, "\n", "\r\n", -1)
}
return result
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func (r resource) loadFromBase(dir string) string {
result := string(b)

if runtime.GOOS != "windows" {
// result = strings.Replace(result, "\n", "\r\n", -1)
result = strings.Replace(result, "\n", "\r\n", -1)
}
return result
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func (r resource) loadFromBase(dir string) string {
}
result := string(b)
if runtime.GOOS != "windows" {
// result = strings.Replace(result, "\n", "\r\n", -1)
result = strings.Replace(result, "\n", "\r\n", -1)
}
return result
}
Expand Down
4 changes: 4 additions & 0 deletions sessions/sessions.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ func (s *Sessions) updateCookie(ctx context.Context, sid string, expires time.Du
cookie.Path = "/"
cookie.Domain = formatCookieDomain(ctx, s.config.DisableSubdomainPersistence)
cookie.HttpOnly = true
if !s.config.DisableSubdomainPersistence {
cookie.SameSite = http.SameSiteLaxMode // allow subdomain sharing.
}

// MaxAge=0 means no 'Max-Age' attribute specified.
// MaxAge<0 means delete cookie now, equivalently 'Max-Age: 0'
// MaxAge>0 means Max-Age attribute present and given in seconds
Expand Down

0 comments on commit 6bbdd3d

Please sign in to comment.