Php 我是否需要action类中的preExecute()函数来检查Symfony中的正确凭据?
要实现凭据,我是否需要实现以下预执行功能:Php 我是否需要action类中的preExecute()函数来检查Symfony中的正确凭据?,php,symfony1,sfguard,sfdoctrineguard,Php,Symfony1,Sfguard,Sfdoctrineguard,要实现凭据,我是否需要实现以下预执行功能: public function preExecute() { $this->configuration = new jobGeneratorConfiguration(); if (!$this->getUser()->hasCredential( $this->configuration->getCredentials($this->g
public function preExecute() {
$this->configuration = new jobGeneratorConfiguration();
if (!$this->getUser()->hasCredential(
$this->configuration->getCredentials($this->getActionName())
));
}
all:
is_secure: true
credentials: [ admin ]
或者在module/config/security.yml中这样定义就足够了:
public function preExecute() {
$this->configuration = new jobGeneratorConfiguration();
if (!$this->getUser()->hasCredential(
$this->configuration->getCredentials($this->getActionName())
));
}
all:
is_secure: true
credentials: [ admin ]
但是,我无法仅使用security.yml解决此问题!我认为preExecute不是必需的,symfony通过加载security.yml定义自动处理它!
请帮忙
我使用的是sfDoctrineGuardPlugin和sfforkeddoctrineaply插件。您无需对此进行预执行
security.yml文件足以阻止没有相应凭据的用户访问指定的模块或操作。请检查,您是否尝试过执行
/symfony cc
?@lonesomeday:事实上,我刚刚解决了问题,这是sf_guard_user表中的is_super_admin字段,对于fixture.yml:)中的所有虚拟用户,该字段被设置为1!这就是为什么每个用户都可以绕过凭证访问所有模块!你是对的!谢谢你的回答。问题是,在sfGuardUser中将is_admin字段设置为1,因此用户可以绕过所有凭据:)