Skip to content

Commit 6af3b52

Browse files
committed
Set cookies to SameSiteStrictMode, set OAuth cookie to SameSiteLaxMode
1 parent a3cbfd4 commit 6af3b52

3 files changed

Lines changed: 5 additions & 4 deletions

File tree

internal/webserver/authentication/csrftoken/CsrfToken.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ var cleanupOnce sync.Once
1414
const ttl = 5 * time.Minute
1515

1616
const (
17-
TypeLogin = iota
18-
TypeApiToken
17+
TypeLogin = iota
18+
TypeApiToken // currently not used
1919
)
2020

2121
type csrfToken struct {
@@ -45,7 +45,7 @@ func IsValid(tokenType int, tokenId string) bool {
4545
if !ok {
4646
return false
4747
}
48-
delete(tokens, tokenId)
48+
delete(tokens, tokenId) //always deletes token, even if it was wrong type
4949
if token.Type != tokenType {
5050
return false
5151
}

internal/webserver/authentication/oauth/Oauth.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ func setCallbackCookie(w http.ResponseWriter, value string) {
119119
Value: value,
120120
MaxAge: int(time.Hour.Seconds()),
121121
HttpOnly: true,
122+
SameSite: http.SameSiteLaxMode,
122123
}
123124
http.SetCookie(w, c)
124125
}

internal/webserver/authentication/sessionmanager/SessionManager.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ func writeSessionCookie(w http.ResponseWriter, sessionString string, expiry time
8888
Value: sessionString,
8989
Expires: expiry,
9090
HttpOnly: true,
91-
SameSite: http.SameSiteLaxMode,
91+
SameSite: http.SameSiteStrictMode,
9292
}
9393
http.SetCookie(w, c)
9494
}

0 commit comments

Comments
 (0)