Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Schwan <carl@carlschwan.eu>2022-05-02 22:46:42 +0300
committerbackportbot-nextcloud[bot] <backportbot-nextcloud[bot]@users.noreply.github.com>2022-05-05 19:59:49 +0300
commit22831d27e4a152116faadf6c9d0177354ed9cab6 (patch)
tree1b3fbea56e36f9a936083b8abd1fc247415e037e
parent0b7cc5f9605d7e29a95b4e49ebfd56250d89d5e3 (diff)
Don't use slow hashing to check the LDAP bindingbackport/32246/stable23
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, so use a fast hashing algorythm. Signed-off-by: Carl Schwan <carl@carlschwan.eu>
-rw-r--r--apps/user_ldap/lib/Connection.php11
1 files changed, 3 insertions, 8 deletions
diff --git a/apps/user_ldap/lib/Connection.php b/apps/user_ldap/lib/Connection.php
index 4abea708a0d..bfddee56658 100644
--- a/apps/user_ldap/lib/Connection.php
+++ b/apps/user_ldap/lib/Connection.php
@@ -125,7 +125,7 @@ class Connection extends LDAPUtility {
protected $ignoreValidation = false;
/**
- * @var array{dn?: mixed, hash?: string, result?: bool}
+ * @var array{sum?: string, result?: bool}
*/
protected $bindResult = [];
@@ -669,11 +669,7 @@ class Connection extends LDAPUtility {
if (
count($this->bindResult) !== 0
- && $this->bindResult['dn'] === $this->configuration->ldapAgentName
- && \OC::$server->getHasher()->verify(
- $this->configPrefix . $this->configuration->ldapAgentPassword,
- $this->bindResult['hash']
- )
+ && $this->bindResult['sum'] === md5($this->configuration->ldapAgentName . $this->configPrefix . $this->configuration->ldapAgentPassword)
) {
// don't attempt to bind again with the same data as before
// bind might have been invoked via getConnectionResource(),
@@ -686,8 +682,7 @@ class Connection extends LDAPUtility {
$this->configuration->ldapAgentPassword);
$this->bindResult = [
- 'dn' => $this->configuration->ldapAgentName,
- 'hash' => \OC::$server->getHasher()->hash($this->configPrefix . $this->configuration->ldapAgentPassword),
+ 'sum' => md5($this->configuration->ldapAgentName . $this->configPrefix . $this->configuration->ldapAgentPassword),
'result' => $ldapLogin,
];