NEW Add param $dolibarr_main_restrict_ip in config file to limit ips
This commit is contained in:
parent
4f0ba4982b
commit
362aec3e4b
@ -238,6 +238,15 @@ $dolibarr_main_prod='0';
|
|||||||
//
|
//
|
||||||
$dolibarr_main_restrict_os_commands='mysqldump, mysql, pg_dump, pgrestore';
|
$dolibarr_main_restrict_os_commands='mysqldump, mysql, pg_dump, pgrestore';
|
||||||
|
|
||||||
|
// $dolibarr_main_restrict_ip
|
||||||
|
// To restrict access to backoffice to some ip addresses only.
|
||||||
|
// Note: Pages that does not need login (like public pages, web site) are not protected with this.
|
||||||
|
// Default value: ''
|
||||||
|
// Examples:
|
||||||
|
// $dolibarr_main_restrict_ip='127.0.0.1, 192.168.0.1';
|
||||||
|
//
|
||||||
|
$dolibarr_main_restrict_ip='';
|
||||||
|
|
||||||
// dolibarr_nocsrfcheck
|
// dolibarr_nocsrfcheck
|
||||||
// This parameter can be used to disable CSRF protection.
|
// This parameter can be used to disable CSRF protection.
|
||||||
// This might be required if you access Dolibarr behind a proxy that make
|
// This might be required if you access Dolibarr behind a proxy that make
|
||||||
@ -284,16 +293,6 @@ $dolibarr_nocsrfcheck='0';
|
|||||||
// Examples:
|
// Examples:
|
||||||
// $dolibarr_strict_mode=0;
|
// $dolibarr_strict_mode=0;
|
||||||
|
|
||||||
// dolibarr_pdf_force_fpdf
|
|
||||||
// Set this to 1 to use the libray FPDF instead of TCPDF. FPDF is not embedded with Dolibarr,
|
|
||||||
// so you also have to uncomment line $dolibarr_lib_FPDF_PATH to provide path to FPDF library.
|
|
||||||
// Warning: FPDF does not support all features supported by TCPDF used by default. So using
|
|
||||||
// this library instead of TCPF will break some features like transparent logo, cyrillic, arab,
|
|
||||||
// and asiatic languages, total number of pages, ...
|
|
||||||
// Default value: 0
|
|
||||||
// Examples:
|
|
||||||
// $dolibarr_pdf_force_fpdf=1;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//#################################
|
//#################################
|
||||||
|
|||||||
@ -548,9 +548,10 @@ abstract class CommonObject
|
|||||||
*
|
*
|
||||||
* @param string $modulepart Module related to document
|
* @param string $modulepart Module related to document
|
||||||
* @param int $initsharekey Init the share key if it was not yet defined
|
* @param int $initsharekey Init the share key if it was not yet defined
|
||||||
|
* @param int $relativelink 0=Return full external link, 1=Return link relative to root of file
|
||||||
* @return string Link or empty string if there is no download link
|
* @return string Link or empty string if there is no download link
|
||||||
*/
|
*/
|
||||||
function getLastMainDocLink($modulepart, $initsharekey=0)
|
function getLastMainDocLink($modulepart, $initsharekey=0, $relativelink=0)
|
||||||
{
|
{
|
||||||
global $user, $dolibarr_main_url_root;
|
global $user, $dolibarr_main_url_root;
|
||||||
|
|
||||||
@ -621,10 +622,17 @@ abstract class CommonObject
|
|||||||
if (! empty($ecmfile->share)) $paramlink.=($paramlink?'&':'').'hashp='.$ecmfile->share; // Hash for public share
|
if (! empty($ecmfile->share)) $paramlink.=($paramlink?'&':'').'hashp='.$ecmfile->share; // Hash for public share
|
||||||
if ($forcedownload) $paramlink.=($paramlink?'&':'').'attachment=1';
|
if ($forcedownload) $paramlink.=($paramlink?'&':'').'attachment=1';
|
||||||
|
|
||||||
$fulllink=$urlwithroot.'/document.php'.($paramlink?'?'.$paramlink:'');
|
if ($relativelink)
|
||||||
|
{
|
||||||
|
$linktoreturn='document.php'.($paramlink?'?'.$paramlink:'');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$linktoreturn=$urlwithroot.'/document.php'.($paramlink?'?'.$paramlink:'');
|
||||||
|
}
|
||||||
|
|
||||||
// Here $ecmfile->share is defined
|
// Here $ecmfile->share is defined
|
||||||
return $fulllink;
|
return $linktoreturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -293,6 +293,25 @@ if (! empty($conf->file->main_force_https) && (empty($_SERVER["HTTPS"]) || $_SER
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (! defined('NOLOGIN') && ! defined('NOIPCHECK') && ! empty($dolibarr_main_restrict_ip))
|
||||||
|
{
|
||||||
|
$listofip=explode(',', $dolibarr_main_restrict_ip);
|
||||||
|
$found = false;
|
||||||
|
foreach($listofip as $ip)
|
||||||
|
{
|
||||||
|
$ip=trim($ip);
|
||||||
|
if ($ip == $_SERVER['REMOTE_ADDR'])
|
||||||
|
{
|
||||||
|
$found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (! $found)
|
||||||
|
{
|
||||||
|
print 'Access refused by IP protection';
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Loading of additional presentation includes
|
// Loading of additional presentation includes
|
||||||
if (! defined('NOREQUIREHTML')) require_once DOL_DOCUMENT_ROOT .'/core/class/html.form.class.php'; // Need 660ko memory (800ko in 2.2)
|
if (! defined('NOREQUIREHTML')) require_once DOL_DOCUMENT_ROOT .'/core/class/html.form.class.php'; // Need 660ko memory (800ko in 2.2)
|
||||||
|
|||||||
@ -30,6 +30,7 @@
|
|||||||
//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION','1'); // Do not check anti CSRF attack test
|
//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION','1'); // Do not check anti CSRF attack test
|
||||||
//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); // Do not check anti CSRF attack test done when option MAIN_SECURITY_CSRF_WITH_TOKEN is on.
|
//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); // Do not check anti CSRF attack test done when option MAIN_SECURITY_CSRF_WITH_TOKEN is on.
|
||||||
//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK','1'); // Do not check style html tag into posted data
|
//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK','1'); // Do not check style html tag into posted data
|
||||||
|
//if (! defined('NOIPCHECK')) define('NOIPCHECK','1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
|
||||||
//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Do not check anti POST attack test
|
//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Do not check anti POST attack test
|
||||||
//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no need to load and show top and left menu
|
//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no need to load and show top and left menu
|
||||||
//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php
|
//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php
|
||||||
|
|||||||
@ -30,6 +30,7 @@
|
|||||||
//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION','1'); // Do not check anti CSRF attack test
|
//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION','1'); // Do not check anti CSRF attack test
|
||||||
//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); // Do not check anti CSRF attack test done when option MAIN_SECURITY_CSRF_WITH_TOKEN is on.
|
//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); // Do not check anti CSRF attack test done when option MAIN_SECURITY_CSRF_WITH_TOKEN is on.
|
||||||
//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK','1'); // Do not check style html tag into posted data
|
//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK','1'); // Do not check style html tag into posted data
|
||||||
|
//if (! defined('NOIPCHECK')) define('NOIPCHECK','1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
|
||||||
//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Do not check anti POST attack test
|
//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Do not check anti POST attack test
|
||||||
//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no need to load and show top and left menu
|
//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no need to load and show top and left menu
|
||||||
//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php
|
//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user