-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[HttpFoundation] make cookies auto-secure when passing them $secure=null + plan to make it and samesite=lax the defaults in 5.0 #28447
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
Conversation
69d8d9a to
1535093
Compare
|
This PR now goes one step further and creates a path to change the default "secure" setting on |
774c256 to
f0a3863
Compare
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 makes sense to me, although I must say that this is the 1st PR that I review on this repository. Thanks, @nicolas-grekas to consider this update after discuss it on the issue.
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.
Missing some new tests
| * @param string $path The path on the server in which the cookie will be available on | ||
| * @param string|null $domain The domain that the cookie is available to | ||
| * @param bool $secure Whether the cookie should only be transmitted over a secure HTTPS connection from the client | ||
| * @param bool|null $secure Whether the cookie should only be transmitted over a secure HTTPS connection from the client or null to set it later using {@see setSecureDefault()} |
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.
If think the most interesting bit to add is the auto-enabling feature (the setSecureDefault() is not that interesting if you ask me)
f0a3863 to
0ece7c3
Compare
ee1837f to
a94f569
Compare
| if (null !== $this->sessionOptions) { | ||
| foreach ($this->sessionOptions as $k => $v) { | ||
| if (0 === strpos($k, 'cookie_')) { | ||
| $params[substr($k, 7)] = $v; |
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.
Nice 💯
a94f569 to
b186cbf
Compare
|
Tests added. Status: needs review |
|
Oh, and there is one more step now: samesite will turn to "lax" by default in Symfony 5! |
b186cbf to
42a7546
Compare
…ull + plan to make it and samesite=lax the defaults in 5.0
42a7546 to
9493cfd
Compare
|
Thank you @nicolas-grekas. |
… them $secure=null + plan to make it and samesite=lax the defaults in 5.0 (nicolas-grekas) This PR was merged into the 4.2-dev branch. Discussion ---------- [HttpFoundation] make cookies auto-secure when passing them $secure=null + plan to make it and samesite=lax the defaults in 5.0 | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | yes | Tests pass? | yes | Fixed tickets | #26731 | License | MIT | Doc PR | - By creating Cookie instances using `null` for the `$secure` argument, this PR allows making cookies inherit their "secure" attribute from the request. This PR also adds a forward to make $secure=null and samesite=lax the defaults in Symfony 5.0: - either define all constructor's arguments explicitly - or use the new `Cookie::create()` factory Commits ------- 9493cfd [HttpFoundation] make cookies auto-secure when passing them $secure=null + plan to make it and samesite=lax the defaults in 5.0
…on (derrabus) This PR was merged into the 6.4 branch. Discussion ---------- [PsrHttpMessageBridge] Remove `Cookie::create()` detection | Q | A | ------------- | --- | Branch? | 6.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | N/A | License | MIT | Doc PR | N/A This method exists since #28447 (Symfony 4.2) Commits ------- 94e75e6 [PsrHttpMessageBridge] Remove Cookie::create() detection
By creating Cookie instances using
nullfor the$secureargument, this PR allows making cookies inherit their "secure" attribute from the request.This PR also adds a forward to make $secure=null and samesite=lax the defaults in Symfony 5.0:
Cookie::create()factory