Skip to content

Commit b27637d

Browse files
committed
Further userpassword enhancement for #387. CRYPT passwords can start with a period and slash. Further, if we dont find a Password helper, we'll assume clear. Closes #397
1 parent 66949f0 commit b27637d

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

app/Classes/LDAP/Attribute/Password.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ final class Password extends Attribute
1717
{
1818
use MD5Updates;
1919

20+
private const LOGKEY = 'AP-';
21+
2022
public const obfuscate = '****************';
2123

2224
protected(set) bool $no_attr_tags = TRUE;
@@ -66,10 +68,14 @@ public static function hash(string $password): ?Attribute\Password\Base
6668
return new $item;
6769
}
6870

69-
throw new \Exception(sprintf('Couldnt figure out a password hash for %s',$password));
71+
// If we get here, we'll treat it as clear text
72+
\Log::alert(sprintf('%s:? Couldnt figure out a password hash for %s, assuming CLEAR',self::LOGKEY,$password));
73+
return new Attribute\Password\Clear;
7074

75+
// No Password type candidates, we'll treat it as clear text
7176
} elseif (! $potential->count()) {
72-
throw new \Exception(sprintf('Couldnt figure out a password hash for %s',$password));
77+
\Log::alert(sprintf('%s:? Couldnt figure out a password hash for %s, no candidates, assuming CLEAR',self::LOGKEY,$password));
78+
return new Attribute\Password\Clear;
7379
}
7480

7581
return new ($potential->pop());

app/Classes/LDAP/Attribute/Password/Crypt.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ final class Crypt extends Base
1111

1212
public static function subid(string $password): bool
1313
{
14-
return preg_match('/^[\w]{2}/',self::password($password));
14+
return preg_match('/^[.\/\w]{2}/',self::password($password));
1515
}
1616

1717
public function compare(string $source,string $compare): bool

0 commit comments

Comments
 (0)