From 103de50a3da04250e2088f021e4445356258596e Mon Sep 17 00:00:00 2001 From: Jeff Gran Date: Tue, 1 Oct 2024 09:24:11 -0600 Subject: [PATCH 1/6] Add some missing cookie options and add go.mod --- cookies.go | 28 +++++++++++++++++----------- go.mod | 10 ++++++++++ go.sum | 6 ++++++ 3 files changed, 33 insertions(+), 11 deletions(-) create mode 100644 go.mod create mode 100644 go.sum diff --git a/cookies.go b/cookies.go index 95c93ec..9a69b94 100644 --- a/cookies.go +++ b/cookies.go @@ -91,11 +91,14 @@ type SecureCookieManager struct { } type CookieOptions struct { - Domain string - Path string - HTTPOnly bool - Secure bool - MaxAge time.Duration + Domain string + Path string + HTTPOnly bool + Secure bool + MaxAge time.Duration + Expires time.Time + Partitioned bool + SameSite http.SameSite } // Set a cookie with the data set to the encrypted version of the serialization of v. @@ -108,12 +111,15 @@ func (cm *SecureCookieManager) Set(w http.ResponseWriter, name string, opts *Coo } cookie := http.Cookie{ - Name: name, - Domain: opts.Domain, - Path: opts.Path, - HttpOnly: opts.HTTPOnly, - Secure: opts.Secure, - MaxAge: int(opts.MaxAge.Seconds()), + Name: name, + Domain: opts.Domain, + Path: opts.Path, + HttpOnly: opts.HTTPOnly, + Secure: opts.Secure, + MaxAge: int(opts.MaxAge.Seconds()), + Expires: opts.Expires, + Partitioned: opts.Partitioned, + SameSite: opts.SameSite, } if err := cm.Encoder.Encode(v, &cookie); err != nil { diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..d220718 --- /dev/null +++ b/go.mod @@ -0,0 +1,10 @@ +module github.com/gostack/cookies + +go 1.23.1 + +require github.com/divoxx/goRailsYourself v0.0.0-20150818201947-3fe8d02f099f + +require ( + github.com/franela/goblin v0.0.0-20211003143422-0a4f594942bf // indirect + golang.org/x/crypto v0.27.0 // indirect +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..9e785d6 --- /dev/null +++ b/go.sum @@ -0,0 +1,6 @@ +github.com/divoxx/goRailsYourself v0.0.0-20150818201947-3fe8d02f099f h1:jx31MCT3aPNLMLEYbaEg5fauKAtBmyb8iM48QxTmE98= +github.com/divoxx/goRailsYourself v0.0.0-20150818201947-3fe8d02f099f/go.mod h1:D2BDDdHBTYnRHaA+Eo6SqJnkkyk+AfTI2Qb49UveB4E= +github.com/franela/goblin v0.0.0-20211003143422-0a4f594942bf h1:NrF81UtW8gG2LBGkXFQFqlfNnvMt9WdB46sfdJY4oqc= +github.com/franela/goblin v0.0.0-20211003143422-0a4f594942bf/go.mod h1:VzmDKDJVZI3aJmnRI9VjAn9nJ8qPPsN1fqzr9dqInIo= +golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A= +golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70= From 661e0131ceb39df6184d77d91772cc424bc975d1 Mon Sep 17 00:00:00 2001 From: Jeff Gran Date: Tue, 1 Oct 2024 09:32:50 -0600 Subject: [PATCH 2/6] 1.22 --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index d220718..68f9c5e 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/gostack/cookies -go 1.23.1 +go 1.22.6 require github.com/divoxx/goRailsYourself v0.0.0-20150818201947-3fe8d02f099f From a0613a7a2dd23df936b1a090e9b6ce2c7502b230 Mon Sep 17 00:00:00 2001 From: Jeff Gran Date: Tue, 1 Oct 2024 09:38:30 -0600 Subject: [PATCH 3/6] rm partitioned for now, requires go 1.23 --- cookies.go | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/cookies.go b/cookies.go index 9a69b94..cad401e 100644 --- a/cookies.go +++ b/cookies.go @@ -91,14 +91,13 @@ type SecureCookieManager struct { } type CookieOptions struct { - Domain string - Path string - HTTPOnly bool - Secure bool - MaxAge time.Duration - Expires time.Time - Partitioned bool - SameSite http.SameSite + Domain string + Path string + HTTPOnly bool + Secure bool + MaxAge time.Duration + Expires time.Time + SameSite http.SameSite } // Set a cookie with the data set to the encrypted version of the serialization of v. @@ -111,15 +110,14 @@ func (cm *SecureCookieManager) Set(w http.ResponseWriter, name string, opts *Coo } cookie := http.Cookie{ - Name: name, - Domain: opts.Domain, - Path: opts.Path, - HttpOnly: opts.HTTPOnly, - Secure: opts.Secure, - MaxAge: int(opts.MaxAge.Seconds()), - Expires: opts.Expires, - Partitioned: opts.Partitioned, - SameSite: opts.SameSite, + Name: name, + Domain: opts.Domain, + Path: opts.Path, + HttpOnly: opts.HTTPOnly, + Secure: opts.Secure, + MaxAge: int(opts.MaxAge.Seconds()), + Expires: opts.Expires, + SameSite: opts.SameSite, } if err := cm.Encoder.Encode(v, &cookie); err != nil { From 14bc89527cc811c2bc5f042dcd87dc4dc02327f5 Mon Sep 17 00:00:00 2001 From: Jeff Gran Date: Tue, 1 Oct 2024 10:22:50 -0600 Subject: [PATCH 4/6] put back partitioned --- cookies.go | 32 +++++++++++++++++--------------- go.mod | 2 +- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/cookies.go b/cookies.go index cad401e..9a69b94 100644 --- a/cookies.go +++ b/cookies.go @@ -91,13 +91,14 @@ type SecureCookieManager struct { } type CookieOptions struct { - Domain string - Path string - HTTPOnly bool - Secure bool - MaxAge time.Duration - Expires time.Time - SameSite http.SameSite + Domain string + Path string + HTTPOnly bool + Secure bool + MaxAge time.Duration + Expires time.Time + Partitioned bool + SameSite http.SameSite } // Set a cookie with the data set to the encrypted version of the serialization of v. @@ -110,14 +111,15 @@ func (cm *SecureCookieManager) Set(w http.ResponseWriter, name string, opts *Coo } cookie := http.Cookie{ - Name: name, - Domain: opts.Domain, - Path: opts.Path, - HttpOnly: opts.HTTPOnly, - Secure: opts.Secure, - MaxAge: int(opts.MaxAge.Seconds()), - Expires: opts.Expires, - SameSite: opts.SameSite, + Name: name, + Domain: opts.Domain, + Path: opts.Path, + HttpOnly: opts.HTTPOnly, + Secure: opts.Secure, + MaxAge: int(opts.MaxAge.Seconds()), + Expires: opts.Expires, + Partitioned: opts.Partitioned, + SameSite: opts.SameSite, } if err := cm.Encoder.Encode(v, &cookie); err != nil { diff --git a/go.mod b/go.mod index 68f9c5e..d220718 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/gostack/cookies -go 1.22.6 +go 1.23.1 require github.com/divoxx/goRailsYourself v0.0.0-20150818201947-3fe8d02f099f From a63e386cb4e52b06fbb0bacedb8deadd352a79dc Mon Sep 17 00:00:00 2001 From: Jeff Gran Date: Wed, 2 Oct 2024 10:24:13 -0600 Subject: [PATCH 5/6] re-remove partitioned flag --- cookies.go | 32 +++++++++++++++----------------- go.mod | 2 +- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/cookies.go b/cookies.go index 9a69b94..cad401e 100644 --- a/cookies.go +++ b/cookies.go @@ -91,14 +91,13 @@ type SecureCookieManager struct { } type CookieOptions struct { - Domain string - Path string - HTTPOnly bool - Secure bool - MaxAge time.Duration - Expires time.Time - Partitioned bool - SameSite http.SameSite + Domain string + Path string + HTTPOnly bool + Secure bool + MaxAge time.Duration + Expires time.Time + SameSite http.SameSite } // Set a cookie with the data set to the encrypted version of the serialization of v. @@ -111,15 +110,14 @@ func (cm *SecureCookieManager) Set(w http.ResponseWriter, name string, opts *Coo } cookie := http.Cookie{ - Name: name, - Domain: opts.Domain, - Path: opts.Path, - HttpOnly: opts.HTTPOnly, - Secure: opts.Secure, - MaxAge: int(opts.MaxAge.Seconds()), - Expires: opts.Expires, - Partitioned: opts.Partitioned, - SameSite: opts.SameSite, + Name: name, + Domain: opts.Domain, + Path: opts.Path, + HttpOnly: opts.HTTPOnly, + Secure: opts.Secure, + MaxAge: int(opts.MaxAge.Seconds()), + Expires: opts.Expires, + SameSite: opts.SameSite, } if err := cm.Encoder.Encode(v, &cookie); err != nil { diff --git a/go.mod b/go.mod index d220718..68f9c5e 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/gostack/cookies -go 1.23.1 +go 1.22.6 require github.com/divoxx/goRailsYourself v0.0.0-20150818201947-3fe8d02f099f From 192f26e8bdb7013b3397fb57fc5f363cd3124c8a Mon Sep 17 00:00:00 2001 From: Jeff Gran <115882203+jeffgran-dox@users.noreply.github.com> Date: Thu, 3 Oct 2024 13:32:06 -0600 Subject: [PATCH 6/6] Update go.mod --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 68f9c5e..550b175 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/gostack/cookies +module github.com/doximity/cookies go 1.22.6