瀏覽代碼

Start to introduce dolibarr_main_dolcrypt_key

Laurent Destailleur 1 年之前
父節點
當前提交
6e18d1b7ab
共有 2 個文件被更改,包括 17 次插入2 次删除
  1. 12 1
      htdocs/conf/conf.php.example
  2. 5 1
      htdocs/core/lib/security.lib.php

+ 12 - 1
htdocs/conf/conf.php.example

@@ -186,7 +186,7 @@ $dolibarr_main_db_readonly=0;
 // dolibarr_main_instance_unique_id
 // ================================
 // An secret ID that is unique for each installation.
-// This value is also visible and never propagated outside of Dolibarr, so it can be used as a salt / key for some encryption (For example to get
+// This value is also never visible and never propagated outside of Dolibarr, so it can be used as a salt / key for some encryption (For example to get
 //  a unique hashed key, application will hash the value concatenated with a string. Example: md5('dolibarr'+dolibarr_main_instance_unique_id)
 // WARNING: Changing this value will also make some sensitive values encrypted in database wrong.
 // Default value: randomly defined during installation
@@ -196,6 +196,17 @@ $dolibarr_main_db_readonly=0;
 $dolibarr_main_instance_unique_id='84b5bc91f83b56e458db71e0adac2b62';
 
 
+// dolibarr_main_dolcrypt_key
+// ==========================
+// An secret key to encrypt/decrypt data with dolcrypt() method, for reversible encryption.
+// This value is also never visible and never propagated outside of Dolibarr, it is used as key for the dolcrypt encryption.
+// WARNING: Changing this value will also make some sensitive values encrypted in database wrong.
+// Default value: ''. When not defined, the $dolibarr_main_instance_unique_id will be used instead.
+// Examples:
+// $dolibarr_main_dolcrypt_key='';
+//
+$dolibarr_main_dolcrypt_key='';
+
 
 //##################
 // Login

+ 5 - 1
htdocs/core/lib/security.lib.php

@@ -187,7 +187,11 @@ function dolDecrypt($chain, $key = '')
 	}
 
 	if (empty($key)) {
-		$key = $conf->file->instance_unique_id;
+		if (!empty($conf->file->dolcrypt_key)) {
+			$key = $conf->file->dolcrypt_key;
+		} else {
+			$key = $conf->file->instance_unique_id;
+		}
 	}
 
 	//var_dump('key='.$key);