【问题标题】:Are BizRules (Business Rules) in RBAC really safe?RBAC 中的 BizRules(业务规则)真的安全吗?
【发布时间】:2010-12-11 18:58:30
【问题描述】:

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

例如Yii框架支持:http://www.yiiframework.com/doc/api/1.1/CAuthManager#createRole-detail

public CAuthItem createRole(string $name, string $description='', string $bizRule=NULL, mixed $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));

它基本上对 bizRule 进行评估,其中 $params 在其上下文中设置为给定数组。

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

【问题讨论】:

标签: php security rbac


【解决方案1】:

也许它会对某人有所帮助,如果你有 php 5.3 我认为你可以使用 LambdaFunctions

$bizRule = function ($param) { return $param[1] = $param[2]};

【讨论】:

    猜你喜欢
    • 2020-11-03
    • 2018-07-31
    • 2019-11-24
    • 1970-01-01
    • 2019-11-11
    • 2021-02-20
    • 2021-09-30
    • 2016-03-26
    • 2012-06-12
    相关资源
    最近更新 更多