用于用户登录的SonataAdminBundle区域



我想为用户和管理员创建一个区域,但是它不起作用。

如果我去/admin/login它的工作原理,并给我登录页面的索纳塔仪表板。如果我点击/login,它现在工作,并给我重定向到我的登陆页面。

这是我的security.yml

security:
acl:                        #sonata
    connection: default     #sonata
# OLD ENCODERS
# encoders:
#     SymfonyComponentSecurityCoreUserUser: plaintext
# NEW ENCODER
encoders:
            "FOSUserBundleModelUserInterface": sha512
# OLD ROLE
# role_hierarchy:
#     ROLE_ADMIN:       ROLE_USER
#     ROLE_SUPER_ADMIN: [ROLE_USER, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH]
# SONATA ROLE
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  # if you are using acl then this line must be commented
# OLD PROVIDERS
# providers:
#     in_memory:
#         memory:
#             users:
#                 user:  { password: userpass, roles: [ 'ROLE_USER' ] }
#                 admin: { password: adminpass, roles: [ 'ROLE_ADMIN' ] }
# FOR PROVIDERS
providers:
    fos_userbundle:
        id: fos_user.user_manager
# OLD FIREWALLS
# firewalls:
#     dev:
#         pattern:  ^/(_(profiler|wdt)|css|images|js)/
#         security: false
#     login:
#         pattern:  ^/demo/secured/login$
#         security: false
#     secured_area:
#         pattern:    ^/demo/secured/
#         form_login:
#             check_path: _security_check
#             login_path: _demo_login
#         logout:
#             path:   _demo_logout
#             target: _demo
#         #anonymous: ~
#         #http_basic:
#         #    realm: "Secured Demo Area"
# FOS FIREWALLS
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
    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
        anonymous:          true
    # -> end custom configuration
    # default login area for standard users
    # 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:    false
            check_path:     /login_check
            failure_path:   null
        logout:             true
        anonymous:          true
# OLD ACCESS CONTROL
# access_control:
#     - { path: ^/demo/secured/hello/admin/, roles: ROLE_ADMIN }
#     #- { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY, requires_channel: https }
# NEW ACCESS CONTROL
access_control:
    # URL of FOSUserBundle which need to be available to anonymous users
    - { path: ^/login$, 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: ^/admin/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
    - { path: ^/admin/logout$, role: IS_AUTHENTICATED_ANONYMOUSLY }
    - { path: ^/admin/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: ^/admin/, role: [ROLE_ADMIN, ROLE_SONATA_ADMIN] }
    - { path: ^/.*, role: IS_AUTHENTICATED_ANONYMOUSLY }

这是我的routing.yml

# SONATA ROUTES
admin:
    resource: '@SonataAdminBundle/Resources/config/routing/sonata_admin.xml'
    prefix: /admin
_sonata_admin:
    resource: .
    type: sonata_admin
    prefix: /admin
# SONATA USER
royal_royal_productions:
    resource: "@RoyalRoyalProductionsRoyalProductionsBundle/Resources/config/routing.yml"
    prefix:   /
sonata_user_security:
    resource: "@SonataUserBundle/Resources/config/routing/sonata_security_1.xml"
sonata_user_resetting:
    resource: "@SonataUserBundle/Resources/config/routing/sonata_resetting_1.xml"
    prefix: /resetting
sonata_user_profile:
    resource: "@SonataUserBundle/Resources/config/routing/sonata_profile_1.xml"
    prefix: /profile
sonata_user_register:
    resource: "@SonataUserBundle/Resources/config/routing/sonata_registration_1.xml"
    prefix: /register
sonata_user_change_password:
    resource: "@SonataUserBundle/Resources/config/routing/sonata_change_password_1.xml"
    prefix: /profile
sonata_user:
    resource: '@SonataUserBundle/Resources/config/routing/admin_security.xml'
prefix: /admin

您似乎缺少了用户admin

的条目
sonata_user:
    resource: '@SonataUserBundle/Resources/config/routing/admin_security.xml'
    prefix: /admin

相关内容

  • 没有找到相关文章

最新更新