您好我正在使用Sonata的项目来创建某种管理仪表板。 它在开发环境的本地工作正常,但在使用prod环境时它不起作用。
我的意思是,当我尝试访问我的仪表板的网址时,例如/ editorial / admin 它重定向到登录(这是正常的),当我尝试登录时,它会中断我的所有会话,并且在我删除cookie之前无法再登录。
我无法弄清楚问题所在,所以我需要一些帮助。
config.yml
imports:
- { resource: parameters.yml }
- { resource: security.yml }
- { resource: amqp.yml }
- { resource: elasticsearch.yml }
- { resource: redis.yml }
- { resource: sonata.yml }
...
sonata.yml
sonata_admin:
title: MyProject
title_logo: bundles/MyProjectfrontendassets/images/logo/myproject-monogramme.png
persist_filters: true
dashboard:
blocks:
- { position: left, type: sonata.admin.block.admin_list }
groups:
sonata.admin.group.news:
label: News
icon: '<i class="fa fa-newspaper-o"></i>'
items:
- sonata.admin.news.advice
- sonata.admin.news.buying_guide
- sonata.admin.news.faq
security:
handler: sonata.admin.security.handler.noop
sonata_block:
default_contexts: [cms]
blocks:
# Enable the SonataAdminBundle block
sonata.admin.block.admin_list:
contexts: [admin]
sonata.admin.block.search_result:
contexts: [admin]
# Your other blocks
sonata.block.service.menu:
sonata.block.service.text:
sonata.user.block.menu: # used to display the menu in profile pages
sonata.user.block.account: # used to display menu option (login option)
security.yml
security:
role_hierarchy:
# Base roles
ROLE_BACKEND_USER: ROLE_USER
ROLE_ADMIN: [ROLE_BACKEND_USER, ROLE_SONATA_ADMIN]
ROLE_SUPER_ADMIN: [ROLE_USER, ROLE_ADMIN, ROLE_USER_ALLOWED_TO_SWITCH, ROLE_SONATA_ADMIN]
firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
frontend:
pattern: ^/
host: %frontend_host%
request_matcher: myproject_frontend.request_matcher
form_login:
provider: fos_userbundle
csrf_provider: form.csrf_provider
login_path: frontend_login
use_referer: true
default_target_path: frontend_home
logout: true
anonymous: true
switch_user: true
access_control:
- { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY, host: %backend_host% }
- { path: ^/editorial/admin, role: ROLE_SONATA_ADMIN, host: %frontend_host% }
- { path: ^/, role: IS_AUTHENTICATED_ANONYMOUSLY, host: %frontend_host% }
routing.yml
admin:
resource: '@SonataAdminBundle/Resources/config/routing/sonata_admin.xml'
prefix: /editorial/admin
_sonata_admin:
resource: .
type: sonata_admin
prefix: /editorial/admin