Ok guys, it has been 10 hours that I search a solution for my problem. My firewall on Symfony 2.7 doesn't redirect me if i'm not logged in.
If I go on domain.com/admin/, the firewall should redirect me on /login, but not.
I use FOSUSerBundle. I alway obtain this error message :
You are not authenticated 401 Unauthorized - HttpException 1 linked Exception: AuthenticationCredentialsNotFoundException »
Here is my code:
security:
encoders:
FOS\UserBundle\Model\UserInterface: sha512
providers:
fos_userbundle:
id: fos_user.user_provider.username
firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
admin:
pattern: ^/
context: site
form_login:
provider: fos_userbundle
check_path: /login_check
login_path: /login
logout:
path: /admin/logout
anonymous: false
My access control:
access_control:
- { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/admin/, role: ROLE_ADMIN }
Here is the code in PhpStorm if you prefer :
Thanks for your help!