-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
[FrameworkBundle][HttpKernel] Add support for SYMFONY_TRUSTED_PROXIES, SYMFONY_TRUSTED_HEADERS, SYMFONY_TRUST_X_SENDFILE_TYPE_HEADER and SYMFONY_TRUSTED_HOSTS env vars
#58161
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
f17dd43 to
4b817ea
Compare
src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php
Show resolved
Hide resolved
|
|
||
| if ($container->hasParameter('kernel.trusted_hosts') && $trustedHosts = $container->getParameter('kernel.trusted_hosts')) { | ||
| Request::setTrustedHosts($trustedHosts); | ||
| Request::setTrustedHosts(\is_array($trustedHosts) ? $trustedHosts : preg_split('/\s*+,\s*+(?![^{]*})/', $trustedHosts)); |
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.
shouldn't this check that the parameter is a string before using preg_split on it ? Especially during booting, we need the code to be robust against unexpected parameter values (an old cache with an unsupported parameter might prevent you from running cache:clear in the prod environment)
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.
we don't do it for the other parameters so I didn't bother
4b817ea to
84d9347
Compare
f2433c0 to
f838316
Compare
|
PR ready ;) |
…S`, `SYMFONY_TRUSTED_HEADERS`, `SYMFONY_TRUST_X_SENDFILE_TYPE_HEADER` and `SYMFONY_TRUSTED_HOSTS` env vars
f838316 to
60bd068
Compare
|
Thank you @nicolas-grekas. |
…ereguiluz) This PR was squashed before being merged into the 7.2 branch. Discussion ---------- [FrameworkBundle] Simplify the configuration class | Q | A | ------------- | --- | Branch? | 7.2 | Bug fix? | no | New feature? | no | Deprecations? | no | Issues | - | License | MIT Spotted while documenting #58161. Commits ------- 429fc32 [FrameworkBundle] Simplify the configuration class
Adding support for
SYMFONY_TRUSTED_PROXIES,SYMFONY_TRUSTED_HEADERS,SYMFONY_TRUST_X_SENDFILE_TYPE_HEADERandSYMFONY_TRUSTED_HOSTSenv vars.This PR proposes making the default configuration rely on these env var when the corresponding config options are not set.
This should make it easier to package or deploy Symfony apps together with a pre-configured web-server or reverse-proxy.