after installing FOSUserBundle, now Im trying to login with user/ userpass but I still get the "Bad credentials" message. This is my security.yml:
security:
encoders:
Symfony\Component\Security\Core\User\User: plaintext
role_hierarchy:
ROLE_ADMIN: ROLE_USER
ROLE_SUPER_ADMIN: [ROLE_USER, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH]
providers:
in_memory:
users:
user: { password: userpass, roles: [ 'ROLE_USER' ] }
admin: { password: adminpass, roles: [ 'ROLE_ADMIN' ] }
fos_userbundle:
id: fos_user.user_manager
firewalls:
main:
pattern: ^/
form_login:
provider: fos_userbundle
logout: true
anonymous: true
#anonymous: ~
#http_basic:
# realm: "Secured Demo Area"
Any idea?
symfony 2.0.4
Chain your providers like this:
providers:
chain_provider:
providers: [in_memory, fos_userbundle]
in_memory:
users:
user: { password: userpass, roles: [ 'ROLE_USER' ] }
admin: { password: adminpass, roles: [ 'ROLE_ADMIN' ] }
fos_userbundle:
id: fos_user.user_manager
firewalls:
main:
pattern: ^/
form_login:
provider: chain_provider
logout: true
anonymous: true
switch_user: true
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
In the firewall section you're using the wrong provider: fos_userbundle instead of in_memory. You can chain them if you want.
In addition to a chian of Users provider, i suggest you to encode your password in your web application, you can encode by a tools online sh1 link to encode online.
encoders:
"Symfony\Component\Security\Core\User\User":
algorithm: sha1
iterations: 1
encode_as_base64: false
"FOS\UserBundle\Model\UserInterface": sha512
providers:
chain_provider:
providers: [in_memory, fos_userbundle]
in_memory:
users:
user: { password: 45f106ef4d5161e7aa38cf6c666607f25748b6ca, roles: [ 'ROLE_USER' ] } # userpass as password
admin: { password: 74913f5cd5f61ec0bcfdb775414c2fb3d161b620, roles: [ 'ROLE_ADMIN' ] } # adminpass as password
fos_userbundle:
id: fos_user.user_manager
firewalls:
main:
pattern: ^/
form_login:
provider: chain_provider
logout: true
anonymous: true
switch_user: true
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With