I'm trying to configure my symfony2 application to use the sha512 password encoder with the in_memory security provider, but I can't get it to work. I am getting the infamous "Bad credentials" error on login. Unlike most questions here, I do not want to get users from any database. I do not want to use FOSUserBundle. All I want is simply to replace the plaintext passwords in my security.yml with sha512 hashes.
According to http://symfony.com/doc/current/book/security.html#encoding-the-user-s-password this should be as simple as setting the encoder and replacing the plaintext password with the hash, so that is what I tried to do:
security.yml:
security:
encoders:
Symfony\Component\Security\Core\User\User: sha512
providers:
in_memory:
memory:
users:
admin: { password: $6$randomsalt$mbd3sS15ibE.W7hkLqfQ0LNEQsUod7BOUD67g/oIb8uhqGfyAzaga3vgGaRJZn67VdHHfn.tnkKY9ffDVXw3C., roles: [ 'ROLE_ADMIN' ] }
The password is "admin", the salt is "randomsalt" and the hash was generated by mkpasswd:
mkpasswd -m sha-512 admin randomsalt
Why is this not working? Does symfony2 expect the hash to be in some other format?
EDIT: things I've tried as well:
- generating the hash through PHP using
crypt($password, "$6$".$salt) - toggling
encode_as_base64true/false on the security encoder - specifying the number of iterations to use (default 5000)
Result is the same: "Bad credentials".
mkpasswdin this situation? Also, you might need to be usingphpand thesha512function to generate the password hash, rather than callingmkpasswd? - tftdcrypt($password, "$6".$salt)(comment edited for code brevity) - Rob