I have always 403 denied access , this is my security.yml
security:
role_hierarchy:
Livreur: Livreur
Producteur: Producteur
Admin: Admin
providers:
fos_userbundle:
id: fos_user.user_provider.username
encoders:
FOS\UserBundle\Model\UserInterface: sha512
firewalls:
main:
pattern: ^/
form_login:
provider: fos_userbundle
csrf_provider: form.csrf_provider
logout: true
anonymous: true
access_control:
- { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/admin, role: Admin }
i want to acces to {url}/app_dev.php/admin , always 403 !
i am using mongodb database and this is my document in mongo :
db.User.find().pretty()
{
"_id" : ObjectId("54fef590a98a93842000002e"),
"username" : "admin",
"usernameCanonical" : "admin",
"email" : "admin@email.com",
"emailCanonical" : "admin@email.com",
"enabled" : true,
"salt" : "flxrknwannwow0swccwk000gw44kwgg",
"password" : "u8d6fIrwTGF/x2FYhJxootw8MU4PR3KvY5mUjwLn9ZPBxA1foi0ox/OVif
9HIipz/cTIdvghJNKsdXljCR6MVA==",
"locked" : false,
"expired" : false,
"roles" : {
"0" : "Admin"
},
"firstName" : "xxxx",
"lastName" : "xxx",
"numTel" : "xxxx",
"adresse" : "xxxxx",
"lastLogin" : ISODate("2015-03-10T14:22:38Z")
}
the return of $document->getRoles() is
["ADMIN","ROLE_USER"]
and if if i make test for current user i get :
$this->container->get('security.context')->isGranted('Admin')
or
$this->container->get('security.context')->isGranted('ADMIN')
it return always FALSE
Help please
I think that all role-names should begin with ROLE_ - prefix You need to use ROLE_ADMIN. I had similar problem, but when I changed role name - problem has been resolved.