From 8741ad54100dab0da89f2f3c51baf56d3227bb46 Mon Sep 17 00:00:00 2001 From: Deepen Patel Date: Wed, 30 Oct 2024 22:42:24 +0530 Subject: [PATCH 1/4] Add expire time --- feature/cloudfront/sign/sign_cookie.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/feature/cloudfront/sign/sign_cookie.go b/feature/cloudfront/sign/sign_cookie.go index b35b93a9f2e..82f85353882 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 + Expire *AWSEpochTime `json:",omitempty"` } // 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.Expire.Time, } cSignature := &http.Cookie{ Name: CookieSignatureName, Value: string(b64Sig), HttpOnly: true, + Expires: opt.Expire.Time, } cKey := &http.Cookie{ Name: CookieKeyIDName, Value: keyID, HttpOnly: true, + Expires: opt.Expire.Time, } cookies := []*http.Cookie{cPolicy, cSignature, cKey} From ff53d4ea3102869239d1f05f315c01d229102dd6 Mon Sep 17 00:00:00 2001 From: Deepen Patel Date: Wed, 30 Oct 2024 23:12:25 +0530 Subject: [PATCH 2/4] Remove naming. --- feature/cloudfront/sign/sign_cookie.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/feature/cloudfront/sign/sign_cookie.go b/feature/cloudfront/sign/sign_cookie.go index 82f85353882..dde54d3dd23 100644 --- a/feature/cloudfront/sign/sign_cookie.go +++ b/feature/cloudfront/sign/sign_cookie.go @@ -24,7 +24,7 @@ type CookieOptions struct { Domain string Secure bool SameSite http.SameSite - Expire *AWSEpochTime `json:",omitempty"` + Expire *AWSEpochTime } // apply will integration the options provided into the base cookie options From e6aaa012239290683b5667ebff6e3e5b21f8673c Mon Sep 17 00:00:00 2001 From: Deepen Patel Date: Fri, 1 Nov 2024 00:09:53 +0530 Subject: [PATCH 3/4] Changed variable type. --- feature/cloudfront/sign/sign_cookie.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/feature/cloudfront/sign/sign_cookie.go b/feature/cloudfront/sign/sign_cookie.go index dde54d3dd23..9f0f8a5f00e 100644 --- a/feature/cloudfront/sign/sign_cookie.go +++ b/feature/cloudfront/sign/sign_cookie.go @@ -24,7 +24,7 @@ type CookieOptions struct { Domain string Secure bool SameSite http.SameSite - Expire *AWSEpochTime + Expire time.Time } // apply will integration the options provided into the base cookie options @@ -220,19 +220,19 @@ func createCookies(p *Policy, keyID string, privKey *rsa.PrivateKey, opt CookieO Name: CookiePolicyName, Value: string(b64Policy), HttpOnly: true, - Expires: opt.Expire.Time, + Expires: opt.Expire, } cSignature := &http.Cookie{ Name: CookieSignatureName, Value: string(b64Sig), HttpOnly: true, - Expires: opt.Expire.Time, + Expires: opt.Expire, } cKey := &http.Cookie{ Name: CookieKeyIDName, Value: keyID, HttpOnly: true, - Expires: opt.Expire.Time, + Expires: opt.Expire, } cookies := []*http.Cookie{cPolicy, cSignature, cKey} From a73b2c2a55433ca56cc1b931becdf573b56b525c Mon Sep 17 00:00:00 2001 From: Luc Talatinian Date: Fri, 1 Nov 2024 11:35:35 -0400 Subject: [PATCH 4/4] expire -> expires, changelog --- .changelog/457746bef3eb4ef08b5b25548f5cf5d2.json | 8 ++++++++ feature/cloudfront/sign/sign_cookie.go | 8 ++++---- 2 files changed, 12 insertions(+), 4 deletions(-) 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 9f0f8a5f00e..7e6d9aa1e5d 100644 --- a/feature/cloudfront/sign/sign_cookie.go +++ b/feature/cloudfront/sign/sign_cookie.go @@ -24,7 +24,7 @@ type CookieOptions struct { Domain string Secure bool SameSite http.SameSite - Expire time.Time + Expires time.Time } // apply will integration the options provided into the base cookie options @@ -220,19 +220,19 @@ func createCookies(p *Policy, keyID string, privKey *rsa.PrivateKey, opt CookieO Name: CookiePolicyName, Value: string(b64Policy), HttpOnly: true, - Expires: opt.Expire, + Expires: opt.Expires, } cSignature := &http.Cookie{ Name: CookieSignatureName, Value: string(b64Sig), HttpOnly: true, - Expires: opt.Expire, + Expires: opt.Expires, } cKey := &http.Cookie{ Name: CookieKeyIDName, Value: keyID, HttpOnly: true, - Expires: opt.Expire, + Expires: opt.Expires, } cookies := []*http.Cookie{cPolicy, cSignature, cKey}