Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[HttpFoundation] Take php session.cookie settings into account#44518
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
simonchrz commentedDec 9, 2021
@alexander-schranz maybe you could review this please ? |
alexander-schranz commentedDec 9, 2021
@simonchrz sorry for the noice. Overall I think we should need to duplicate here some thing from the I would go with the following in the $this->sessionOptions = [];foreach (session_get_cookie_params()as$key =>$value) {$this->sessionOptions['cookie_' .$key] =>$value;}foreach ($sessionOptionsas$key =>$value) {// do the same logic as in the NativeSessionStorage// @see https://github.com/symfony/symfony/blob/v5.4.0/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php#L392-L394if (isset($validOptions[$key])) {if ('cookie_secure' ===$key &&'auto' ===$value) {continue; }$this->sessionOptions[$key] =$value; }} We need to check if symfony is forcing some specific values inhttps://github.com/symfony/symfony/blob/v5.4.0/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php specially if samesite work correctly still for lower PHP Versions. |
derrabus commentedDec 13, 2021
@simonchrz Are you able to write a test for your change? I really want to make sure, we don't break this behavior again. |
simonchrz commentedDec 14, 2021
@alexander-schranz i've followed your suggestion, please double check. 👍 |
src/Symfony/Component/HttpKernel/Tests/EventListener/SessionListenerTest.phpShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Component/HttpKernel/Tests/EventListener/SessionListenerTest.phpShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
alexander-schranz commentedDec 14, 2021 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@simonchrz as I see there is also issue about |
X-Coder264 commentedDec 15, 2021 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@simonchrz@alexander-schranz I don't think this completely fixes the problem with the In a normal Symfony request lifecycle the session listener is one of the first things that gets called on the Since the The fix for this would probably be to not call |
alexander-schranz commentedDec 15, 2021
@X-Coder264 Thank you for the detailed response and testing this out. Was not aware of it that it was currently possible to change the Storage Options from outside. Then it definitly make sense that we move the call of $sessionOptions =$this->getMergedPhpSessionOptions();$sessionCookiePath =$sessionOptions['cookie_path'] ??'/';// ... Would be interesting how we could create a functional test case for this. To avoid this errors in the future. @simonchrz sorry for the circumstances. And really thank you for working on this. |
alexander-schranz left a comment
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.
Changes looks good. Thank you 👍 . Still a test for symfony using cookie_secureauto with native secure disabled should be added, or did I miss that one?
simonchrz commentedDec 15, 2021
nope, i'm actually struggling with adding this one... maybe you could jump in writing this test ? :-) |
alexander-schranz commentedDec 15, 2021
@simonchrz Thx, no problem. Will try to have a look at the evening at it. |
Jelle-S commentedDec 15, 2021
I can confirm this fixes#44541 |
alexander-schranz commentedDec 16, 2021
@simonchrz This two additonal test cases cover the 'set_cookiesecure_auto_by_symfony_false_by_php' => ['phpSessionOptions' => ['secure' =>false],'sessionOptions' => ['cookie_path' =>'/test/','cookie_httponly' =>'auto','cookie_secure' =>'auto','cookie_samesite' => Cookie::SAMESITE_LAX],'expectedSessionOptions' => ['cookie_path' =>'/test/','cookie_domain' =>'','cookie_secure' =>false,'cookie_httponly' =>true,'cookie_samesite' => Cookie::SAMESITE_LAX], ],'set_cookiesecure_auto_by_symfony_true_by_php' => ['phpSessionOptions' => ['secure' =>true],'sessionOptions' => ['cookie_path' =>'/test/','cookie_httponly' =>'auto','cookie_secure' =>'auto','cookie_samesite' => Cookie::SAMESITE_LAX],'expectedSessionOptions' => ['cookie_path' =>'/test/','cookie_domain' =>'','cookie_secure' =>true,'cookie_httponly' =>true,'cookie_samesite' => Cookie::SAMESITE_LAX], ], |
simonchrz commentedDec 16, 2021
@alexander-schranz thanks for the hint == i've just added them to the provider |
simonchrz commentedDec 18, 2021
issue comes from refactoring on#41390 which isn't backmerged to 5.3 for some reason... |
simonchrz commentedDec 18, 2021
i guess with 5.4.2 ? ;) |
sxsws commentedDec 18, 2021
I think the real question is why wasn't this problem caught on such a mature project? |
nicolas-grekas commentedDec 18, 2021
🤷 |
simonchrz commentedDec 18, 2021
@nicolas-grekas any idea how to fix thos 8.0, macos-11 test of messenger component ? they seem to have some kind of disk I/O issues ?https://github.com/symfony/symfony/runs/4569511187?check_suite_focus=true#step:9:2464 |
32c8e36 to3257a3bComparesrc/Symfony/Component/HttpKernel/Tests/EventListener/SessionListenerTest.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
derrabus commentedDec 18, 2021
That test is not related to these changes, is it? You don't need to bother then. The macOS test suite is relatively new and we still have some flaky tests there. |
nicolas-grekas left a comment
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.
(after minor change)
src/Symfony/Component/HttpKernel/EventListener/AbstractSessionListener.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
8d6405e to23bd7a7Comparefabpot commentedDec 20, 2021
Thank you@simonchrz. |
alexander-schranz commentedDec 20, 2021 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@simonchrz Thank you for fixing this, great work 👍 |
wnunezc commentedDec 20, 2021
a great job let's wait for the 5.4.2 release to pull the XD, I think I'll have to revert some changes. |
…rabus)This PR was merged into the 5.4 branch.Discussion----------[HttpKernel] Don't rely on session service in tests| Q | A| ------------- | ---| Branch? | 5.4| Bug fix? | no| New feature? | no| Deprecations? | no| Tickets | Follow-up to#44518| License | MIT| Doc PR | N/AThe test introduced by#44518 makes use of the deprecated session service mechanism. Instead, I've attached the session to the request. This allows us to merge the test up to 6.0 and beyond without breaking it.Commits-------e963594 Don't rely on session service in tests
Fixes issue on SessionListener, not taken session.cookie_* settings into account anymore.