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

feat: support partitioned cookies #1041

Merged
merged 5 commits into from
Jan 12, 2024
Merged

Conversation

Haswf
Copy link
Contributor

@Haswf Haswf commented Jan 8, 2024

What type of PR is this?

feat

Check the PR title.

  • This PR title match the format: <type>(optional scope): <description>
  • The description of this PR title is user-oriented and clear enough for others to understand.
  • Attach the PR updating the user documentation if the current PR requires user awareness at the usage level. User docs repo

(Optional) Translate the PR title into Chinese.

feat(cookie): 支持独立分区 Cookies (CHIPS)

(Optional) More detailed description for this PR(en: English/zh: Chinese).

en:

Chrome has started restricting third-party cookies by default for 1% of Chrome browsers, which means third-party cookies with the SameSite=None attribute will be blocked. Partitioned cookies has been introduced as a privacy preserving alternative. A partitioned cookie is tied to the top-level site where it's initially set and cannot be accessed from elsewhere.

Set-Cookie: __Host-name=value; Secure; Path=/; SameSite=None; Partitioned;

image
image

You can learn more about CHIPS here or try the demo.

The net/http library has adopted partitioned cookies with golang/go#62490 and #1032.

To support partitioned cookies for Hertz, the following changes have been made:

  • Add partitioned field to Cookie
  • Append Partitioned; to the end of the cookie if partitioned is set to true.
  • Add Partitioned and SetPartitioned to get and set partitioned. SetPartitioned to true, will also set Secure.
  • Set partitioned to false when cookie is reset.

zh(optional):

(Optional) Which issue(s) this PR fixes:

Fixes #1032

(Optional) The PR that updates user documentation:

No

@Haswf Haswf requested review from a team as code owners January 8, 2024 17:02
Copy link

codecov bot commented Jan 9, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (119a744) 82.49% compared to head (a20c758) 82.54%.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1041      +/-   ##
===========================================
+ Coverage    82.49%   82.54%   +0.04%     
===========================================
  Files           98       98              
  Lines        10011    10024      +13     
===========================================
+ Hits          8259     8274      +15     
+ Misses        1255     1254       -1     
+ Partials       497      496       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Haswf Haswf changed the title feat(cookie): support partitioned cookies (CHIPS) feat: support partitioned cookies Jan 9, 2024
pkg/protocol/cookie.go Outdated Show resolved Hide resolved
pkg/protocol/cookie.go Outdated Show resolved Hide resolved
pkg/protocol/cookie.go Outdated Show resolved Hide resolved
pkg/protocol/cookie.go Outdated Show resolved Hide resolved
Copy link
Member

@welkeyever welkeyever left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thx~

@welkeyever welkeyever merged commit a949b0b into cloudwego:develop Jan 12, 2024
15 of 16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

proposal: http1 server support partitioned cookies
5 participants