Created
January 27, 2015 12:28
-
-
Save webdevilopers/9de56b109588a30401c2 to your computer and use it in GitHub Desktop.
How to redirect after successful login setting default_target_path on all firewalls using FOSUserBundle and SonataAdminBundle in Symfony2 Security
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
security: | |
encoders: | |
FOS\UserBundle\Model\UserInterface: sha512 | |
# set access_strategy to unanimous, else you may have unexpected behaviors | |
access_decision_manager: | |
strategy: unanimous | |
providers: | |
fos_userbundle: | |
id: fos_user.user_manager | |
firewalls: | |
# Disabling the security for the web debug toolbar, the profiler and Assetic. | |
dev: | |
pattern: ^/(_(profiler|wdt)|css|images|js)/ | |
security: false | |
# -> custom firewall for the admin area of the URL | |
qis: | |
pattern: /qis(.*) | |
context: user | |
form_login: | |
provider: fos_userbundle | |
login_path: /login | |
check_path: /qis/login_check | |
logout: | |
path: /qis/logout | |
anonymous: false | |
# This firewall is used to handle the public login area | |
# This part is handled by the FOS User Bundle | |
main: | |
pattern: .* | |
context: user | |
form_login: | |
provider: fos_userbundle | |
login_path: /login | |
use_forward: true | |
default_target_path: /qis | |
# always_use_default_target_path: false | |
check_path: /login_check | |
failure_path: null | |
logout: | |
path: /logout | |
anonymous: true | |
# Session liftime | |
remember_me: | |
key: '%secret%' | |
lifetime: 28800 | |
# Sonata User Impersonating | |
switch_user: true | |
access_control: | |
# URL of FOSUserBundle which need to be available to anonymous users | |
- { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY } | |
# - { path: ^/logout$, role: IS_AUTHENTICATED_ANONYMOUSLY } | |
- { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY } | |
- { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY } | |
# Admin login page needs to be access without credential | |
- { path: ^/qis/login$, role: IS_AUTHENTICATED_ANONYMOUSLY } | |
- { path: ^/qis/login_check$, role: IS_AUTHENTICATED_ANONYMOUSLY } | |
# Secured part of the site | |
# This config requires being logged for the whole site and having the admin role for the admin part. | |
# Change these rules to adapt them to your needs | |
- { path: ^/qis/, role: [ROLE_USER] } | |
- { path: ^/.*, role: IS_AUTHENTICATED_ANONYMOUSLY } | |
acl: | |
connection: default |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The problem was the
anonymous: false
setting on the qis firewal. Solution: