hf400159 commented on code in PR #7520:
URL: https://github.com/apache/apisix/pull/7520#discussion_r931712560


##########
docs/zh/latest/plugins/consumer-restriction.md:
##########
@@ -92,26 +106,33 @@ curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 
'X-API-KEY: edd1c9f034335f13
 
 **测试插件**
 
-jack1 访问:
+`jack1` 发出访问请求,返回 `200` HTTP 状态码,代表访问成功:
 
 ```shell
 curl -u jack2019:123456 http://127.0.0.1:9080/index.html -i
+```
+
+```shell
 HTTP/1.1 200 OK
-...
 ```
 
-jack2 访问:
+`jack2` 发出访问请求,返回 `403` HTTP 状态码,代表访问被限制,插件生效:
 
 ```shell
 curl -u jack2020:123456 http://127.0.0.1:9080/index.html -i
+```
+
+```shell
 HTTP/1.1 403 Forbidden
 ...
 {"message":"The consumer_name is forbidden."}
 ```
 
-### 如何限制 `allowed_by_methods`
+### 通过 `allowed_by_methods` 限制访问
+
+首先,创建两个 Consumer,分别为 `jack1` 和 `jack2`,方法参考 [通过 `consumer_name` 
限制访问](#通过-consumername-限制访问)。
 
-下面是一个示例,在指定的 route 上开启了 `consumer-restriction` 插件,限制 `jack1` 只能使用 `POST` 进行访问:
+然后,在指定路由上启用并配置 `consumer-restriction` 插件,并限制指定 Consumer 只能使用指定 HTTP 方法进行访问:

Review Comment:
   ```suggestion
   然后,在指定路由上启用并配置 `consumer-restriction` 插件,并且仅允许 `jack1` 使用 `POST` 方法进行访问:
   ```



##########
docs/zh/latest/plugins/consumer-restriction.md:
##########
@@ -278,20 +307,21 @@ curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 
'X-API-KEY: edd1c9f034335f13
 }'
 ```
 
-**测试插件**
+再次对 Service 发出访问请求,返回 `403` HTTP 状态码,说明不在白名单列表的 `service_id` 被拒绝访问,插件生效:
 
 ```shell
 curl http://127.0.0.1:9080/index.html -H 'apikey: auth-jack' -i
+```
+
+```shell
 HTTP/1.1 403 Forbidden
 ...
 {"message":"The service_id is forbidden."}
 ```
 
-说明不在白名单列表的 `service_id` 被拒绝访问,插件配置生效。
-
 ## 禁用插件
 
-当你想去掉 `consumer-restriction` 插件的时候,很简单,在插件的配置中把对应的 json 配置删除即可,无须重启服务,即刻生效:
+当你需要禁用 `consumer-restriction` 插件时,可以通过以下命令删除相应的 JSON 配置,APISIX 
将会自动重新加载相关配置,无需重启服务:

Review Comment:
   ```suggestion
   当你需要禁用该插件时,可以通过以下命令删除相应的 JSON 配置,APISIX 将会自动重新加载相关配置,无需重启服务:
   ```



##########
docs/zh/latest/plugins/consumer-restriction.md:
##########
@@ -23,29 +28,34 @@ title: consumer-restriction
 
 ## 描述
 
-`consumer-restriction` 根据选择的不同对象做相应的访问限制。
+`consumer-restriction` 插件允许用户根据 Route、Service 或 Consumer 来设置相应的访问限制。
 
 ## 属性
 
-| 参数名     | 类型          | 可选项   | 默认值            | 有效值                         
  | 描述                                                                          
                                                  |
-| --------- | ------------- | ------ | -----------------| 
--------------------------------|-------------------------------------------------------------------------------------------------------------------------------|
-| type      |     string    | 可选    | consumer_name    | ["consumer_name", 
"service_id", "route_id"] | 根据不同的对象做相应的限制,支持 
`consumer_name`、`service_id`、`route_id`。                                        
                             |
-| whitelist | array[string] | 必选    |                  |                       
          | 与`blacklist`二选一,只能单独启用白名单或黑名单,两个不能一起使用。                             
                                                          |
-| blacklist | array[string] | 必选    |                  |                       
          | 与`whitelist`二选一,只能单独启用白名单或黑名单,两个不能一起使用。                             
                                                          |
-| rejected_code | integer   | 可选    | 403              | [200,...]             
          | 当请求被拒绝时,返回的 HTTP 状态码。                                               
                                                          |
-| rejected_msg | String   | 可选    |               |                        | 
当请求被拒绝时,返回的消息内容。                                                                
                                              |
-| allowed_by_methods | array[object] | 可选     |            |                   
     | 为用户设置允许的 HTTP methods 列表 , HTTP methods 可以为 
`["GET","POST","PUT","DELETE","PATCH","HEAD","OPTIONS","CONNECT","TRACE", 
"PURGE"]` |
+| 名称     | 类型          | 必选项   | 默认值            | 有效值                    | 描述  
                        |
+| --------- | ------------- | ------ | -----------------| 
-------------------------|------------------------|
+| type      | string    | 否    | consumer_name    | ["consumer_name", 
"service_id", "route_id"] | 支持设置访问限制的对象类型。 |
+| allowed_by_methods | array[object] | 否     |            | ["GET", "POST", 
"PUT", "DELETE", "PATCH", "HEAD", "OPTIONS", "CONNECT", "TRACE", "PURGE"] | 为 
Consumer 设置的允许的 HTTP 方法列表。 |
+| whitelist | array[string] | 是    |                  |                        
| 加入白名单的对象,优先级高于 `allowed_by_methods`。 |
+| blacklist | array[string] | 是    |                  |                        
| 加入黑名单的对象,优先级高于 `whitelist`。 |
+| rejected_code | integer   | 否    | 403              | [200,...]          | 
当请求被拒绝时,返回的 HTTP 状态码。    |
+| rejected_msg | string   | 否    |               |                   | 
当请求被拒绝时,返回的消息内容。     |

Review Comment:
   ```suggestion
   | rejected_msg | string   | 否    |               |                   | 
