I'm trying to place the admin part of a webpage under authentication I've managed to configure a user and password but when I login with the user and respective password the login fails. How can I debug this? What can be the problem?
$app['security.encoder.digest'] = function ($app) {
// uses the password-compat encryption
return new BCryptPasswordEncoder(10);
};
$app['security.encoder_factory'] = function ($app) {
return new EncoderFactory(
array(
'Symfony\Component\Security\Core\User\UserInterface' => $app['security.encoder.digest']
)
);
};
$app->register(new Silex\Provider\SecurityServiceProvider(), array(
'security.firewalls' => array(
'admin' => array(
'pattern' => '^/admin',
'http' => true,
'users' => function () use ($app) {
$dbs = new \FMP\Service\DbService($app);
return new UserProvider($dbs->getDb(), $app['form.factory']);
}
)
)
));
I set the user password using this:
$encoder = $encoderFactory->getEncoder($user);
// compute the encoded password for foo
$password = $encoder->encodePassword($user->getPassword(), $user->getSalt());
Logs:
[2016-11-24 15:41:51] app.DEBUG: initialized users system [] [] [2016-11-24 15:41:51] app.INFO: Matched route "{route}". {"route":"GET_admin_users","route_parameters":{"_controller":"[object] (Closure: {})","_route":"GET_admin_users"},"request_uri":"http://dev.fmp2/admin/users","method":"GET"} [] [2016-11-24 15:41:51] app.INFO: An AuthenticationException was thrown; redirecting to authentication entry point. {"exception":"[object] (Symfony\Component\Security\Core\Exception\AuthenticationCredentialsNotFoundException(code: 0): A Token was not found in the TokenStorage. at /home/andref/workspace/fmpsite2/vendor/symfony/security/Http/Firewall/AccessListener.php:53)"} [] [2016-11-24 15:41:51] app.DEBUG: Calling Authentication entry point. [] [] [2016-11-24 15:41:51] app.DEBUG: < 401 [] []