Merge pull request #194 from Mibew/trusted_proxies

Add "trusted_proxy" option
This commit is contained in:
Fedor A. Fetisov 2017-03-10 00:00:18 +03:00 committed by GitHub
commit 6ea5f5af11
3 changed files with 19 additions and 0 deletions

View File

@ -77,6 +77,15 @@ default_locale: en
# http://php.net/manual/en/timezones.php
timezone: ""
# List of proxy's IP Mibew should trust. You should set this option if you use
# Mibew with a load balancer or behind a proxy.
trusted_proxies: []
# Here is an example of what values this option can take:
# trusted_proxies:
# - 127.0.0.1
# - ::1
# - 10.0.0.0/8
# Plugins
plugins: []

View File

@ -59,6 +59,12 @@ function load_system_configs()
$configs['plugins'] = array();
}
// Trusted proxies section should exists too. The logic behind "empty" statement is
// the same as above.
if (empty($configs['trusted_proxies'])) {
$configs['trusted_proxies'] = array();
}
// Database section should exists too. Also it should have an appropriate structure.
if (empty($configs['database'])) {
$configs['database'] = array();

View File

@ -44,6 +44,10 @@ require_once(MIBEW_FS_ROOT . '/libs/common/request.php');
require_once(MIBEW_FS_ROOT . '/libs/common/response.php');
require_once(MIBEW_FS_ROOT . '/libs/common/string.php');
if (count($configs['trusted_proxies']) > 0) {
\Symfony\Component\HttpFoundation\Request::setTrustedProxies($configs['trusted_proxies']);
}
// We need to get some info from the request. Use symfony wrapper because it's
// the simplest way.
$tmp_request = \Symfony\Component\HttpFoundation\Request::createFromGlobals();