我希望将对控制器的访问限制为只能访问一个IP (或IP列表)。
正确的配置方法是什么?(例如,我只希望IP 172.19.37.175能够访问index.php?r=painel/restrict)。
我试过这样做:
public function behaviors()
{
return [
'access' => [
'class' => AccessControl::classname(),
'only' => ['index'],
'rules' => [
[
'allow' => true,
'roles' => ['?'],
'ips' => ['172.19.37.175'],
],
],
'denyCallback' => function ($rule, $action) {
throw new \Exception('You are not allowed to access this page');
}
],
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['post'],
],
],
];
}发布于 2017-07-06 21:48:17
变化
'roles' => ['?'] 至
'roles' => ['@'] https://stackoverflow.com/questions/44949605
复制相似问题