-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -393,7 +393,7 @@ | |
$class = $this->getContainerClass(); | ||
$buildDir = $this->warmupDir ?: $this->getBuildDir(); | ||
$skip = $_SERVER['SYMFONY_DISABLE_RESOURCE_TRACKING'] ?? ''; | ||
$skip = filter_var($skip, \FILTER_VALIDATE_BOOLEAN, \FILTER_NULL_ON_FAILURE) ?? explode(',', $skip); | ||
$skip = filter_var($skip, \FILTER_VALIDATE_BOOLEAN, \FILTER_NULL_ON_FAILURE) ?? explode(',', $skip); | ||
$cache = new ConfigCache($buildDir.'/'.$class.'.php', $this->debug, null, \is_array($skip) && ['*'] !== $skip ? $skip : ($skip ? [] : null)); | ||
|
||
$cachePath = $cache->getPath(); | ||
|
@@ -745,11 +745,30 @@ | |
$container = $this->container; | ||
|
||
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)); | ||
Check failure on line 748 in src/Symfony/Component/HttpKernel/Kernel.php
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. shouldn't this check that the parameter is a string before using There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
} | ||
|
||
if ($container->hasParameter('kernel.trusted_proxies') && $container->hasParameter('kernel.trusted_headers') && $trustedProxies = $container->getParameter('kernel.trusted_proxies')) { | ||
Request::setTrustedProxies(\is_array($trustedProxies) ? $trustedProxies : array_map('trim', explode(',', $trustedProxies)), $container->getParameter('kernel.trusted_headers')); | ||
$trustedHeaders = $container->getParameter('kernel.trusted_headers'); | ||
|
||
if (\is_string($trustedHeaders)) { | ||
$trustedHeaders = array_map('trim', explode(',', $trustedHeaders)); | ||
} | ||
|
||
if (\is_array($trustedHeaders)) { | ||
$trustedHeaderSet = 0; | ||
|
||
foreach ($trustedHeaders as $header) { | ||
if (!\defined($const = Request::class.'::HEADER_'.strtr(strtoupper($header), '-', '_'))) { | ||
throw new \InvalidArgumentException(\sprintf('The trusted header "%s" is not supported.', $header)); | ||
} | ||
$trustedHeaderSet |= \constant($const); | ||
} | ||
} else { | ||
$trustedHeaderSet = $trustedHeaders ?? (Request::HEADER_X_FORWARDED_FOR | Request::HEADER_X_FORWARDED_PORT | Request::HEADER_X_FORWARDED_PROTO); | ||
} | ||
|
||
Request::setTrustedProxies(\is_array($trustedProxies) ? $trustedProxies : array_map('trim', explode(',', $trustedProxies)), $trustedHeaderSet); | ||
} | ||
|
||
return $container; | ||
|
Uh oh!
There was an error while loading. Please reload this page.