当请求被拒绝时,返回的错误信息。     |
   ```



##########
docs/zh/latest/plugins/consumer-restriction.md:
##########
@@ -92,26 +106,33 @@ curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 
'X-API-KEY: edd1c9f034335f13
 
 **测试插件**
 
-jack1 访问:
+`jack1` 发出访问请求,返回 `200` HTTP 状态码,代表访问成功:
 
 ```shell
 curl -u jack2019:123456 http://127.0.0.1:9080/index.html -i
+```
+
+```shell
 HTTP/1.1 200 OK
-...
 ```
 
-jack2 访问:
+`jack2` 发出访问请求,返回 `403` HTTP 状态码,代表访问被限制,插件生效:
 
 ```shell
 curl -u jack2020:123456 http://127.0.0.1:9080/index.html -i
+```
+
+```shell
 HTTP/1.1 403 Forbidden
 ...
 {"message":"The consumer_name is forbidden."}
 ```
 
-### 如何限制 `allowed_by_methods`
+### 通过 `allowed_by_methods` 限制访问
+
+首先,创建两个 Consumer,分别为 `jack1` 和 `jack2`,方法参考 [通过 `consumer_name` 
限制访问](#通过-consumername-限制访问)。

Review Comment:
   ```suggestion
   首先,创建两个 Consumer,分别为 `jack1` 和 `jack2`,创建方法请参考[通过 `consumer_name` 
限制访问](#通过-consumername-限制访问)。
   ```



##########
docs/zh/latest/plugins/consumer-restriction.md:
##########
@@ -207,7 +234,7 @@ curl http://127.0.0.1:9080/apisix/admin/services/2 -H 
'X-API-KEY: edd1c9f034335f
 }'
 ```
 
-2、在 `consumer` 上绑定 `consumer-restriction` 插件 (需要与一个授权插件配合才能绑定),并添加 
`service_id` 白名单列表
+然后配合 `key-auth` 授权插件,在指定路由上启用并配置 `consumer-restriction` 插件,并通过将 `service_id` 
加入 `whitelist` 来限制 Consumer 对 Service 的访问:

Review Comment:
   在指定消费者上配置 `key-auth` 和 `consumer-restriction` 插件,并将 `service_id` 加入 
`whitelist` 来限制 Consumer 对 Service 的访问:



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to