Release 2.20.0 (#4987)
This commit is contained in:
@@ -77,7 +77,7 @@ final class LdapAuthenticator implements AuthenticationEntryPointInterface, Inte
|
||||
public function start(Request $request, AuthenticationException $authException = null): Response
|
||||
{
|
||||
if (!$this->authenticator instanceof AuthenticationEntryPointInterface) {
|
||||
throw new NotAnEntryPointException(sprintf('Decorated authenticator "%s" does not implement interface "%s".', get_debug_type($this->authenticator), AuthenticationEntryPointInterface::class));
|
||||
throw new NotAnEntryPointException(\sprintf('Decorated authenticator "%s" does not implement interface "%s".', get_debug_type($this->authenticator), AuthenticationEntryPointInterface::class));
|
||||
}
|
||||
|
||||
return $this->authenticator->start($request, $authException);
|
||||
|
||||
@@ -41,7 +41,7 @@ final class LdapCredentialsSubscriber implements EventSubscriberInterface
|
||||
}
|
||||
|
||||
if (!$passport instanceof Passport || !$passport->hasBadge(PasswordCredentials::class)) {
|
||||
throw new \LogicException(sprintf('LDAP authentication requires a passport containing a user and password credentials, authenticator "%s" does not fulfill these requirements.', \get_class($event->getAuthenticator())));
|
||||
throw new \LogicException(\sprintf('LDAP authentication requires a passport containing a user and password credentials, authenticator "%s" does not fulfill these requirements.', \get_class($event->getAuthenticator())));
|
||||
}
|
||||
|
||||
/** @var PasswordCredentials $passwordCredentials */
|
||||
|
||||
@@ -60,10 +60,10 @@ class LdapManager
|
||||
$filters[] = $params['filter'];
|
||||
foreach ($criteria as $key => $value) {
|
||||
$value = ldap_escape($value, '', LDAP_ESCAPE_FILTER);
|
||||
$filters[] = sprintf('(%s=%s)', $key, $value);
|
||||
$filters[] = \sprintf('(%s=%s)', $key, $value);
|
||||
}
|
||||
|
||||
return sprintf('(%s%s)', $condition, implode($filters));
|
||||
return \sprintf('(%s%s)', $condition, implode($filters));
|
||||
}
|
||||
|
||||
public function bind(string $dn, string $password): bool
|
||||
@@ -84,7 +84,7 @@ class LdapManager
|
||||
// always look up the users current DN first, as the current user might be upgraded from local to LDAP
|
||||
$userFresh = $this->findUserByUsername($user->getUserIdentifier());
|
||||
if (null === $userFresh || null === ($baseDn = $userFresh->getPreferenceValue('ldap_dn'))) {
|
||||
throw new LdapDriverException(sprintf('Failed fetching user DN for %s', $user->getUserIdentifier()));
|
||||
throw new LdapDriverException(\sprintf('Failed fetching user DN for %s', $user->getUserIdentifier()));
|
||||
}
|
||||
$user->setPreferenceValue('ldap_dn', $baseDn);
|
||||
|
||||
@@ -128,7 +128,7 @@ class LdapManager
|
||||
|
||||
return $this->driver->search(
|
||||
$roleParameter['baseDn'],
|
||||
sprintf('(&%s(%s=%s))', $filter, $roleParameter['userDnAttribute'], ldap_escape($dn, '', LDAP_ESCAPE_FILTER)),
|
||||
\sprintf('(&%s(%s=%s))', $filter, $roleParameter['userDnAttribute'], ldap_escape($dn, '', LDAP_ESCAPE_FILTER)),
|
||||
[$roleParameter['nameAttribute']]
|
||||
);
|
||||
}
|
||||
@@ -200,7 +200,7 @@ class LdapManager
|
||||
}
|
||||
|
||||
if (!$mapped) {
|
||||
$roleName = sprintf('ROLE_%s', self::slugify($roleName));
|
||||
$roleName = \sprintf('ROLE_%s', self::slugify($roleName));
|
||||
}
|
||||
|
||||
if (!\in_array($roleName, $allowedRoles, true)) {
|
||||
|
||||
@@ -35,7 +35,7 @@ final class LdapUserProvider implements UserProviderInterface
|
||||
'username' => $identifier,
|
||||
'result' => 'not found',
|
||||
]);
|
||||
$ex = new UserNotFoundException(sprintf('User "%s" not found', $identifier));
|
||||
$ex = new UserNotFoundException(\sprintf('User "%s" not found', $identifier));
|
||||
$ex->setUserIdentifier($identifier);
|
||||
|
||||
throw $ex;
|
||||
@@ -53,17 +53,17 @@ final class LdapUserProvider implements UserProviderInterface
|
||||
public function refreshUser(UserInterface $user): UserInterface
|
||||
{
|
||||
if (!($user instanceof User)) {
|
||||
throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', \get_class($user)));
|
||||
throw new UnsupportedUserException(\sprintf('Instances of "%s" are not supported.', \get_class($user)));
|
||||
}
|
||||
|
||||
if (!$user->isLdapUser()) {
|
||||
throw new UnsupportedUserException(sprintf('Account "%s" is not a registered LDAP user.', $user->getUserIdentifier()));
|
||||
throw new UnsupportedUserException(\sprintf('Account "%s" is not a registered LDAP user.', $user->getUserIdentifier()));
|
||||
}
|
||||
|
||||
try {
|
||||
$this->ldapManager->updateUser($user);
|
||||
} catch (LdapDriverException $ex) {
|
||||
throw new UnsupportedUserException(sprintf('Failed to refresh user "%s", probably DN is expired.', $user->getUserIdentifier()));
|
||||
throw new UnsupportedUserException(\sprintf('Failed to refresh user "%s", probably DN is expired.', $user->getUserIdentifier()));
|
||||
}
|
||||
|
||||
return $user;
|
||||
|
||||
Reference in New Issue
Block a user