Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1bdc2a2

Browse files
feature #41363 [Ldap] Removed deprecated code (malteschlueter)
This PR was merged into the 6.0 branch. Discussion ---------- [Ldap] Removed deprecated code | Q | A | ------------- | --- | Branch? | 6.0 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - This remove deprecated code from Ldap. Do I have to update the upgrade log for the two method deletions or is it unnecessary because it's mentioned in the security? Commits ------- 16bb7c4 [Ldap] Removed deprecated code
2 parents e1aa54e + 16bb7c4 commit 1bdc2a2

File tree

4 files changed

+8
-28
lines changed

4 files changed

+8
-28
lines changed

src/Symfony/Component/Ldap/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
CHANGELOG
22
=========
33

4+
6.0
5+
---
6+
7+
* Removed `LdapUser::getUsername()` method, use `getUserIdentifier()` instead
8+
* Removed `LdapUserProvider::loadUserByUsername()` method, use `loadUserByIdentifier()` instead
9+
410
5.3
511
---
612

src/Symfony/Component/Ldap/Security/CheckLdapCredentialsListener.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
use Symfony\Component\Ldap\LdapInterface;
1818
use Symfony\Component\Security\Core\Exception\BadCredentialsException;
1919
use Symfony\Component\Security\Core\Exception\LogicException;
20-
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
2120
use Symfony\Component\Security\Http\Authenticator\Passport\Credentials\PasswordCredentials;
2221
use Symfony\Component\Security\Http\Authenticator\Passport\UserPassportInterface;
2322
use Symfony\Component\Security\Http\Event\CheckPassportEvent;
@@ -70,9 +69,6 @@ public function onCheckPassport(CheckPassportEvent $event)
7069
}
7170

7271
$user = $passport->getUser();
73-
if (!$user instanceof PasswordAuthenticatedUserInterface) {
74-
trigger_deprecation('symfony/ldap', '5.3', 'Not implementing the "%s" interface in class "%s" while using password-based authenticators is deprecated.', PasswordAuthenticatedUserInterface::class, get_debug_type($user));
75-
}
7672

7773
/** @var LdapInterface $ldap */
7874
$ldap = $this->ldapLocator->get($ldapBadge->getLdapServiceId());
@@ -83,8 +79,7 @@ public function onCheckPassport(CheckPassportEvent $event)
8379
} else {
8480
throw new LogicException('Using the "query_string" config without using a "search_dn" and a "search_password" is not supported.');
8581
}
86-
// @deprecated since 5.3, change to $user->getUserIdentifier() in 6.0
87-
$username = $ldap->escape(method_exists($user, 'getUserIdentifier') ? $user->getUserIdentifier() : $user->getUsername(), '', LdapInterface::ESCAPE_FILTER);
82+
$username = $ldap->escape($user->getUserIdentifier(), '', LdapInterface::ESCAPE_FILTER);
8883
$query = str_replace('{username}', $username, $ldapBadge->getQueryString());
8984
$result = $ldap->query($ldapBadge->getDnString(), $query)->execute();
9085
if (1 !== $result->count()) {
@@ -93,8 +88,7 @@ public function onCheckPassport(CheckPassportEvent $event)
9388

9489
$dn = $result[0]->getDn();
9590
} else {
96-
// @deprecated since 5.3, change to $user->getUserIdentifier() in 6.0
97-
$username = $ldap->escape(method_exists($user, 'getUserIdentifier') ? $user->getUserIdentifier() : $user->getUsername(), '', LdapInterface::ESCAPE_DN);
91+
$username = $ldap->escape($user->getUserIdentifier(), '', LdapInterface::ESCAPE_DN);
9892
$dn = str_replace('{username}', $username, $ldapBadge->getDnString());
9993
}
10094

src/Symfony/Component/Ldap/Security/LdapUser.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -71,16 +71,6 @@ public function getSalt(): ?string
7171
return null;
7272
}
7373

74-
/**
75-
* {@inheritdoc}
76-
*/
77-
public function getUsername(): string
78-
{
79-
trigger_deprecation('symfony/ldap', '5.3', 'Method "%s()" is deprecated and will be removed in 6.0, use getUserIdentifier() instead.', __METHOD__);
80-
81-
return $this->username;
82-
}
83-
8474
public function getUserIdentifier(): string
8575
{
8676
return $this->username;

src/Symfony/Component/Ldap/Security/LdapUserProvider.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -62,16 +62,6 @@ public function __construct(LdapInterface $ldap, string $baseDn, string $searchD
6262
$this->extraFields = $extraFields;
6363
}
6464

65-
/**
66-
* {@inheritdoc}
67-
*/
68-
public function loadUserByUsername(string $username)
69-
{
70-
trigger_deprecation('symfony/ldap', '5.3', 'Method "%s()" is deprecated, use loadUserByIdentifier() instead.', __METHOD__);
71-
72-
return $this->loadUserByIdentifier($username);
73-
}
74-
7565
public function loadUserByIdentifier(string $identifier): UserInterface
7666
{
7767
try {

0 commit comments

Comments
 (0)