I’m building a website with a simple architecture, using FOSuserBundle in a very basic way:
- a public area, where users may be authenticated
- a protected area, where users have to be authenticated
- a login page
Authentication works fine on public pages.
However, when the user goes to a protected page, authentication is lost (anonymous), and user is redirected to the login page.
Nevertheless, the user is still authenticated for public pages.
Here is the firewall config:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
login:
pattern: ^/(login$|register|resetting)
anonymous: true
secured_area:
pattern: ^(/[A-Za-z_]*/[A-Za-z0-9-]*/[A-Za-z0-9-]*/.*)|(/[A-Za-z_]*/NT.*)
form_login:
provider: fos_userbundle
csrf_provider: form.csrf_provider
remember_me: true
use_referer: true
remember_me:
key: %secret%
anonymous: false
logout: true
main:
pattern: ^/
form_login:
provider: fos_userbundle
csrf_provider: form.csrf_provider
remember_me: true
use_referer: true
remember_me:
key: %secret%
anonymous: true
logout: true
Thanks 🙂
If You have 2 firewall You need to ask user to authenticate through each one of them.
Couldnt You stick to main and require some role to access your secure pages?
you could just add remove secured_area firewall and add for example: