-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
gh-136992: Add 'None' as valid SameSite value as per RFC6265bis #137040
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change looks good to me, but please run pre-commit to fix the failing lint job.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
For future reference, you don't need to force push; we squash at the end.
Thanks for the heads-up! I’ll avoid force-pushing next time. |
The attribute :attr:`samesite` controls when the browser sends the cookie with | ||
cross-site requests. This helps to mitigate CSRF attacks. Valid values are | ||
"Strict" (never sent with cross-site requests), "Lax" (sent with top-level | ||
navigation), and "None" (always sent). When using "None", the "secure" | ||
attribute must also be set, as required by modern browsers. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The attribute :attr:`samesite` controls when the browser sends the cookie with | |
cross-site requests. This helps to mitigate CSRF attacks. Valid values are | |
"Strict" (never sent with cross-site requests), "Lax" (sent with top-level | |
navigation), and "None" (always sent). When using "None", the "secure" | |
attribute must also be set, as required by modern browsers. | |
The attribute :attr:`samesite` controls when the browser sends the cookie with | |
cross-site requests. This helps to mitigate CSRF attacks. Valid values are | |
"Strict" (only sent with same-site requests), "Lax" (sent with same-site | |
requests and top-level navigations), and "None" (sent with same-site and | |
cross-site requests). When using "None", the "secure" attribute must also | |
be set, as required by modern browsers. |
Let's use the same wording as the RFC.
"Strict" (never sent with cross-site requests), "Lax" (sent with top-level | ||
navigation), and "None" (always sent). When using "None", the "secure" | ||
attribute must also be set, as required by modern browsers. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR adds missing documentation for the samesite attribute in the http.cookies module.
While the attribute was already listed among valid Morsel attributes, it lacked an explanation. This change adds clear and complete documentation explaining:
-The attribute’s role in CSRF protection.
-The valid values: "Strict", "Lax", and "None".
-The requirement that "secure" must be set when using "SameSite=None".
This update brings the documentation in line with RFC6265bis and reflects current browser behaviour.
📚 Documentation preview 📚: https://cpython-previews--137040.org.readthedocs.build/
http.cookies
should mention thatsamesite=None
is valid as per RFC6265bis #136992