Skip to content

always "Bad credentials" though password is correct #34113

@BernardA

Description

@BernardA

Symfony version(s) affected: 4.3.5

Description
It always throws bad credential exception even though password is correct.
This seems to be related to this issue.

This is a Symfony API-Platform back-end with Gatsby on the front-end, FIY. It was working fine and the only thing I can think I did was to install Vich uploader bundle. The issue started after that. Though I reversed back to the situation before that change, the problem persisted.

Then, checking the logs I noticed the deprecation of the password encoder and applied the new recommendation, like so:

/config/packages/security.yaml

      encoders:
         App\Entity\User:
            algorithm: auto

Users are being loaded from fixtures and password encoded as follows:

     UserPasswordEncoderInterface $passwordEncoder,

        $user->setPassword(
            $this->passwordEncoder->encodePassword(
                $user,
                $userFixture['password']
            )
        );

I did register an user from the front-end and it also had the same issue.

This is how an encoded password looks like on the db:

   $argon2id$v=19$m=65536,t=4,p=1$DjdHrgs64e45ByyMz4H

How to reproduce

Complete code in this repository.

Possible Solution

Additional context
The error log shows that the issue is specifically the password.

  [2019-10-25 08:38:19] security.INFO: Authentication request failed. {"exception":"[object] (Symfony\\Component\\Security\\Core\\Exception\\BadCredentialsException(code: 0): Bad credentials. at /Users/user/Sites/quiamo-api/vendor/symfony/security-core/Authentication/Provider/UserAuthenticationProvider.php:85, Symfony\\Component\\Security\\Core\\Exception\\BadCredentialsException(code: 0): The presented password is invalid. at /Users/user/Sites/quiamo-api/vendor/symfony/security-core/Authentication/Provider/DaoAuthenticationProvider.php:58)"} []

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions