我剛剛發現並開始使用Role Based Access control。yii2 - RBAC - 是否在後端和前端之間共享?
由於我使用yii2的高級模板,我想知道角色和權限是否在後端和前端層之間共享,或者如果它們是分開的。
例如
<?php
namespace app\commands;
use Yii;
use yii\console\Controller;
class RbacController extends Controller
{
public function actionInit()
{
$auth = Yii::$app->authManager;
// add "createPost" permission
$createPost = $auth->createPermission('createPost');
$createPost->description = 'Create a post';
$auth->add($createPost);
// add "author" role and give this role the "createPost" permission
$author = $auth->createRole('author');
$auth->add($author);
$auth->addChild($author, $createPost);
}
}
將創作和createpost可用於兩個後端和前端?
謝謝!
在Yii2中最好的Rbac教程www.freetuts.org/tutorial/view?id=6 – SohelAhmedM