dolibarr  21.0.0-alpha
Functions
security2.lib.php File Reference

Set of function used for dolibarr security (not common functions). More...

Go to the source code of this file.

Functions

 dol_getwebuser ($mode)
 Return user/group account of web server. More...
 
 checkLoginPassEntity ($usertotest, $passwordtotest, $entitytotest, $authmode, $context='')
 Return a login if login/pass was successful. More...
 
if(!function_exists('dol_loginfunction')) makesalt ($type=CRYPT_SALT_LENGTH)
 Initialise the salt for the crypt function. More...
 
 encodedecode_dbpassconf ($level=0)
 Encode or decode database password in config file. More...
 
 getRandomPassword ($generic=false, $replaceambiguouschars=null, $length=32)
 Return a generated password using default module. More...
 
 dolJSToSetRandomPassword ($htmlname, $htmlnameofbutton='generate_token', $generic=1)
 Output javascript to autoset a generated password using default module into a HTML element. More...
 

Detailed Description

Set of function used for dolibarr security (not common functions).

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 security2.lib.php.

Function Documentation

◆ checkLoginPassEntity()

checkLoginPassEntity (   $usertotest,
  $passwordtotest,
  $entitytotest,
  $authmode,
  $context = '' 
)

Return a login if login/pass was successful.

Parameters
string$usertotestLogin value to test
string$passwordtotestPassword value to test
string$entitytotestInstance of data we must check
array$authmodeArray list of selected authentication mode array('http', 'dolibarr', 'xxx'...)
string$contextContext checkLoginPassEntity was created for ('api', 'dav', 'ws', '')
Returns
string Login or '' or '–bad-login-validity–'

Show Dolibarr default login page. Part of this code is also duplicated into main.inc.php::top_htmlhead

Parameters
Translate$langsLang object (must be initialized by a new).
Conf$confConf object
Societe$mysocCompany object
Returns
void

Definition at line 58 of file security2.lib.php.

◆ dol_getwebuser()

dol_getwebuser (   $mode)

Return user/group account of web server.

Parameters
string$mode'user' or 'group'
Returns
string Return user or group of web server

Definition at line 36 of file security2.lib.php.

◆ dolJSToSetRandomPassword()

dolJSToSetRandomPassword (   $htmlname,
  $htmlnameofbutton = 'generate_token',
  $generic = 1 
)

Output javascript to autoset a generated password using default module into a HTML element.

Parameters
string$htmlnameHTML name of element to insert key into
string$htmlnameofbuttonHTML name of button
int$generic1=Return a generic pass, 0=Return a pass following setup rules
Returns
string HTML javascript code to set a password
See also
getRandomPassword()

Definition at line 574 of file security2.lib.php.

◆ encodedecode_dbpassconf()

encodedecode_dbpassconf (   $level = 0)

Encode or decode database password in config file.

Parameters
int$levelEncode level: 0 no encoding, 1 encoding
Returns
int Return integer <0 if KO, >0 if OK

Definition at line 383 of file security2.lib.php.

◆ getRandomPassword()

getRandomPassword (   $generic = false,
  $replaceambiguouschars = null,
  $length = 32 
)

Return a generated password using default module.

Parameters
boolean$generictrue=Create generic password (32 chars/numbers), false=Use the configured password generation module
array$replaceambiguouscharsDiscard ambiguous characters. For example array('I').
int$lengthLength of random string (Used only if $generic is true)
Returns
string New value for password
See also
dol_hash(), dolJSToSetRandomPassword()

Definition at line 488 of file security2.lib.php.

◆ makesalt()

if (!function_exists( 'dol_loginfunction')) makesalt (   $type = CRYPT_SALT_LENGTH)

Initialise the salt for the crypt function.

Parameters
int$type2 =>Return a salt for DES encryption 12=>Return a salt for MD5 encryption Undefined=>Return a salt for default encryption
Returns
string Salt string

Definition at line 346 of file security2.lib.php.