Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit f276989

Browse filesBrowse files
ismail1432nicolas-grekas
authored andcommitted
[Ldap] cast to string when checking empty passwords
1 parent 677d9aa commit f276989
Copy full SHA for f276989

File tree

2 files changed

+18
-1
lines changed
Filter options

2 files changed

+18
-1
lines changed

‎src/Symfony/Component/Security/Core/Authentication/Provider/LdapBindAuthenticationProvider.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Core/Authentication/Provider/LdapBindAuthenticationProvider.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ protected function checkAuthentication(UserInterface $user, UsernamePasswordToke
7171
$username = $token->getUsername();
7272
$password = $token->getCredentials();
7373

74-
if ('' === $password) {
74+
if ('' === (string) $password) {
7575
throw new BadCredentialsException('The presented password must not be empty.');
7676
}
7777

‎src/Symfony/Component/Security/Core/Tests/Authentication/Provider/LdapBindAuthenticationProviderTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Core/Tests/Authentication/Provider/LdapBindAuthenticationProviderTest.php
+17Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,23 @@ public function testEmptyPasswordShouldThrowAnException()
3939
$reflection->invoke($provider, new User('foo', null), new UsernamePasswordToken('foo', '', 'key'));
4040
}
4141

42+
/**
43+
* @expectedException \Symfony\Component\Security\Core\Exception\BadCredentialsException
44+
* @expectedExceptionMessage The presented password must not be empty.
45+
*/
46+
public function testNullPasswordShouldThrowAnException()
47+
{
48+
$userProvider = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserProviderInterface')->getMock();
49+
$ldap = $this->getMockBuilder('Symfony\Component\Ldap\LdapClientInterface')->getMock();
50+
$userChecker = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserCheckerInterface')->getMock();
51+
52+
$provider = new LdapBindAuthenticationProvider($userProvider, $userChecker, 'key', $ldap);
53+
$reflection = new \ReflectionMethod($provider, 'checkAuthentication');
54+
$reflection->setAccessible(true);
55+
56+
$reflection->invoke($provider, new User('foo', null), new UsernamePasswordToken('foo', null, 'key'));
57+
}
58+
4259
/**
4360
* @expectedException \Symfony\Component\Security\Core\Exception\BadCredentialsException
4461
* @expectedExceptionMessage The presented password is invalid.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.