圆般 2011-03-22 22:35:36 4172次浏览 0条回复 1 0 0

文档中如是写道:

CAccessControlFilter performs authorization checks for the specified actions. 
CAccessControlFilter起到对特定(规定)的行为的进行权限检测的作用。
By enabling this filter, controller actions can be checked for access permissions.

通过启用这个筛选器,可以验证控制器行为的访问许可。

When the user is not denied by one of the security rules or allowed by a rule explicitly, he will be able to access the action. 
当一个用户未被安全规则拒绝或者被一个声明的规则允许,他将可以访问该(控制器)行为。
For maximum security consider adding array('deny', 'users'=>array('*'))as a last rule in a list so all actions will be denied by default.

出于最大限度安全考量,添加(形如)array('deny', 'users'=>array('*'))的规则到列表的最后,以便在默认情况下任何的(控制器)行为将被拒绝。

To specify the access rules, set the rules property, which should be an array of the rules.
制定访问规则时,应以数组的形式设置规则的属性。
Each rule is specified as an array of the following structure: 

每条规则应被制定成如下的数组结构:

array(
  'allow',  // or 'deny'  // 或者 'deny'
  // optional, list of action IDs (case insensitive) that this rule applies to   
  //可选项,应用此规则的(控制器)行为列表(括号内的不会翻译)
  'actions'=>array('edit', 'delete'),
  // optional, list of controller IDs (case insensitive) that this rule applies to 
//可选项,应用此规则的控制器列表
  // This option is available since version 1.0.3. 
//此选项自1.0.3版本开始生效。
  'controllers'=>array('post', 'admin/user'),
  // optional, list of usernames (case insensitive) that this rule applies to  
//可选项,应用此规则的用户名列表
  // Use * to represent all users, ? guest users, and  authenticated users 
//使用 * 代表所有用户,? 代表游客,@代表认证用户
  'users'=>array('thomas', 'kevin'),
  // optional, list of roles (case sensitive!) that this rule applies to.  
//可选项,应用此规则到角色(也相当于用户组吧?)列表。
//PS:问题哪里规定了用户组呢?括号内容中多了个感叹号!还是不会翻译~
  'roles'=>array('admin', 'editor'),
  // optional, list of IP address/patterns that this rule applies to   
//可选项,应用此规则到IP地址或IP地址样式。
  // e.g. 127.0.0.1, 127.0.0.*      
//举例~第二个应该就是所谓的IP地址样式吧~
  'ips'=>array('127.0.0.1'),
  // optional, list of request types (case insensitive) that this rule applies to 
//可选项,应用此规则到请求类型列表.
  'verbs'=>array('GET', 'POST'),
  // optional, a PHP expression whose value indicates whether this rule applies  
//可选项, php表达式的值确定规则是否应用.
  // This option is available since version 1.0.3. 
//此选项自1.0.3版本开始生效.
  'expression'=>'!$user->isGuest && $user->level==2',
  // optional, the customized error message to be displayed  
//可选项,用户自定义错误消息提示.
  // This option is available since version 1.1.1.  
//此选项自1.1.1版本开始生效.
  'message'=>'Access Denied.',
)
    没有找到数据。
您需要登录后才可以回复。登录 | 立即注册