[HttpFoundation] make cookies auto-secure when passing them $secure=null + plan to make it and samesite=lax the defaults in 5.0#28447
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
DavidGarciaCat
left a comment
There was a problem hiding this comment.
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.
| * @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.
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; |
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