Search code examples
javasymfonyencryptionfosuserbundle

Synchronise my java app with the table user of fosuserbundle


I am trying to create a Desktop app (using java) that points to the same database of my website (created using symfony 2),and i have a problem that I can't insert in the columns "password" and "salt" (using the same encryption type sha512 generated by fosuserBundle),and I don't know how fosuserBundle generates the "salt" value.

My encoder is currently set as:

security:
encoders:
    FOS\UserBundle\Model\UserInterface: sha512

Solution

  • finally i find a solution that makes the field "salt" negligible in the fos_user table:

    namespace Symfony\Component\Security\Core\Encoder;
    
        protected function mergePasswordAndSalt($password, $salt)
            {
                if (empty($salt)) {
                    return $password;
                }
        
                if (false !== strrpos($salt, '{') || false !== strrpos($salt, '}')) {
                    throw new \InvalidArgumentException('Cannot use { or } in salt.');
                }
        
                return $password;
            
        
            }