dongyu2300 2013-09-04 21:09
浏览 38
已采纳

Symfony2(v2.3.4) - 使用FOSUserBundle时拒绝访问

When i go to project/web/ the application redirect me to te web/login where is a form for logging in.

But when i got authorized, after submit the form i got back to project/web/ path with Acces denied exception. What is wrong with my settings, i can't figure it out.

routing.yml

my_backend:
    resource: "@MyBackendBundle/Controller/"
    type:     annotation
    prefix:   /

fos_user_security:
    resource: "@FOSUserBundle/Resources/config/routing/security.xml"

security.yml

security:
encoders:
    FOS\UserBundle\Model\UserInterface: sha512

providers:
    fos_userbundle:
        id: fos_user.user_provider.username

firewalls:
    main:
        pattern: ^/
        form_login:
            provider: fos_userbundle
            csrf_provider: form.csrf_provider
            login_path:                     /login
            use_forward:                    false
            check_path:                     /login_check
            post_only:                      true
            always_use_default_target_path: false
            default_target_path:            /
            target_path_parameter:          _target_path
            use_referer:                    false
            failure_path:                   null
            failure_forward:                false
            username_parameter:             _username
            password_parameter:             _password
            csrf_parameter:                 _csrf_token
            intention:                      authenticate
        logout:       true
        anonymous:    true
access_control:
    - { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
    - { path: ^/, role: ROLE_ADMIN }
  • 写回答

4条回答 默认 最新

  • dsij89625 2013-09-05 05:06
    关注

    After you authenticate you are being set another role then ROLE_ADMIN. Please use the app_dev.php version of the site and at bottom it will tell you your role after you access the access denied page.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 win10权限管理,限制普通用户使用删除功能
  • ¥15 minnio内存占用过大,内存没被回收(Windows环境)
  • ¥65 抖音咸鱼付款链接转码支付宝
  • ¥15 ubuntu22.04上安装ursim-3.15.8.106339遇到的问题
  • ¥15 求螺旋焊缝的图像处理
  • ¥15 blast算法(相关搜索:数据库)
  • ¥15 请问有人会紧聚焦相关的matlab知识嘛?
  • ¥15 网络通信安全解决方案
  • ¥50 yalmip+Gurobi
  • ¥20 win10修改放大文本以及缩放与布局后蓝屏无法正常进入桌面