Skip to content

Commit 061540b

Browse files
Cloudfront - add expire time in signed cookie. (#2862)
1 parent aa3bd1f commit 061540b

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"id": "457746be-f3eb-4ef0-8b5b-25548f5cf5d2",
3+
"type": "feature",
4+
"description": "Add Expires field to CookieOptions.",
5+
"modules": [
6+
"feature/cloudfront/sign"
7+
]
8+
}

feature/cloudfront/sign/sign_cookie.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ type CookieOptions struct {
2424
Domain string
2525
Secure bool
2626
SameSite http.SameSite
27+
Expires time.Time
2728
}
2829

2930
// apply will integration the options provided into the base cookie options
@@ -219,16 +220,19 @@ func createCookies(p *Policy, keyID string, privKey *rsa.PrivateKey, opt CookieO
219220
Name: CookiePolicyName,
220221
Value: string(b64Policy),
221222
HttpOnly: true,
223+
Expires: opt.Expires,
222224
}
223225
cSignature := &http.Cookie{
224226
Name: CookieSignatureName,
225227
Value: string(b64Sig),
226228
HttpOnly: true,
229+
Expires: opt.Expires,
227230
}
228231
cKey := &http.Cookie{
229232
Name: CookieKeyIDName,
230233
Value: keyID,
231234
HttpOnly: true,
235+
Expires: opt.Expires,
232236
}
233237

234238
cookies := []*http.Cookie{cPolicy, cSignature, cKey}

0 commit comments

Comments
 (0)