I have a route that has a parameter and its tripping my firewall thinking it needs to be logged in first. I tried to setup the pattern to use the name form at as used in the route but it still saying it requires authentication.
is there a special way to get the patter to work with parameters? I'm failing to see how to so that.
Thanks
$app->register(new Silex\Provider\SecurityServiceProvider(), [
'security.firewalls' => [
'login' => [
'pattern' => '^/login$',
'anonymous' => true
],
'pwdRecovery' => [
'pattern' => '^/recover',
'anonymous' => true
],
'newPassword' => [
'pattern' => '^/newpassword$',
'anonymous' => true
],
// Any other URL requires auth.
'authenticated' => [
'pattern' => '^.*$',
'form' => [
'login_path' => '/login',
'check_path' => '/authenticate'
],
'anonymous' => false,
'logout' => ['logout_path' => '/logout'],
'users' => $app->share(function() use ($app) {
return new App\Providers\UserServiceProvider();
}),
]
],
'security.access_rules' => [
['^/admin', 'ROLE_ADMIN']
],
'security.encoder.digest' => $app->share(function() {
return new BCryptPasswordEncoder(15);
})
]);
This may be a regex problem. I can pass parameters to the ^/recover
route just fine.
$app->get('/recover/{id}', function (Request $request, $id) use ($app) {
error_log(print_r((int) $id,1).' '.__FILE__.' '.__LINE__,0);
});
But if I add $
to that route like ^/recover$
then it redirects to login because the dollar sign dictates end of string.