Merge branch '2.8' into 3.0
* 2.8: Fixed issue with blank password with Ldap
This commit is contained in:
commit
5c47d9adc5
@ -73,6 +73,10 @@ class LdapBindAuthenticationProvider extends UserAuthenticationProvider
|
||||
$username = $token->getUsername();
|
||||
$password = $token->getCredentials();
|
||||
|
||||
if ('' === $password) {
|
||||
throw new BadCredentialsException('The presented password must not be empty.');
|
||||
}
|
||||
|
||||
try {
|
||||
$username = $this->ldap->escape($username, '', LDAP_ESCAPE_DN);
|
||||
$dn = str_replace('{username}', $username, $this->dnString);
|
||||
|
@ -21,6 +21,23 @@ use Symfony\Component\Ldap\Exception\ConnectionException;
|
||||
*/
|
||||
class LdapBindAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Security\Core\Exception\BadCredentialsException
|
||||
* @expectedExceptionMessage The presented password must not be empty.
|
||||
*/
|
||||
public function testEmptyPasswordShouldThrowAnException()
|
||||
{
|
||||
$userProvider = $this->getMock('Symfony\Component\Security\Core\User\UserProviderInterface');
|
||||
$ldap = $this->getMock('Symfony\Component\Ldap\LdapClientInterface');
|
||||
$userChecker = $this->getMock('Symfony\Component\Security\Core\User\UserCheckerInterface');
|
||||
|
||||
$provider = new LdapBindAuthenticationProvider($userProvider, $userChecker, 'key', $ldap);
|
||||
$reflection = new \ReflectionMethod($provider, 'checkAuthentication');
|
||||
$reflection->setAccessible(true);
|
||||
|
||||
$reflection->invoke($provider, new User('foo', null), new UsernamePasswordToken('foo', '', 'key'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Security\Core\Exception\BadCredentialsException
|
||||
* @expectedExceptionMessage The presented password is invalid.
|
||||
@ -40,7 +57,7 @@ class LdapBindAuthenticationProviderTest extends \PHPUnit_Framework_TestCase
|
||||
$reflection = new \ReflectionMethod($provider, 'checkAuthentication');
|
||||
$reflection->setAccessible(true);
|
||||
|
||||
$reflection->invoke($provider, new User('foo', null), new UsernamePasswordToken('foo', '', 'key'));
|
||||
$reflection->invoke($provider, new User('foo', null), new UsernamePasswordToken('foo', 'bar', 'key'));
|
||||
}
|
||||
|
||||
public function testRetrieveUser()
|
||||
|
Reference in New Issue
Block a user