I need to access the current user logged in (if any) in any part of the application. Special paths like /admin requires special permissions (roles).
This is the firewall configuration (just one firewall) protecting the entire application but not allowing anonymous users (because I need the current user even in homepage).
I got a redirect loop even requesting /. Any help?
'security.firewalls' => array(
'secured' => array(
'pattern' => '.*',
'anonymous' => false,
'form' => array(
'login_path' => '/login',
'check_path' => '/login_check',
'username_parameter' => 'login[username]',
'password_parameter' => 'login[password]',
),
'logout' => array('logout_path' => '/logout')
)
)
Access rules requires ROLE_ADMIN only for paths starting with /admin . The rest is anonymous:
'security.access_rules' => array(
array('^/admin', 'ROLE_ADMIN'),
array('^.*', 'IS_AUTHENTICATED_ANONYMOUSLY')
),
To allow acces via
IS_AUTHENTICATED_ANONYMOUSLYhave have to allow anonymous.If the user is logged in you can access them in every page.
IS_AUTHENTICATED_ANONYMOUSLYis only a role, which have unauthenticated users (anonymous).