updated packages
This commit is contained in:
+28
-10
@@ -18,14 +18,14 @@ class TrustProxies
|
||||
/**
|
||||
* The trusted proxies for the application.
|
||||
*
|
||||
* @var array
|
||||
* @var null|string|array
|
||||
*/
|
||||
protected $proxies;
|
||||
|
||||
/**
|
||||
* The proxy header mappings.
|
||||
*
|
||||
* @var array
|
||||
* @var null|string|int
|
||||
*/
|
||||
protected $headers;
|
||||
|
||||
@@ -66,16 +66,19 @@ class TrustProxies
|
||||
{
|
||||
$trustedIps = $this->proxies ?: $this->config->get('trustedproxy.proxies');
|
||||
|
||||
// Trust any IP address that calls us
|
||||
// `**` for backwards compatibility, but is deprecated
|
||||
if ($trustedIps === '*' || $trustedIps === '**') {
|
||||
return $this->setTrustedProxyIpAddressesToTheCallingIp($request);
|
||||
}
|
||||
|
||||
// Support IPs addresses separated by comma
|
||||
$trustedIps = is_string($trustedIps) ? array_map('trim', explode(',', $trustedIps)) : $trustedIps;
|
||||
|
||||
// Only trust specific IP addresses
|
||||
if (is_array($trustedIps)) {
|
||||
return $this->setTrustedProxyIpAddressesToSpecificIps($request, $trustedIps);
|
||||
}
|
||||
|
||||
// Trust any IP address that calls us
|
||||
// `**` for backwards compatibility, but is depreciated
|
||||
if ($trustedIps === '*' || $trustedIps === '**') {
|
||||
return $this->setTrustedProxyIpAddressesToTheCallingIp($request);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -102,10 +105,25 @@ class TrustProxies
|
||||
/**
|
||||
* Retrieve trusted header name(s), falling back to defaults if config not set.
|
||||
*
|
||||
* @return array
|
||||
* @return int A bit field of Request::HEADER_*, to set which headers to trust from your proxies.
|
||||
*/
|
||||
protected function getTrustedHeaderNames()
|
||||
{
|
||||
return $this->headers ?: $this->config->get('trustedproxy.headers');
|
||||
$headers = $this->headers ?: $this->config->get('trustedproxy.headers');
|
||||
switch ($headers) {
|
||||
case 'HEADER_X_FORWARDED_AWS_ELB':
|
||||
case Request::HEADER_X_FORWARDED_AWS_ELB:
|
||||
return Request::HEADER_X_FORWARDED_AWS_ELB;
|
||||
break;
|
||||
case 'HEADER_FORWARDED':
|
||||
case Request::HEADER_FORWARDED:
|
||||
return Request::HEADER_FORWARDED;
|
||||
break;
|
||||
default:
|
||||
return Request::HEADER_X_FORWARDED_ALL;
|
||||
}
|
||||
|
||||
// Should never reach this point
|
||||
return $headers;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user