无法使用FOSUser Bundle对用户进行身份验证

时间:2016-06-02 16:28:13

标签: symfony fosuserbundle sonata-user-bundle

我正在将SonataAdmin捆绑包与SonataUser Bundle结合使用,以进行管理区域管理和身份验证。

但是,我希望非管理员用户在前端注册并注册以发出订单请求。

我遇到了从前端验证用户的问题,我一直收到错误的凭据错误。

我正在使用

FOSUserBundle: ~2.0@dev
SonataUserBundle: dev-add_support_for_fos_user2

这是我的security.yml

 security:

encoders:
    FOS\UserBundle\Model\UserInterface: sha512

# http://symfony.com/doc/current/book/security.html#where-do-users-come-from-user-providers
role_hierarchy:
    ROLE_ADMIN:       [ROLE_USER, ROLE_SONATA_ADMIN]
    ROLE_SUPER_ADMIN: [ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH]
    SONATA:
        - ROLE_SONATA_PAGE_ADMIN_PAGE_EDIT

providers:
    fos_userbundle:
        id: fos_user.user_manager

firewalls:
    # disables authentication for assets and the profiler, adapt it according to your needs
    dev:
        pattern: ^/(_(profiler|wdt)|css|images|js)/
        security: false

    admin:
        pattern:            /admin(.*)
        context:            user
        form_login:
            provider:       fos_userbundle
            login_path:     /admin/login
            use_forward:    false
            check_path:     /admin/login_check
            failure_path:   null
        logout:
            path:           /admin/logout
            target:         /admin/login
        anonymous:          true

    main:
        pattern:             .*
        context:             user
        form_login:
            provider:       fos_userbundle
            login_path:     /login
            use_forward:    false
            check_path:     fos_user_security_check
            failure_path:   null
            success_handler: authentication_handler
            failure_handler: authentication_handler
            require_previous_session: false
        logout:             true
        anonymous:          true

access_control:
    - { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
    - { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
    - { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }

    # Admin login page needs to be accessed without credential
    - { path: ^/admin/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
    - { path: ^/admin/logout$, role: IS_AUTHENTICATED_ANONYMOUSLY }
    - { path: ^/admin/login_check$, role: IS_AUTHENTICATED_ANONYMOUSLY }
    - { path: ^/admin/resetting, 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: ^/admin/, role: [ROLE_ADMIN, ROLE_SONATA_ADMIN] }
    - { path: ^/.*, role: IS_AUTHENTICATED_ANONYMOUSLY }

acl:
    connection: default

0 个答案:

没有答案