Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

[PasswordHasher] Fix usage of PasswordHasherAdapter in PasswordHasherFactory#42321

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
derrabus merged 1 commit intosymfony:5.3frompeter17:patch-1
Jul 29, 2021

Conversation

@peter17
Copy link
Contributor

QA
Branch?5.3
Bug fix?yes
New feature?no
Deprecations?no
TicketsFix explained below
LicenseMIT

Using migrate_from with a PasswordEncoderInterface was working fine in Symfony 5.2. It Symfony 5.3, it resulted in an error, because getHasherConfigFromAlgorithm would access it before it is decorated with the adapter.

Full stack-trace:

TypeError:Argument 1 passed to Symfony\Component\PasswordHasher\Hasher\PasswordHasherFactory::createHasher() must be of the type array, object given, called in /var/www/html/vendor/symfony/password-hasher/Hasher/PasswordHasherFactory.php on line 157  at vendor/symfony/password-hasher/Hasher/PasswordHasherFactory.php:73  at Symfony\Component\PasswordHasher\Hasher\PasswordHasherFactory->createHasher(object(LegacyPasswordEncoder), true)     (vendor/symfony/password-hasher/Hasher/PasswordHasherFactory.php:157)  at Symfony\Component\PasswordHasher\Hasher\PasswordHasherFactory->getHasherConfigFromAlgorithm(array('algorithm' => 'native', 'cost' => 15, 'hash_algorithm' => 'sha512', 'key_length' => 40, 'ignore_case' => false, 'encode_as_base64' => true, 'iterations' => 5000, 'memory_cost' => null, 'time_cost' => null))     (vendor/symfony/password-hasher/Hasher/PasswordHasherFactory.php:77)  at Symfony\Component\PasswordHasher\Hasher\PasswordHasherFactory->createHasher(array('algorithm' => 'native', 'cost' => 15, 'migrate_from' => array('legacy'), 'hash_algorithm' => 'sha512', 'key_length' => 40, 'ignore_case' => false, 'encode_as_base64' => true, 'iterations' => 5000, 'memory_cost' => null, 'time_cost' => null), true)     (vendor/symfony/password-hasher/Hasher/PasswordHasherFactory.php:137)  at Symfony\Component\PasswordHasher\Hasher\PasswordHasherFactory->getHasherConfigFromAlgorithm(array('algorithm' => 'native', 'cost' => 15, 'migrate_from' => array('legacy'), 'hash_algorithm' => 'sha512', 'key_length' => 40, 'ignore_case' => false, 'encode_as_base64' => true, 'iterations' => 5000, 'memory_cost' => null, 'time_cost' => null))     (vendor/symfony/password-hasher/Hasher/PasswordHasherFactory.php:77)  at Symfony\Component\PasswordHasher\Hasher\PasswordHasherFactory->createHasher(array('algorithm' => 'auto', 'cost' => 15, 'migrate_from' => array('legacy'), 'hash_algorithm' => 'sha512', 'key_length' => 40, 'ignore_case' => false, 'encode_as_base64' => true, 'iterations' => 5000, 'memory_cost' => null, 'time_cost' => null))     (vendor/symfony/password-hasher/Hasher/PasswordHasherFactory.php:113)  at Symfony\Component\PasswordHasher\Hasher\PasswordHasherFactory->createHasherUsingAdapter('App\\Entity\\User')     (vendor/symfony/password-hasher/Hasher/PasswordHasherFactory.php:65)  at Symfony\Component\PasswordHasher\Hasher\PasswordHasherFactory->getPasswordHasher(object(User))     (vendor/symfony/security-core/Authentication/Provider/DaoAuthenticationProvider.php:100)  at Symfony\Component\Security\Core\Authentication\Provider\DaoAuthenticationProvider->checkAuthentication(object(User), object(UsernamePasswordToken))     (vendor/symfony/security-core/Authentication/Provider/UserAuthenticationProvider.php:86)  at Symfony\Component\Security\Core\Authentication\Provider\UserAuthenticationProvider->authenticate(object(UsernamePasswordToken))     (vendor/symfony/security-core/Authentication/AuthenticationProviderManager.php:88)  at Symfony\Component\Security\Core\Authentication\AuthenticationProviderManager->authenticate(object(UsernamePasswordToken))     (vendor/symfony/security-http/Firewall/UsernamePasswordFormAuthenticationListener.php:108)  at Symfony\Component\Security\Http\Firewall\UsernamePasswordFormAuthenticationListener->attemptAuthentication(object(Request))     (vendor/symfony/security-http/Firewall/AbstractAuthenticationListener.php:136)  at Symfony\Component\Security\Http\Firewall\AbstractAuthenticationListener->authenticate(object(RequestEvent))     (vendor/symfony/security-bundle/Debug/WrappedLazyListener.php:49)  at Symfony\Bundle\SecurityBundle\Debug\WrappedLazyListener->authenticate(object(RequestEvent))     (vendor/symfony/security-http/Firewall/AbstractListener.php:26)  at Symfony\Component\Security\Http\Firewall\AbstractListener->__invoke(object(RequestEvent))     (vendor/symfony/security-bundle/Debug/TraceableFirewallListener.php:62)  at Symfony\Bundle\SecurityBundle\Debug\TraceableFirewallListener->callListeners(object(RequestEvent), object(Generator))     (vendor/symfony/security-http/Firewall.php:86)  at Symfony\Component\Security\Http\Firewall->onKernelRequest(object(RequestEvent), 'kernel.request', object(TraceableEventDispatcher))     (vendor/symfony/event-dispatcher/Debug/WrappedListener.php:117)  at Symfony\Component\EventDispatcher\Debug\WrappedListener->__invoke(object(RequestEvent), 'kernel.request', object(TraceableEventDispatcher))     (vendor/symfony/event-dispatcher/EventDispatcher.php:230)  at Symfony\Component\EventDispatcher\EventDispatcher->callListeners(array(object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener)), 'kernel.request', object(RequestEvent))     (vendor/symfony/event-dispatcher/EventDispatcher.php:59)  at Symfony\Component\EventDispatcher\EventDispatcher->dispatch(object(RequestEvent), 'kernel.request')     (vendor/symfony/event-dispatcher/Debug/TraceableEventDispatcher.php:151)  at Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher->dispatch(object(RequestEvent), 'kernel.request')     (vendor/symfony/http-kernel/HttpKernel.php:133)  at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), 1)     (vendor/symfony/http-kernel/HttpKernel.php:79)  at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), 1, true)     (vendor/symfony/http-kernel/Kernel.php:199)  at Symfony\Component\HttpKernel\Kernel->handle(object(Request))     (public/index.php:20)

