From a46ec9a1723f408a6607b282f5e898f4bcb9a73d Mon Sep 17 00:00:00 2001 From: Tim van Dijen Date: Sun, 7 Apr 2024 17:05:34 +0200 Subject: [PATCH] Fix unit tests --- composer.json | 3 ++- src/Auth/Source/X509userCert.php | 4 +++- tools/composer-require-checker.json | 3 +-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index 3bd5e20..0bcf980 100644 --- a/composer.json +++ b/composer.json @@ -48,7 +48,8 @@ "simplesamlphp/simplesamlphp": "^2.2", "simplesamlphp/simplesamlphp-module-ldap": "^2.2", "symfony/http-foundation": "^6.4", - "symfony/ldap": "^6.4" + "symfony/ldap": "^6.4", + "symfony/security-core": "^6.4" }, "require-dev": { "simplesamlphp/simplesamlphp-test-framework": "^1.6.0" diff --git a/src/Auth/Source/X509userCert.php b/src/Auth/Source/X509userCert.php index 256d58f..aaa56b0 100644 --- a/src/Auth/Source/X509userCert.php +++ b/src/Auth/Source/X509userCert.php @@ -15,6 +15,7 @@ use SimpleSAML\Utils; use SimpleSAML\XHTML\Template; use Symfony\Component\Ldap\Entry; +use Symfony\Component\Ldap\Ldap; use Symfony\Component\Ldap\Security\LdapUserProvider; use Symfony\Component\Security\Core\Exception\UserNotFoundException; @@ -279,9 +280,10 @@ public function findUserByAttribute(string $attr, string $value): ?Entry Assert::nullOrnotWhitespaceOnly($searchPassword); $ldap = ConnectorFactory::fromAuthSource($this->backend); + $connection = new Ldap($ldap->getAdapter()); foreach ($searchBase as $base) { - $ldapUserProvider = new LdapUserProvider($ldap, $base, $searchUsername, $searchPassword, [], $attr); + $ldapUserProvider = new LdapUserProvider($connection, $base, $searchUsername, $searchPassword, [], $attr); try { return $ldapUserProvider->loadUserByIdentifier($value)->getEntry(); } catch (UserNotFoundException $e) { diff --git a/tools/composer-require-checker.json b/tools/composer-require-checker.json index 8a6e045..c98b9cd 100644 --- a/tools/composer-require-checker.json +++ b/tools/composer-require-checker.json @@ -2,7 +2,6 @@ "symbol-whitelist": [ "SimpleSAML\\Module\\ldap\\ConfigHelper", "SimpleSAML\\Module\\ldap\\ConnectorFactory", - "SimpleSAML\\Module\\ldap\\ConnectorInterface", - "Symfony\\Component\\Security\\Core\\Exception\\UserNotFoundException" + "SimpleSAML\\Module\\ldap\\ConnectorInterface" ] }