Attention : vous consultez actuellement la documentation dédiée aux versions 1.x de Moodle. La documentation pour les versions 2.x de Moodle est consultable ici : Salage de mot de passe, celle pour les versions 3.x de Moodle est consultable ici : Salage de mot de passe et celle pour Moodle 4.x est consultable là : Salage de mot de passe.

« Salage de mot de passe » : différence entre les versions

De MoodleDocs
Aller à :navigation, rechercher
(Page créée avec « {{En cours de traduction}} ==Qu'est-ce que le salage de mot de passe ?== Dans la base de données de Moodle, les mots de passe sont stockés sous forme cryptée, que l'on ap... »)
 
Aucun résumé des modifications
Ligne 69 : Ligne 69 :
If a user is deemed valid, the system will upgrade the user's hashed password to the latest salt.
If a user is deemed valid, the system will upgrade the user's hashed password to the latest salt.


[[Category:Security]]
[[Category:Sécurité]]


[[en:Password salting]]
[[es:report/security/report_security_check_passwordsaltmain]]
[[es:report/security/report_security_check_passwordsaltmain]]

Version du 19 novembre 2009 à 12:09

Remarque : la traduction de cet article n'est pas terminée. N'hésitez pas à traduire tout ou partie de cette page ou à la compléter. Vous pouvez aussi utiliser la page de discussion pour vos recommandations et suggestions d'améliorations.


Qu'est-ce que le salage de mot de passe ?

Dans la base de données de Moodle, les mots de passe sont stockés sous forme cryptée, que l'on appelle 'empreinte md5 du mot de passe'.

Le salage de mot de passe est une méthode de rendre l'empreinte des mots de passe plus sûre en ajoutant aux mots de passe une chaîne de caractères aléatoires avant de calculer leur empreinte md5, ce qui rend beaucoup plus complexe l'opération de retrouver le mot de passe à partir de son empreinte. Plus la chaîne aléatoire est longue, et plus cette opération est rendue complexe.

Activer le salage de mot de passe

To set a password salt, add the following line to your config.php file:

$CFG->passwordsaltmain = 'some long random string here with lots of characters';

The random string of characters should be a mix of letters, numbers and other characters. The Moodle Salt Generator may be used to obtain a suitable long random string. A string length of at least 40 characters is recommended.

Note: For security reasons the only way to enable password salting is by editing config.php - there is no way to do so in the Moodle interface.

Changing the salt

If for any reason you wish to change the salt, the old salt must be retained in config.php in addition to the new salt.

passwordsaltmain should be changed to passwordsaltalt1 (note that the exact expressions must be used) for the old salt as follows:

$CFG->passwordsaltalt1 = 'old long random string';
$CFG->passwordsaltmain = 'new long random string';

If you change your salt again in the future, you must retain all the previous salts for some time (until every user has logged in at least once, so they start using the new salt). You can use $CFG->passwordsaltalt2, $CFG->passwordsaltalt3, etc. to keep up to 20 previous salts.

Warning: If you change the salt and do not retain the old one in config.php you will no longer be able to login to your site!

Disabling password salting

Note: Not Recommended! Once enabled, you should leave password salt enabled.

To disable password salting in Moodle, you can delete, comment out, or change the value of passwordsaltmain to "empty"

// EXAMPLE: set to empty string
$CFG->passwordsaltmain = '';


// EXAMPLE: comment out
/*
$CFG->passwordsaltmain = '';
*/

However, you are not done! You must also move the old salt to an "alt" value, just like the "changing the salt" description, above:

$CFG->passwordsaltalt1 = 'old long random string';
$CFG->passwordsaltmain = '';

Importing users from another site

If you import users from another Moodle site which uses a password salt, you need to add the other site's salt to config.php too. Upto 20 alternate salts may be added

$CFG->passwordsaltalt1, $CFG->passwordsaltalt2, ...  $CFG->passwordsaltalt20

How does password salting work?

When a password is checked, the code looks for CFG->passwordsaltmain. If set, it appends the user's password to the salt before calculating the md5 hash.

If the unsalted md5 hash of a user's password validates, it is assumed that the salt was set for the first time since the last time the user logged in. The user's password is upgraded, using the salt.

If neither the unsalted md5 hash, or the salted md5 hash validates, the code looks for up to 20 alternate salts.

If you change salts, in order not to orphan existing user accounts, you must enter the old salt into one of the alternate slots.

When a user who has an "old salt" password logs in, the first test of their authentication with the new salt will fail... then the code will test any alternate salts, looking for one that allows the password to be proven valid.

If a user is deemed valid, the system will upgrade the user's hashed password to the latest salt.