Skip to content

Commit fc420ad

Browse files
committed
Support userpassword hashes in lowercase
1 parent 4cb5be8 commit fc420ad

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

app/Classes/LDAP/Attribute/Password.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,13 @@ protected static function helpers(): Collection
5252
public static function hash(string $password): ?Attribute\Password\Base
5353
{
5454
$m = [];
55-
preg_match('/^{([A-Z0-9]+)}(.*)$/',$password,$m);
55+
preg_match('/^{([a-zA-Z0-9]+)}(.*)$/',$password,$m);
5656

57-
$hash = \Arr::get($m,1,'*clear*');
57+
$hash = strtoupper($x=\Arr::get($m,1,'*clear*'));
58+
59+
// If our hash in the password is not in upper case, then convert it, as we use uppercase hashes to find the right class
60+
if ($hash !== $x)
61+
$password = preg_replace('/^{'.$x.'}/','{'.$hash.'}',$password);
5862

5963
if (($potential=static::helpers()->filter(fn($hasher)=>str_starts_with($hasher::key,$hash)))->count() > 1) {
6064
foreach ($potential as $item) {

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('/^[\da-zA-Z]{2}/',self::password($password));
14+
return preg_match('/^[\w]{2}/',self::password($password));
1515
}
1616

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

config/ldap.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@
165165
],
166166
sprintf('userpassword.%s%s.*',\App\Ldap\Entry::TAG_NOTAG,\App\Ldap\Entry::TAG_HELPER) => [
167167
'nullable',
168-
'min:4'
168+
'min:3'
169169
],
170170
sprintf('userpassword.%s.*',\App\Ldap\Entry::TAG_NOTAG) => [
171171
'nullable',

0 commit comments

Comments
 (0)