php - 是否可以在 Symfony 2 中保护整个 Controller ?

标签 php symfony jms

我正在使用 JMS Security Extra bundle 来保护我的 Controller 中的方法。 但是有什么方法可以使用 @Secure 保护整个 Controller ?

最佳答案

这可以按照 Documentaion 完成

https://github.com/schmittjoh/JMSSecurityExtraBundle/issues/50

Tip: If you like to secure all actions of the controller with the same rule, you may also specify @PreAuthorize on the class itself. Caution though, this rule is only applied to the methods which are declared in the class.

use JMS\SecurityExtraBundle\Annotation\PreAuthorize;

 /** @PreAuthorize("hasRole('A') or (hasRole('B') and hasRole('C'))") */
class MyService
{

    public function secureMethod()
    {
        // ...
    }
}

关于php - 是否可以在 Symfony 2 中保护整个 Controller ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11999210/

相关文章:

Eclipse 中的 Java EE 项目文件夹结构?

javascript - Symfony DataTables [Js] Composer

php - Elasticsearch-ICU排序规则关键字字段-挪威语- Elasticsearch 在排序时被视为å

unit-testing - 如何使用 Java DSL 测试 Camel JMS 路由

使用 PDO MySQL 的 PHP 搜索和分页 - SQLSTATE [42000] : Syntax error

php - 如何在 PHP 代码运行时估计资源使用情况

php - 向MySQL表插入大量数据只插入1行?

php - QT5 : best efficiant way to "unserialise" array of keys/values from json result

php - 使用 Symfony 2 创建表单步骤?

java - 如何在 Spring 集成中将 XML JMS 消息发送到 FTP