Hanno Böck commited on 2016-10-21 19:21:05
Zeige 1 geänderte Dateien mit 6 Einfügungen und 36 Löschungen.
| ... | ... |
@@ -15,50 +15,20 @@ Nevertheless, in case you use a significant part of this code, we ask (but not r |
| 15 | 15 |
*/ |
| 16 | 16 |
|
| 17 | 17 |
require_once('inc/error.php');
|
| 18 |
+require_once('vendor/autoload.php');
|
|
| 18 | 19 |
|
| 19 | 20 |
|
| 20 |
-function strong_password($password) |
|
| 21 |
+function strong_password($password, $user = array()) |
|
| 21 | 22 |
{
|
| 22 |
- if ($password == '' || strlen($password) < 4) {
|
|
| 23 |
- DEBUG("Passwort zu kurz!");
|
|
| 24 |
- return "Passwort ist zu kurz!"; |
|
| 25 |
- } |
|
| 23 |
+ $passwordchecker = new ZxcvbnPhp\Zxcvbn(); |
|
| 24 |
+ $strength = $passwordchecker->passwordStrength($password, $user); |
|
| 26 | 25 |
|
| 27 |
- if (! function_exists("crack_opendict"))
|
|
| 28 |
- {
|
|
| 29 |
- DEBUG("cracklib not available!");
|
|
| 30 |
- return true; |
|
| 26 |
+ if ($strength['score'] < 2) {
|
|
| 27 |
+ return "Das Passwort ist zu einfach!"; |
|
| 31 | 28 |
} |
| 32 |
- if (config('use_cracklib') === NULL or config('use_cracklib') === false) {
|
|
| 33 |
- DEBUG('Cracklib deaktiviert');
|
|
| 34 |
- return true; |
|
| 35 |
- } |
|
| 36 |
- DEBUG("Öffne Wörterbuch: ".config('cracklib_dict'));
|
|
| 37 |
- if (! ($dict = crack_opendict(config('cracklib_dict'))))
|
|
| 38 |
- {
|
|
| 39 |
- logger(LOG_ERR, "inc/security", "cracklib", "could not open cracklib-dictionary »".config('cracklib_dict')."«");
|
|
| 40 |
- #system_failure("Kann Crack-Lib-Wörterbuch nicht öffnen: ".config('cracklib_dict'));
|
|
| 41 |
- DEBUG('cracklib tut nicht, dann wird das PW akzeptiert');
|
|
| 42 |
- warning('Das Passwort konnte aufgrund eines internen Fehlers nicht auf die Passwortstärke geprüft werden.');
|
|
| 43 |
- return true; |
|
| 44 |
- } |
|
| 45 |
- // Führe eine Überprüfung des Passworts durch |
|
| 46 |
- $check = crack_check($dict, $password); |
|
| 47 |
- |
|
| 48 |
- $message = crack_getlastmessage(); |
|
| 49 |
- crack_closedict($dict); |
|
| 50 | 29 |
|
| 51 |
- if ($check === True) |
|
| 52 |
- {
|
|
| 53 |
- DEBUG("Passwort ok");
|
|
| 54 | 30 |
return true; |
| 55 | 31 |
} |
| 56 |
- else |
|
| 57 |
- {
|
|
| 58 |
- DEBUG("Passwort nicht ok: {$message}");
|
|
| 59 |
- return $message; |
|
| 60 |
- } |
|
| 61 |
-} |
|
| 62 | 32 |
|
| 63 | 33 |
|
| 64 | 34 |
function filter_input_general( $input ) |
| 65 | 35 |