Php RBAC中的BizRules(业务规则)真的安全吗?

Php RBAC中的BizRules(业务规则)真的安全吗?,php,security,rbac,Php,Security,Rbac,在RBAC(基于角色的访问控制)中使用BizRules的想法让我感到恶心。它基本上是一种定义脚本以在授权期间针对数据运行的方法 例如,Yii框架支持它: public-CAuthItem-createRole(字符串$name,字符串$description='',字符串$bizRule=NULL,混合$data=NULL) 以下是执行业务规则的源代码: /** * Executes the specified business rule. * @param stri

在RBAC(基于角色的访问控制)中使用BizRules的想法让我感到恶心。它基本上是一种定义脚本以在授权期间针对数据运行的方法

例如,Yii框架支持它:

public-CAuthItem-createRole(字符串$name,字符串$description='',字符串$bizRule=NULL,混合$data=NULL)

以下是执行业务规则的源代码:

    /**
     * Executes the specified business rule.
     * @param string $bizRule the business rule to be executed.
     * @param array $params parameters passed to {@link IAuthManager::checkAccess}.
     * @param mixed $data additional data associated with the authorization item or assignment.
     * @return boolean whether the business rule returns true.
     * If the business rule is empty, it will still return true.
     */
    public function executeBizRule($bizRule,$params,$data)
    {
            return $bizRule==='' || $bizRule===null || ($this->showErrors ? eval($bizRule)!=0 : @eval($bizRule)!=0);
    }
因此,您可以执行以下操作:

    // Assume this bizRule: $bizRule='return Yii::app()->user->id==$params["post"]->authID;';
    Yii::app()->user->checkAccess('createUser', array('post' => $post));
它基本上是在上下文中将$params设置为给定数组的bizRule求值


我不喜欢那些安全方面的商业规则。有更好的方法吗?

如果你有PHP5.3,也许它会帮助一些人,我认为你可以使用LambdaFunctions

$bizRule = function ($param) { return $param[1] = $param[2]};
为什么不在网上问一下呢?事实上,检查一下。