Skip to content

Commit

Permalink
Cloudfront - add expire time in signed cookie. (#2862)
Browse files Browse the repository at this point in the history
  • Loading branch information
deepenpatel19 authored Nov 1, 2024
1 parent aa3bd1f commit 061540b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .changelog/457746bef3eb4ef08b5b25548f5cf5d2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"id": "457746be-f3eb-4ef0-8b5b-25548f5cf5d2",
"type": "feature",
"description": "Add Expires field to CookieOptions.",
"modules": [
"feature/cloudfront/sign"
]
}
4 changes: 4 additions & 0 deletions feature/cloudfront/sign/sign_cookie.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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}
Expand Down

0 comments on commit 061540b

Please sign in to comment.