From 061540b5a73ead172928c9c5aebc48c011bf4ee1 Mon Sep 17 00:00:00 2001 From: Deepen Patel Date: Sat, 2 Nov 2024 00:38:57 +0530 Subject: [PATCH] Cloudfront - add expire time in signed cookie. (#2862) --- .changelog/457746bef3eb4ef08b5b25548f5cf5d2.json | 8 ++++++++ feature/cloudfront/sign/sign_cookie.go | 4 ++++ 2 files changed, 12 insertions(+) create mode 100644 .changelog/457746bef3eb4ef08b5b25548f5cf5d2.json diff --git a/.changelog/457746bef3eb4ef08b5b25548f5cf5d2.json b/.changelog/457746bef3eb4ef08b5b25548f5cf5d2.json new file mode 100644 index 00000000000..29078007b03 --- /dev/null +++ b/.changelog/457746bef3eb4ef08b5b25548f5cf5d2.json @@ -0,0 +1,8 @@ +{ + "id": "457746be-f3eb-4ef0-8b5b-25548f5cf5d2", + "type": "feature", + "description": "Add Expires field to CookieOptions.", + "modules": [ + "feature/cloudfront/sign" + ] +} \ No newline at end of file diff --git a/feature/cloudfront/sign/sign_cookie.go b/feature/cloudfront/sign/sign_cookie.go index b35b93a9f2e..7e6d9aa1e5d 100644 --- a/feature/cloudfront/sign/sign_cookie.go +++ b/feature/cloudfront/sign/sign_cookie.go @@ -24,6 +24,7 @@ type CookieOptions struct { Domain string Secure bool SameSite http.SameSite + Expires time.Time } // 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 Name: CookiePolicyName, Value: string(b64Policy), HttpOnly: true, + Expires: opt.Expires, } cSignature := &http.Cookie{ Name: CookieSignatureName, Value: string(b64Sig), HttpOnly: true, + Expires: opt.Expires, } cKey := &http.Cookie{ Name: CookieKeyIDName, Value: keyID, HttpOnly: true, + Expires: opt.Expires, } cookies := []*http.Cookie{cPolicy, cSignature, cKey}