php-casbin/yii-permission

Hope to add a new feature: PermissionControl

pigochu opened this issue · 1 comments

Orignal Yii has AccessControl that use in Controller behavior.

It's simple for us to control page permission.

I think yii-permission should be able to implement.

usage example in controller:

public function behaviors() {

    return [
       'permission' => PermissionControl::class
       'rules' => [
           'allow' => true,
           'actions' => ['index', 'view'],
           'enforce' => [
              'user' => \Yii::$app->user->identity->id, // map to $v0
              'obj' => 'data1', // map to $v1
              'dom' => 'domain1', // map to $v2 ?
              'act' => 'read', // map to $v3 ?
           ],
       ],
    ];
}

It will check current user can read domain1's data1 , then allow actions index and view.
$v0~$v5 can be alias in config for readable.

I don’t know if anyone can experiment with my wish 😍