简体   繁体   English

在一个奏鸣曲列表视图上显示“访问被拒绝”,但在另一个奏鸣曲列表上则没有

[英]“Access denied” on one Sonata list view but not on another

I am working on a project based on Symfony 2.7 and Sonata Admin. 我正在基于Symfony 2.7和Sonata Admin进行项目。 I am logged in as a superuser, and I have two browser tabs open. 我以超级用户身份登录,并且打开了两个浏览器选项卡。 On the first tab, I have successfully loaded the list view for a Video entity. 在第一个标签上,我已经成功加载了Video实体的列表视图。

On the second tab, I try to load a new admin screen for an entity called VideoDerivative. 在第二个标签上,我尝试为名为VideoDerivative的实体加载新的管理屏幕。 Instead of the list view, I get an uncaught AccessDeniedException. 而不是列表视图,我得到了未捕获的AccessDeniedException。 Expanding the error shows that the following logic has been invoked in CRUDController.php: 扩展错误表明在CRUDController.php中调用了以下逻辑:

public function listAction()
{
    if (false === $this->admin->isGranted('LIST')) {
        throw new AccessDeniedException();
    }

I find that interesting since, as I mentioned, I am able to view other entity types' list views just fine. 我发现这很有趣,因为如上所述,我可以查看其他实体类型的列表视图。

I'm not sure how to start debugging this. 我不确定如何开始调试它。 What would you do? 你会怎么做?

It turned out that I needed to create and assign these roles: 原来,我需要创建和分配以下角色:

    ROLE_APP_ADMIN_VIDEO_DERIVATIVE_ALL:
        - ROLE_APP_ADMIN_VIDEO_DERIVATIVE_CREATE
        - ROLE_APP_ADMIN_VIDEO_DERIVATIVE_EDIT
        - ROLE_APP_ADMIN_VIDEO_DERIVATIVE_DELETE
        - ROLE_APP_ADMIN_VIDEO_DERIVATIVE_LIST
        - ROLE_APP_ADMIN_VIDEO_DERIVATIVE_WORKFLOW

Putting those into place (and giving my user access to them) fixed my issue. 将这些放置到位(并让我的用户访问它们)可以解决我的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM