Skip to content

Commit 338dad1

Browse files
committed
feat: Auto-enforce Secure=true for Partitioned cookies in Cookie()
- Add Secure enforcement for Partitioned cookies per CHIPS spec - Update test to reflect new auto-fix behavior
1 parent 2e985d2 commit 338dad1

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

ctx_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1211,7 +1211,7 @@ func Test_Ctx_Cookie_Invalid(t *testing.T) {
12111211
{Name: "i", Value: "b", Domain: "2001:db8::1"}, // ipv6 not allowed
12121212
{Name: "p", Value: "b", Path: "\x00"}, // invalid path byte
12131213
{Name: "e", Value: "b", Expires: time.Date(1500, 1, 1, 0, 0, 0, 0, time.UTC)}, // invalid expires
1214-
{Name: "s", Value: "b", Partitioned: true}, // partitioned but not secure
1214+
// Note: Partitioned without Secure is auto-fixed (Secure=true set automatically per CHIPS spec)
12151215
}
12161216

12171217
for _, invalid := range cases {

res.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,11 @@ func (r *DefaultRes) Cookie(cookie *Cookie) {
249249
sameSite = http.SameSiteLaxMode
250250
}
251251

252+
// Partitioned requires Secure=true per CHIPS spec
253+
if cookie.Partitioned {
254+
cookie.Secure = true
255+
}
256+
252257
// create/validate cookie using net/http
253258
hc := &http.Cookie{
254259
Name: cookie.Name,

0 commit comments

Comments
 (0)