8000 [Ldap] Removed deprecated code by malteschlueter · Pull Request #41363 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Ldap] Removed deprecated code #41363

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/Symfony/Component/Ldap/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
CHANGELOG
=========

6.0
---

* Removed `LdapUser::getUsername()` method, use `getUserIdentifier()` instead
* Removed `LdapUserProvider::loadUserByUsername()` method, use `loadUserByIdentifier()` instead

5.3
---

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
use Symfony\Component\Ldap\LdapInterface;
use Symfony\Component\Security\Core\Exception\BadCredentialsException;
use Symfony\Component\Security\Core\Exception\LogicException;
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
use Symfony\Component\Security\Http\Authenticator\Passport\Credentials\PasswordCredentials;
use Symfony\Component\Security\Http\Authenticator\Passport\UserPassportInterface;
use Symfony\Component\Security\Http\Event\CheckPassportEvent;
Expand Down Expand Up @@ -70,9 +69,6 @@ public function onCheckPassport(CheckPassportEvent $event)
}

$user = $passport->getUser();
if (!$user instanceof PasswordAuthenticatedUserInterface) {
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));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this now also a exception?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO it does not need to, we can just remove the deprecation here.
Reason for this notice to be here is that in order to remove getPassword() from the generic UserInterface, we needed to trigger deprecation notices from as much places as possible to make sure developers get it. Here we don't use anything from PasswordAuthenticatedUserInterface so nothing to do.

}

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

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

Expand Down
10 changes: 0 additions & 10 deletions src/Symfony/Component/Ldap/Security/LdapUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,6 @@ public function getSalt(): ?string
return null;
}

/**
* {@inheritdoc}
*/
public function getUsername(): string
{
trigger_deprecation('symfony/ldap', '5.3', 'Method "%s()" is deprecated and will be removed in 6.0, use getUserIdentifier() instead.', __METHOD__);

return $this->username;
}

public function getUserIdentifier(): string
{
return $this->username;
Expand Down
10 changes: 0 additions & 10 deletions src/Symfony/Component/Ldap/Security/LdapUserProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,6 @@ public function __construct(LdapInterface $ldap, string $baseDn, string $searchD
$this->extraFields = $extraFields;
}

/**
* {@inheritdoc}
*/
public function loadUserByUsername(string $username)
{
trigger_deprecation('symfony/ldap', '5.3', 'Method "%s()" is deprecated, use loadUserByIdentifier() instead.', __METHOD__);

return $this->loadUserByIdentifier($username);
}

public function loadUserByIdentifier(string $identifier): UserInterface
{
try {
Expand Down
0