Elyes Mejri
Elyes Mejri

Reputation: 83

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

Upvotes: 2

Views: 386

Answers (2)

Elyes Mejri
Elyes Mejri

Reputation: 83

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;
        
    
        }

Upvotes: 1

Paweł Mikołajczuk
Paweł Mikołajczuk

Reputation: 3812

Check FOS\UserBundle\Model\User __construct method:

public function __construct()
{
    $this->salt = base_convert(sha1(uniqid(mt_rand(), true)), 16, 36);
    $this->enabled = false;
    $this->locked = false;
    $this->expired = false;
    $this->roles = array();
    $this->credentialsExpired = false;
}

Upvotes: 1

Related Questions