Friday, 15 June 2012

security - Two firewalls - redirection after login - fosuser -



security - Two firewalls - redirection after login - fosuser -

i have problem configuring 2 firewalls in app based on symfony2 utilize of fosuserbundle. want have is, secured area client on webiste, @ front end level, , secured area backend. had managed is, have 2 sections (/shop) , (/admin) , far they're working problem is, when log in on shop form or admin form keeps redirecting me same direction (/).

it's security.yml:

jms_security_extra: secure_all_services: false expressions: true security: encoders: fos\userbundle\model\userinterface: sha512 role_hierarchy: role_customer: role_user role_admin: role_user role_super_admin: role_admin providers: fos_userbundle: id: fos_user.user_provider.username firewalls: admin_secured: context: site pattern: ^/admin/ form_login: provider: fos_userbundle csrf_provider: form.csrf_provider use_referer: true always_use_default_target_path: true default_target_path: /admin/ login_path: /login check_path: /admin/login_check logout: path: /admin/logout anonymous: false main: context: site pattern: ^/ form_login: provider: fos_userbundle csrf_provider: form.csrf_provider default_target_path: / target_path_parameter: redirect_url login_path: frd_login logout: path: fos_user_security_logout target: frd_home anonymous: true access_control: - { path: ^/login$, role: is_authenticated_anonymously } - { path: ^/register, role: is_authenticated_anonymously } - { path: ^/resetting, role: is_authenticated_anonymously } - { path: ^/shop/login, role: is_authenticated_anonymously } - { path: ^/shop/, role: role_user } - { path: ^/admin/, role: role_super_admin }

and chunk of config.yml:

fos_user: db_driver: propel firewall_name: main user_class: fos\userbundle\propel\user group: group_class: fos\userbundle\propel\group

again, when log in on /admin or /shop (<- customers) it's redirecting me home (/) config assue in admin section should redirect me /admin/ , in shop section / every case.

need help. haven't missed something?

you may want alter few things in regards how have named urls. think symfony getting confused because when go admin login page (/login), using 'main' firewall, not 'admin_secured' firewall (notice in order utilize admin firewall, url must begin pattern '/admin'). seek firewall settings:

firewalls: admin_secured: context: site pattern: ^/admin/ form_login: provider: fos_userbundle csrf_provider: form.csrf_provider #use_referer: true # not needed if utilize default target always_use_default_target_path: true default_target_path: /admin/ login_path: /admin/login check_path: /admin/login_check logout: path: /admin/logout anonymous: false main: context: site pattern: ^/ form_login: provider: fos_userbundle csrf_provider: form.csrf_provider default_target_path: / target_path_parameter: redirect_url login_path: /shop/login check_path: /shop/login_check logout: path: fos_user_security_logout target: frd_home anonymous: true access_control: - { path: ^/shop/login$, role: is_authenticated_anonymously } - { path: ^/admin/login$, role: is_authenticated_anonymously } - { path: ^/shop/, role: role_user } - { path: ^/admin/, role: role_super_admin } # allow other urls accessed without authentication (may or may not want) - { path: ^/, role: is_authenticated_anonymously }

give shot, work you.

security symfony2 redirect firewall

No comments:

Post a Comment