Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for partitioned cookies #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 17 additions & 15 deletions cookies.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/doximity/cookies

go 1.22.6
go 1.23.1

require github.com/divoxx/goRailsYourself v0.0.0-20150818201947-3fe8d02f099f

Expand Down