mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
Merge pull request #6977 from andrewandante/FIX/move_dotenv_higher
move TRUSTED_PROXY below .env loader
This commit is contained in:
commit
11de4abe0a
@ -30,28 +30,6 @@ use SilverStripe\Control\Util\IPUtils;
|
|||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// ENVIRONMENT CONFIG
|
// ENVIRONMENT CONFIG
|
||||||
|
|
||||||
/**
|
|
||||||
* Validate whether the request comes directly from a trusted server or not
|
|
||||||
* This is necessary to validate whether or not the values of X-Forwarded-
|
|
||||||
* or Client-IP HTTP headers can be trusted
|
|
||||||
*/
|
|
||||||
if (!defined('TRUSTED_PROXY')) {
|
|
||||||
define('TRUSTED_PROXY', call_user_func(function () {
|
|
||||||
$trustedIPs = getenv('SS_TRUSTED_PROXY_IPS');
|
|
||||||
if (empty($trustedIPs) || $trustedIPs === 'none') {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if ($trustedIPs === '*') {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
// Validate IP address
|
|
||||||
if (isset($_SERVER['REMOTE_ADDR'])) {
|
|
||||||
return IPUtils::checkIP($_SERVER['REMOTE_ADDR'], explode(',', $trustedIPs));
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Define system paths
|
* Define system paths
|
||||||
*/
|
*/
|
||||||
@ -90,6 +68,28 @@ if (!getenv('SS_IGNORE_DOT_ENV')) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validate whether the request comes directly from a trusted server or not
|
||||||
|
* This is necessary to validate whether or not the values of X-Forwarded-
|
||||||
|
* or Client-IP HTTP headers can be trusted
|
||||||
|
*/
|
||||||
|
if (!defined('TRUSTED_PROXY')) {
|
||||||
|
define('TRUSTED_PROXY', call_user_func(function () {
|
||||||
|
$trustedIPs = getenv('SS_TRUSTED_PROXY_IPS');
|
||||||
|
if (empty($trustedIPs) || $trustedIPs === 'none') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if ($trustedIPs === '*') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// Validate IP address
|
||||||
|
if (isset($_SERVER['REMOTE_ADDR'])) {
|
||||||
|
return IPUtils::checkIP($_SERVER['REMOTE_ADDR'], explode(',', $trustedIPs));
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
if (!defined('BASE_URL')) {
|
if (!defined('BASE_URL')) {
|
||||||
define('BASE_URL', call_user_func(function () {
|
define('BASE_URL', call_user_func(function () {
|
||||||
// Determine the base URL by comparing SCRIPT_NAME to SCRIPT_FILENAME and getting common elements
|
// Determine the base URL by comparing SCRIPT_NAME to SCRIPT_FILENAME and getting common elements
|
||||||
|
Loading…
x
Reference in New Issue
Block a user