I can't figure out how to use SecurityServiceProvider
in Silex
. My configuration is:
$app['security.firewalls'] = array(
'admin' => array(
'pattern' => '^/_admin/.+',
'form' => array('login_path' => '/_admin/', 'check_path' => '/_admin/login_check'),
'logout' => array('logout_path' => '/_admin/logout'),
'users' => array(
'admin' => array('ROLE_ADMIN', '5FZ2Z8QIkA7UTZ4BYkoC+GsR...'),
),
),
);
$app->register(new SilexProviderSecurityServiceProvider());
This just throws:
Fatal error: Uncaught exception 'InvalidArgumentException' with message 'Identifier "security.authentication_providers" is not defined.'
According to the documentation in some cases when you want to access Security features outside of the handling of a request you have to call $app->boot();
but this isn't my situation.
If I call $app->boot();
before $app->register(...)
it doesn't raise any exception but it probably doesn't boot at all because then in generating login form Twig throws:
Unable to generate a URL for the named route "_admin_login_check" as such route does not exist.
There's an issue a few months ago with probably the same problem but it's closed so I guess it should be fixed now
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…