Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[FrameworkBundle][HttpKernel] Restrict stateless reporting to exception only#36321
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
bf3ee5d to369872aComparenicolas-grekas commentedApr 2, 2020
I was wondering if we shouldn't rename "debug" to "strict". |
mtarld commentedApr 2, 2020
I like the strict idea. Maybe we could add a |
nicolas-grekas commentedApr 2, 2020 • 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.
yes, a config entry looks like an idea to consider to me |
mtarld commentedApr 2, 2020
Even better yes, I'll give a try |
369872a to2d20edbComparemtarld commentedApr 3, 2020 • 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.
With this implementation, you'll have the following configuration available: session:strict_stateless:true With default configuration to |
Uh oh!
There was an error while loading.Please reload this page.
2d20edb to3f38bdfComparejaviereguiluz commentedApr 3, 2020 • 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.
Thanks for creating this PR. The thing I don't like about the current implementation is that if (true ===$request->attributes->get('stateless')) {$response->setSharedMaxAge(3600);} The problem is that, if the route uses the session, you may be caching a page with private information and serving it to anyone. That may be a very serious problem. I don't like the idea of making this behavior configurable either. You said you weren't going to use the session ... so if you use it by mistake, the application should fail. I think the transition will be OK, because developers will see the exceptions locally and fix them. So, in the remote case that you use the session in production when you shouldn't, I think that throwing an exception is better than silencing this error. |
nicolas-grekas commentedApr 3, 2020 • 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.
How can this happen? That's not possible to me, we have a mechanism that prevents it already. We know by experience that it's very easy to use the session by mistake. For ppl that inadvertently render() a controller that uses the session, would they prefer a broken prod, or an automatic "cache-control: private"? The current way (since always) is the 2nd option and this should remain to me. With a line in the logs ftw. In dev, sure, I want an exception. |
javiereguiluz commentedApr 3, 2020
After discussing privately with Nicolas ... my main concern is now gone. In the previous example, Symfony will set "cache private" automatically because the session was used, so it will ignore our "smaxage" setting. So, can anyone spot another issue for using the session in a controller that said that it was not going to use the session? Thanks! |
nicolas-grekas commentedApr 3, 2020 • 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.
Shall we close this PR then? One less option FTW. Here is an excerpt of our conversation for the record: Q:
A:
Q:
A:
|
mtarld commentedApr 3, 2020
IMHO, some Symfony users may want to actually throw an exception even on production. In this way they'll be a hundred percent sure that session isn't used. |
nicolas-grekas commentedApr 3, 2020
@mtarld my stand:
|
mtarld commentedApr 3, 2020
Fair enough. So if it shouldn't be configurable, we can close this PR I guess. |
This PR is related to#35732 which is reporting session usage when stateless is specified.
In debug mode, it throws an
UnexpectedSessionUsageExceptionwhereas in "no debug mode", it only logs that session is unexpectedly used.The current PR proposes to replace the log by an exception in the "no debug mode".
In that way, if session is unexpectedly used in production mode, it will throw an exception and prevent more serious problems such as serving a cached page with personal data.
WDYT ?