My confguration in security.yml:

    encoders:        legacy:            id: 'App\Utils\LegacyPasswordEncoder'        App\Entity\User:            algorithm: auto            cost: 15            migrate_from:                - legacy

@carsonbot
Copy link

Hey!

I see that this is your first PR. That is great! Welcome!

Symfony has acontribution guide which I suggest you to read.

In short:

  • Always add tests
  • Keep backward compatibility (seehttps://symfony.com/bc).
  • Bug fixes must be submitted against the lowest maintained branch where they apply (seehttps://symfony.com/releases)
  • Features and deprecations must be submitted against the 5.4 branch.

Review the GitHub status checks of your pull request and try to solve the reported issues. If some tests are failing, try to see if they are failing because of this change.

When two Symfony core team members approve this change, it will be merged and you will become an official Symfony contributor!
If this PR is merged in a lower version branch, it will be merged up to all maintained branches within a few days.

I am going to sit back now and wait for the reviews.

Cheers!

Carsonbot

@derrabus
Copy link
Member

Can you provide a test case for your change?

@carsonbotcarsonbot changed the title Fix usage of PasswordHasherAdapter in PasswordHasherFactory[PasswordHasher] Fix usage of PasswordHasherAdapter in PasswordHasherFactoryJul 29, 2021
@peter17peter17force-pushed thepatch-1 branch 2 times, most recently from8ee821e to744d651CompareJuly 29, 2021 16:04
@peter17
Copy link
ContributorAuthor

@derrabus I added a test. On branch 5.3, this test fails with:

TypeError: Argument 1 passed to Symfony\Component\PasswordHasher\Hasher\PasswordHasherFactory::createHasher() must be of the type array, object given, called in symfony/src/Symfony/Component/PasswordHasher/Hasher/PasswordHasherFactory.php on line 146

And it passes with my patch. Regards

@derrabus
Copy link
Member

Good catch, thanks@peter17.

peter17 reacted with thumbs up emoji

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@derrabusderrabusderrabus approved these changes

@chalasrchalasrchalasr approved these changes

Assignees

No one assigned

Projects

None yet

Milestone

5.3

Development

Successfully merging this pull request may close these issues.

4 participants

@peter17@carsonbot@derrabus@chalasr

[8]ページ先頭

©2009-2025 Movatter.jp