LSattr_ldap :: password : Added encode_function feature

This commit is contained in:
Benjamin Renard 2011-04-08 17:07:43 +02:00
parent c8704c9bd7
commit 5241ac4214
5 changed files with 1529 additions and 1495 deletions

View file

@ -7,6 +7,7 @@
<citetitle>Structure</citetitle>... <citetitle>Structure</citetitle>...
<![CDATA['ldap_options' => array ( <![CDATA['ldap_options' => array (
'encode' => '[Type d'encodage du mot de passe]', 'encode' => '[Type d'encodage du mot de passe]',
'encode_function' => '[Nom de la fonction d'encodage]',
'no_random_crypt_salt' => '[Booléen]', // Désactivation de l'utilisation d'une salt aléatoire 'no_random_crypt_salt' => '[Booléen]', // Désactivation de l'utilisation d'une salt aléatoire
'wildcardPassword' => '[mot de passe(s) en clair]', 'wildcardPassword' => '[mot de passe(s) en clair]',
'encodedWildcardPassword' => '[mot de passe(s) encodé(s)]' 'encodedWildcardPassword' => '[mot de passe(s) encodé(s)]'
@ -41,6 +42,15 @@
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term>encode_function</term>
<listitem>
<para>Nom d'une function qui sera utilisée afin d'encoder le mot de passe.
Cette fonction recevra deux paramètres : le <literal>LSldapObject</literal>
et le mot de passe en clair.</para>
</listitem>
</varlistentry>
<varlistentry> <varlistentry>
<term>no_random_crypt_salt</term> <term>no_random_crypt_salt</term>
<listitem> <listitem>

View file

@ -91,7 +91,16 @@ class LSattr_ldap_password extends LSattr_ldap {
* @retval strinf The encode password * @retval strinf The encode password
*/ */
function encodePassword($clearPassword) { function encodePassword($clearPassword) {
if (!$this -> config['ldap_options']['encode']) { if (isset($this -> config['ldap_options']['encode_function']) || $this -> config['ldap_options']['encode']=='function') {
if (!is_callable($this -> config['ldap_options']['encode_function'])) {
$this -> config['ldap_options']['encode'] = 'clear';
LSerror :: addErrorCode('LSattr_ldap_password_02',$this -> config['ldap_options']['encode_function']);
}
else {
$this -> config['ldap_options']['encode'] = 'function';
}
}
elseif (!$this -> config['ldap_options']['encode']) {
$this -> config['ldap_options']['encode'] = 'md5crypt'; $this -> config['ldap_options']['encode'] = 'md5crypt';
} }
switch($this -> config['ldap_options']['encode']) { switch($this -> config['ldap_options']['encode']) {
@ -163,6 +172,9 @@ class LSattr_ldap_password extends LSattr_ldap {
case 'clear': case 'clear':
return $clearPassword; return $clearPassword;
break; break;
case 'function':
return $this -> config['ldap_options']['encode_function']($this -> attribute -> ldapObject, $clearPassword);
break;
} }
LSerror :: addErrorCode('LSattr_ldap_password_01',$this -> config['ldap_options']['encode']); LSerror :: addErrorCode('LSattr_ldap_password_01',$this -> config['ldap_options']['encode']);
return $clearPassword; return $clearPassword;
@ -201,4 +213,8 @@ class LSattr_ldap_password extends LSattr_ldap {
LSerror :: defineError('LSattr_ldap_password_01', LSerror :: defineError('LSattr_ldap_password_01',
_("LSattr_ldap_password : Encoding type %{type} is not supported. This password will be stored in clear text.") _("LSattr_ldap_password : Encoding type %{type} is not supported. This password will be stored in clear text.")
); );
LSerror :: defineError('LSattr_ldap_password_02',
_("LSattr_ldap_password : Encoding function %{function} is not callable. This password will be stored in clear text.")
);
?> ?>

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff