【问题标题】:Allow unsecured access to Symfony object action in security.yml允许对 security.yml 中的 Symfony 对象操作进行不安全访问
【发布时间】:2011-10-18 16:00:14
【问题描述】:

我在 Symfony 1.4.13 中有一个特定的模块,在其 security.yml 文件中默认设置为安全。我有一个特定的对象操作,我希望任何人(已注销的用户)都可以访问它,但似乎找不到正确的方法来纠正 YAML 文件中的操作名称以匹配它。

具体来说,我有一个project 模块,其中包含典型的索引、显示、创建等操作,以及一个runReport 对象操作(因此操作方法的名称是executeListRunReport)。 security.yml文件如下:

all:
  is_secure: true

index:
  credentials: pm_view

show:
  credentials: pm_view

filter:
  credentials: pm_view

runReport:   # This is the one that is giving me problems
  is_secure: false

我在actions.php中的方法是:

public function executeListRunReport(sfWebRequest $request) {
...
}

这对登录用户来说很好,当转到project/[idOfObject]/ListRunReport 时。

如何编写 security.yml 文件以允许任何人访问该操作(例如,直接从我手动生成的 URL)而无需登录?谢谢!

【问题讨论】:

  • 不确定,但请尝试将 all: 更改为 default:

标签: security symfony1 symfony-1.4


【解决方案1】:

如果您的应用程序/*/config/security.yml 有

default:
  is_secure: true

您可以在模块的 security.yml 中定义:

index:
  credentials: pm_view

show:
  credentials: pm_view

filter:
  credentials: pm_view   

runReport:
  is_secure: false

并从你的模块中删除:

all:
  is_secure: true

【讨论】:

    【解决方案2】:

    原来问题在于我在 security.yml 中命名元素的方式(抱歉,如果问题不够清楚,无法表明这可能是最初的问题)。

    它适用于 listRunReport,所以代码如下:

    listRunReport:
        is_secure:false
    

    @arsenik 是正确的,因为 all:is_secure:true 是不必要的,但不幸的是这并没有解决问题(它可以保留)。

    教训是,当使用最终命名为 executeListXYZ 的列表对象操作时,必须在 security.yml 中将其标记为 listXYZ。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-05-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-02-16
      • 2010-12-05
      相关资源
      最近更新 更多