|
dolibarr
13.0.2
|
Set of function used for dolibarr security (common function included into filefunc.inc.php) Warning, this file must not depends on other library files, except function.lib.php because it is used at low code level. More...
Go to the source code of this file.
Functions | |
| dol_encode ($chain, $key= '1') | |
| Encode a string with base 64 algorithm + specific delta change. More... | |
| dol_decode ($chain, $key= '1') | |
| Decode a base 64 encoded + specific delta change. More... | |
| dol_hash ($chain, $type= '0') | |
| Returns a hash of a string. More... | |
| dol_verifyHash ($chain, $hash, $type= '0') | |
| Compute a hash and compare it to the given one For backward compatibility reasons, if the hash is not in the password_hash format, we will try to match against md5 and sha1md5 If constant MAIN_SECURITY_HASH_ALGO is defined, we use this function as hashing function. More... | |
| restrictedArea ($user, $features, $objectid=0, $tableandshare= '', $feature2= '', $dbt_keyfield= 'fk_soc', $dbt_select= 'rowid', $isdraft=0) | |
| Check permissions of a user to show a page and an object. More... | |
| checkUserAccessToObject ($user, $featuresarray, $objectid=0, $tableandshare= '', $feature2= '', $dbt_keyfield= '', $dbt_select= 'rowid', $parenttableforentity= '') | |
| Check access by user to object. More... | |
| accessforbidden ($message= '', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null) | |
| Show a message to say access is forbidden and stop program Calling this function terminate execution of PHP. More... | |
Set of function used for dolibarr security (common function included into filefunc.inc.php) Warning, this file must not depends on other library files, except function.lib.php because it is used at low code level.
Definition in file security.lib.php.
| accessforbidden | ( | $message = '', |
|
$printheader = 1, |
|||
$printfooter = 1, |
|||
$showonlymessage = 0, |
|||
$params = null |
|||
| ) |
Show a message to say access is forbidden and stop program Calling this function terminate execution of PHP.
| string | $message | Force error message |
| int | $printheader | Show header before |
| int | $printfooter | Show footer after |
| int | $showonlymessage | Show only message parameter. Otherwise add more information. |
| array | null | $params | More parameters provided to hook |
Definition at line 649 of file security.lib.php.
References llxFooter(), llxHeader(), llxHeaderVierge(), and print.
Referenced by restrictedArea().
| checkUserAccessToObject | ( | $user, | |
| $featuresarray, | |||
$objectid = 0, |
|||
$tableandshare = '', |
|||
$feature2 = '', |
|||
$dbt_keyfield = '', |
|||
$dbt_select = 'rowid', |
|||
$parenttableforentity = '' |
|||
| ) |
Check access by user to object.
This function is also called by restrictedArea
| User | $user | User to check |
| array | $featuresarray | Features/modules to check. Example: ('user','service','member','project','task',...) |
| int | string | $objectid | Object ID if we want to check a particular record (optional) is linked to a owned thirdparty (optional). |
| string | $tableandshare | 'TableName&SharedElement' with Tablename is table where object is stored. SharedElement is an optional key to define where to check entity for multicompany modume. Param not used if objectid is null (optional). |
| string | $feature2 | Feature to check, second level of permission (optional). Can be or check with 'level1|level2'. |
| string | $dbt_keyfield | Field name for socid foreign key if not fk_soc. Not used if objectid is null (optional) |
| string | $dbt_select | Field name for select if not rowid. Not used if objectid is null (optional) |
| string | $parenttableforentity | Parent table for entity. Example 'fk_website' |
Definition at line 427 of file security.lib.php.
References $resql, and dol_print_error().
Referenced by DolibarrApi\_checkAccessToResource(), and restrictedArea().
| dol_decode | ( | $chain, | |
$key = '1' |
|||
| ) |
Decode a base 64 encoded + specific delta change.
This function is called by filefunc.inc.php at each page call.
| string | $chain | string to decode |
| string | $key | rule to use for delta ('0', '1' or 'myownkey') |
Definition at line 73 of file security.lib.php.
References dol_strlen().
Referenced by encodedecode_dbpassconf(), and print_paybox_redirect().
| dol_encode | ( | $chain, | |
$key = '1' |
|||
| ) |
Encode a string with base 64 algorithm + specific delta change.
| string | $chain | string to encode |
| string | $key | rule to use for delta ('0', '1' or 'myownkey') |
Definition at line 38 of file security.lib.php.
References dol_strlen().
Referenced by encodedecode_dbpassconf().
| dol_hash | ( | $chain, | |
$type = '0' |
|||
| ) |
Returns a hash of a string.
If constant MAIN_SECURITY_HASH_ALGO is defined, we use this function as hashing function (recommanded value is 'password_hash') If constant MAIN_SECURITY_SALT is defined, we use it as a salt (used only if hashing algorightm is something else than 'password_hash').
| string | $chain | String to hash |
| string | $type | Type of hash ('0':auto will use MAIN_SECURITY_HASH_ALGO else md5, '1':sha1, '2':sha1+md5, '3':md5, '4':md5 for OpenLdap with no salt, '5':sha256). Use '3' here, if hash is not needed for security purpose, for security need, prefer '0'. |
Definition at line 113 of file security.lib.php.
Referenced by MailmanSpip\add_to_spip(), MailingTargets\addTargetsToDatabase(), BlockedLog\checkSignature(), EcmFiles\create(), BlockedLog\create(), dol_verifyHash(), CMailFile\findHtmlImages(), BlockedLog\getSignature(), Login\index(), RssParser\parser(), User\send_password(), SMTPs\setAttachment(), SMTPs\setBodyContent(), SMTPs\setImageInline(), Adherent\setPassword(), and User\setPassword().
| dol_verifyHash | ( | $chain, | |
| $hash, | |||
$type = '0' |
|||
| ) |
Compute a hash and compare it to the given one For backward compatibility reasons, if the hash is not in the password_hash format, we will try to match against md5 and sha1md5 If constant MAIN_SECURITY_HASH_ALGO is defined, we use this function as hashing function.
If constant MAIN_SECURITY_SALT is defined, we use it as a salt.
| string | $chain | String to hash (not hashed string) |
| string | $hash | hash to compare |
| string | $type | Type of hash ('0':auto, '1':sha1, '2':sha1+md5, '3':md5, '4':md5 for OpenLdap, '5':sha256). Use '3' here, if hash is not needed for security purpose, for security need, prefer '0'. |
Definition at line 149 of file security.lib.php.
References dol_hash().
Referenced by check_user_password_dolibarr().
| restrictedArea | ( | $user, | |
| $features, | |||
$objectid = 0, |
|||
$tableandshare = '', |
|||
$feature2 = '', |
|||
$dbt_keyfield = 'fk_soc', |
|||
$dbt_select = 'rowid', |
|||
$isdraft = 0 |
|||
| ) |
Check permissions of a user to show a page and an object.
Check read permission. If GETPOST('action','aZ09') defined, we also check write and delete permission. This method check permission on module then call checkUserAccessToObject() for permission on object (according to entity and socid of user).
| User | $user | User to check |
| string | $features | Features to check (it must be module $object->element. Examples: 'societe', 'contact', 'produit&service', 'produit|service', ...) |
| int | $objectid | Object ID if we want to check a particular record (optional) is linked to a owned thirdparty (optional). |
| string | $tableandshare | 'TableName&SharedElement' with Tablename is table where object is stored. SharedElement is an optional key to define where to check entity for multicompany module. Param not used if objectid is null (optional). |
| string | $feature2 | Feature to check, second level of permission (optional). Can be a 'or' check with 'sublevela|sublevelb'. |
| string | $dbt_keyfield | Field name for socid foreign key if not fk_soc. Not used if objectid is null (optional) |
| string | $dbt_select | Field name for select if not rowid. Not used if objectid is null (optional) |
| int | $isdraft | 1=The object with id=$objectid is a draft |
Definition at line 181 of file security.lib.php.
References accessforbidden(), checkUserAccessToObject(), and GETPOST().