Use the default hash method for online signature instead of password
hash
This commit is contained in:
parent
64c0acd40e
commit
5446eca125
4 changed files with 13 additions and 14 deletions
|
|
@ -10828,7 +10828,7 @@ abstract class CommonObject
|
|||
if (array_key_exists('ref', $fieldvalues)) {
|
||||
$fieldvalues['ref'] = dol_string_nospecial($fieldvalues['ref']); // If field is a ref, we sanitize data
|
||||
}
|
||||
if (getDolGlobalString('MAIN_DISABLE_AUTO_UPDATE_OF_TMS_FIELDS') && array_key_exists('tms', $fieldvalues)) { // If we want the explicit update of tms fields instead of deprecated update by database
|
||||
if (getDolGlobalString('MAIN_DISABLE_AUTO_UPDATE_OF_TMS_FIELDS') && array_key_exists('tms', $fieldvalues)) { // If we want the explicit update of tms fields instead of the deprecated update by database
|
||||
$fieldvalues['tms'] = $this->db->idate($now);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -359,7 +359,7 @@ function dol_hash($chain, $type = '0', $nosalt = 0, $mode = 0)
|
|||
*
|
||||
* @param string $chain String to hash (not hashed string)
|
||||
* @param string $hash hash to compare
|
||||
* @param string $type Type of hash ('0':auto, '1':sha1, '2':sha1+md5, '3':md5, '4': for OpenLdap, '5':sha256). Use '3' here, if hash is not needed for security purpose, for security need, prefer '0'.
|
||||
* @param string $type Type of hash ('0':auto, '1':sha1, '2':sha1+md5, '3':md5, '4': for OpenLdap, '5':sha256, 'hash'). Use '3' here, if hash is not needed for security purpose, for security need, prefer '0'.
|
||||
* @return bool True if the computed hash is the same as the given one
|
||||
* @see dol_hash()
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ function getOnlineSignatureUrl($mode, $type, $ref = '', $localorexternal = 1, $o
|
|||
if ($mode == 1) {
|
||||
$out .= "hash('".$securekeyseed."' + '".$type."' + proposal_ref)";
|
||||
} else {
|
||||
$out .= '&securekey='.urlencode(dol_hash($securekeyseed.$type.$ref.(isModEnabled('multicompany') ? (empty($obj->entity) ? '' : $obj->entity) : ''), '0'));
|
||||
$out .= '&securekey='.urlencode(dol_hash($securekeyseed.$type.$ref.(isModEnabled('multicompany') ? (empty($obj->entity) ? '' : $obj->entity) : ''), 'hash'));
|
||||
}
|
||||
/*
|
||||
if ($mode == 1) {
|
||||
|
|
@ -160,7 +160,7 @@ function getOnlineSignatureUrl($mode, $type, $ref = '', $localorexternal = 1, $o
|
|||
if ($mode == 1) {
|
||||
$out .= "hash('".$securekeyseed."' + '".$type."' + contract_ref)";
|
||||
} else {
|
||||
$out .= '&securekey='.urlencode(dol_hash($securekeyseed.$type.$ref.(isModEnabled('multicompany') ? (empty($obj->entity) ? '' : (int) $obj->entity) : ''), '0'));
|
||||
$out .= '&securekey='.urlencode(dol_hash($securekeyseed.$type.$ref.(isModEnabled('multicompany') ? (empty($obj->entity) ? '' : (int) $obj->entity) : ''), 'hash'));
|
||||
}
|
||||
} elseif ($type == 'fichinter') {
|
||||
$securekeyseed = getDolGlobalString('FICHINTER_ONLINE_SIGNATURE_SECURITY_TOKEN', $defaultsalt);
|
||||
|
|
@ -180,7 +180,7 @@ function getOnlineSignatureUrl($mode, $type, $ref = '', $localorexternal = 1, $o
|
|||
if ($mode == 1) {
|
||||
$out .= "hash('".$securekeyseed."' + '".$type."' + fichinter_ref)";
|
||||
} else {
|
||||
$out .= '&securekey='.urlencode(dol_hash($securekeyseed.$type.$ref.(isModEnabled('multicompany') ? (empty($obj->entity) ? '' : (int) $obj->entity) : ''), '0'));
|
||||
$out .= '&securekey='.urlencode(dol_hash($securekeyseed.$type.$ref.(isModEnabled('multicompany') ? (empty($obj->entity) ? '' : (int) $obj->entity) : ''), 'hash'));
|
||||
}
|
||||
} else { // For example $type = 'societe_rib'
|
||||
$securekeyseed = getDolGlobalString(dol_strtoupper($type).'_ONLINE_SIGNATURE_SECURITY_TOKEN', $defaultsalt);
|
||||
|
|
@ -200,7 +200,7 @@ function getOnlineSignatureUrl($mode, $type, $ref = '', $localorexternal = 1, $o
|
|||
if ($mode == 1) {
|
||||
$out .= "hash('".$securekeyseed."' + '".$type."' + $type + '_ref)";
|
||||
} else {
|
||||
$out .= '&securekey='.urlencode(dol_hash($securekeyseed.$type.$ref.(!isModEnabled('multicompany') ? '' : $obj->entity), '0'));
|
||||
$out .= '&securekey='.urlencode(dol_hash($securekeyseed.$type.$ref.(isModEnabled('multicompany') ? (empty($obj->entity) ? '' : (int) $obj->entity) : ''), 'hash'));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -52,13 +52,6 @@ if (is_numeric($entity)) {
|
|||
|
||||
// Load Dolibarr environment
|
||||
require '../../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php';
|
||||
|
||||
/**
|
||||
* @var Conf $conf
|
||||
* @var DoliDB $db
|
||||
|
|
@ -69,6 +62,12 @@ require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php';
|
|||
*
|
||||
* @var string $dolibarr_main_url_root
|
||||
*/
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php';
|
||||
|
||||
// Load translation files
|
||||
$langs->loadLangs(array("main", "other", "dict", "bills", "companies", "errors", "members", "paybox", "stripe", "propal", "commercial"));
|
||||
|
|
@ -157,7 +156,7 @@ if ($source == 'proposal') {
|
|||
} elseif ($source == 'societe_rib') {
|
||||
$securekeyseed = getDolGlobalString('SOCIETE_RIB_ONLINE_SIGNATURE_SECURITY_TOKEN', $defaultsalt);
|
||||
}
|
||||
if (!dol_verifyHash($securekeyseed.$type.$ref.(isModEnabled('multicompany') ? $entity : ''), $SECUREKEY, '0')) {
|
||||
if (!dol_verifyHash($securekeyseed.$type.$ref.(isModEnabled('multicompany') ? $entity : ''), $SECUREKEY, 'hash')) {
|
||||
httponly_accessforbidden('Bad value for securitykey. Value provided '.dol_escape_htmltag($SECUREKEY).' does not match expected value for ref='.dol_escape_htmltag($ref), 403, 1);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue