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

Prepare PasswordUpgraderInterface implementations for 6.0 signature #42001

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
Jul 6, 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
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,14 @@ public function supportsClass(string $class)
*
* @final
*/
public function upgradePassword(UserInterface $user, string $newEncodedPassword): void
public function upgradePassword($user, string $newHashedPassword): void
chalasr marked this conversation as resolved.
Show resolved Hide resolved
{
if (!$user instanceof PasswordAuthenticatedUserInterface) {
trigger_deprecation('symfony/doctrine-bridge', '5.3', 'The "%s::upgradePassword()" method expects an instance of "%s" as first argument, the "%s" class should implement it.', PasswordUpgraderInterface::class, PasswordAuthenticatedUserInterface::class, get_debug_type($user));

if (!$user instanceof UserInterface) {
throw new \TypeError(sprintf('The "%s::upgradePassword()" method expects an instance of "%s" as first argument, "%s" given.', PasswordAuthenticatedUserInterface::class, get_debug_type($user)));
}
}

$class = $this->getClass();
Expand All @@ -146,7 +150,7 @@ public function upgradePassword(UserInterface $user, string $newEncodedPassword)

$repository = $this->getRepository();
if ($repository instanceof PasswordUpgraderInterface) {
$repository->upgradePassword($user, $newEncodedPassword);
$repository->upgradePassword($user, $newHashedPassword);
}
}

Expand Down
6 changes: 3 additions & 3 deletions 6 src/Symfony/Component/Ldap/Security/LdapUserProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public function refreshUser(UserInterface $user)
*
* @final
*/
public function upgradePassword(UserInterface $user, string $newEncodedPassword): void
public function upgradePassword($user, string $newHashedPassword): void
{
if (!$user instanceof LdapUser) {
throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', get_debug_type($user)));
Expand All @@ -143,9 +143,9 @@ public function upgradePassword(UserInterface $user, string $newEncodedPassword)
}

try {
$user->getEntry()->setAttribute($this->passwordAttribute, [$newEncodedPassword]);
$user->getEntry()->setAttribute($this->passwordAttribute, [$newHashedPassword]);
$this->ldap->getEntryManager()->update($user->getEntry());
$user->setPassword($newEncodedPassword);
$user->setPassword($newHashedPassword);
} catch (ExceptionInterface $e) {
// ignore failed password upgrades
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ public function eraseCredentials()
}
interface PasswordUpgraderProvider extends UserProviderInterface, PasswordUpgraderInterface
{
public function upgradePassword(UserInterface $user, string $newHashedPassword): void;
public function upgradePassword($user, string $newHashedPassword): void;

public function loadUserByIdentifier(string $identifier): UserInterface;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,16 +130,20 @@ public function supportsClass(string $class)
*
* {@inheritdoc}
*/
public function upgradePassword($user, string $newEncodedPassword): void
public function upgradePassword($user, string $newHashedPassword): void
{
if (!$user instanceof PasswordAuthenticatedUserInterface) {
trigger_deprecation('symfony/security-core', '5.3', 'The "%s::upgradePassword()" method expects an instance of "%s" as first argument, the "%s" class should implement it.', PasswordUpgraderInterface::class, PasswordAuthenticatedUserInterface::class, get_debug_type($user));

if (!$user instanceof UserInterface) {
throw new \TypeError(sprintf('The "%s::upgradePassword()" method expects an instance of "%s" as first argument, "%s" given.', PasswordAuthenticatedUserInterface::class, get_debug_type($user)));
}
}

foreach ($this->providers as $provider) {
if ($provider instanceof PasswordUpgraderInterface) {
try {
$provider->upgradePassword($user, $newEncodedPassword);
$provider->upgradePassword($user, $newHashedPassword);
} catch (UnsupportedUserException $e) {
// ignore: password upgrades are opportunistic
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

class PasswordUpgraderProvider extends InMemoryUserProvider implements PasswordUpgraderInterface
{
public function upgradePassword(UserInterface $user, string $newEncodedPassword): void
public function upgradePassword($user, string $newHashedPassword): void
{
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.