how to secure whole pages except login page in symfony2?

后端 未结 2 2098
不思量自难忘°
不思量自难忘° 2021-01-03 07:09

I want to have whole site secured through login with FOSUserBundle. I tried to set security.yml like this

security:
encoders:
    Symfony\\Component\\Securit         


        
相关标签:
2条回答
  • 2021-01-03 07:40

    Every time the same, nobody bats an eye on the documentation. Wayne. But for your spamming you shouldn't get a answer, but this would be unfair ^^

    security:
        firewalls:
            main:
                pattern: ^/
                # other settings
                anonymous:    true
    
        access_control:
            - { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
            - { path: ^/, role: ROLE_USER }
    
    0 讨论(0)
  • 2021-01-03 07:59

    for move to this URL localhost/QuickBacklog/web/app_dev.php/dashboard
    you must add like this in the security.yml

    firewalls:
            main:
                pattern:    ^/
                form_login:
                    provider:             fos_userbundle
                    default_target_path:  /dashboard/                
                logout:     
                    ........
                    invalidate_session: false
                anonymous: ~
    

    In the routing file

    applicationlogin_success:
      pattern: /dashboard/
      defaults: { _controller: SampleBundle:Default:FrontPage } 
    

    BY USING default_target_path : ROUTING_PATTERN
    u will redirect it...

    0 讨论(0)
提交回复
热议问题