Skip to content

Commit e3e3e6e

Browse files
committed
Don't use slow hashing to check the LDAP binding
using password_hash is expensive and should be used for hashing passwords when saving them in the database. Here we just want to see if the bind was already done with the given password. Signed-off-by: Carl Schwan <carl@carlschwan.eu>
1 parent f7413b9 commit e3e3e6e

1 file changed

Lines changed: 2 additions & 5 deletions

File tree

apps/user_ldap/lib/Connection.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -673,10 +673,7 @@ public function bind() {
673673
if (
674674
count($this->bindResult) !== 0
675675
&& $this->bindResult['dn'] === $this->configuration->ldapAgentName
676-
&& \OC::$server->getHasher()->verify(
677-
$this->configPrefix . $this->configuration->ldapAgentPassword,
678-
$this->bindResult['hash']
679-
)
676+
&& md5($this->configPrefix . $this->configuration->ldapAgentPassword) === $this->bindResult['hash']
680677
) {
681678
// don't attempt to bind again with the same data as before
682679
// bind might have been invoked via getConnectionResource(),
@@ -690,7 +687,7 @@ public function bind() {
690687

691688
$this->bindResult = [
692689
'dn' => $this->configuration->ldapAgentName,
693-
'hash' => \OC::$server->getHasher()->hash($this->configPrefix . $this->configuration->ldapAgentPassword),
690+
'hash' => md5($this->configPrefix . $this->configuration->ldapAgentPassword),
694691
'result' => $ldapLogin,
695692
];
696693

0 commit comments

Comments
 (0)