You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2022/01/25 09:42:47 UTC

[GitHub] [apisix] zaunist commented on a change in pull request #6195: fix consumer-restriction plugin doc

zaunist commented on a change in pull request #6195:
URL: https://github.com/apache/apisix/pull/6195#discussion_r791529363



##########
File path: docs/zh/latest/plugins/consumer-restriction.md
##########
@@ -117,6 +119,74 @@ HTTP/1.1 403 Forbidden
 {"message":"The consumer_name is forbidden."}
 ```
 
+### 如何限制 `allowed_by_methods`
+
+下面是一个示例,在指定的route上开启了`consumer-restriction`插件,限制`jack1`只能使用`POST`进行访问:

Review comment:
       ```suggestion
   下面是一个示例,在指定的 route 上开启了`consumer-restriction`插件,限制`jack1`只能使用`POST`进行访问:
   ```
   We should add a space between Chinese and English. You can ref https://github.com/sparanoid/chinese-copywriting-guidelines

##########
File path: docs/zh/latest/plugins/consumer-restriction.md
##########
@@ -117,6 +119,74 @@ HTTP/1.1 403 Forbidden
 {"message":"The consumer_name is forbidden."}
 ```
 
+### 如何限制 `allowed_by_methods`
+
+下面是一个示例,在指定的route上开启了`consumer-restriction`插件,限制`jack1`只能使用`POST`进行访问:
+
+```shell
+curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
+{
+    "uri": "/index.html",
+    "upstream": {
+        "type": "roundrobin",
+        "nodes": {
+            "127.0.0.1:1980": 1
+        }
+    },
+    "plugins": {
+        "basic-auth": {},
+        "consumer-restriction": {
+            "allowed_by_methods":[{
+                "user": "jack1",
+                "methods": ["POST"]
+            }]
+        }
+    }
+}'
+```
+
+**测试插件**
+
+jack1访问:
+
+```shell
+curl -u jack2019:123456 http://127.0.0.1:9080/index.html
+HTTP/1.1 403 Forbidden
+...
+{"message":"The consumer_name is forbidden."}
+```
+
+增加`jack1` `GET`访问能力:
+
+```shell
+curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
+{
+    "uri": "/index.html",
+    "upstream": {
+        "type": "roundrobin",
+        "nodes": {
+            "127.0.0.1:1980": 1
+        }
+    },
+    "plugins": {
+        "basic-auth": {},
+        "consumer-restriction": {
+            "allowed_by_methods":[{
+                "user": "jack1",
+                "methods": ["POST","GET"]
+            }]
+        }
+    }
+}'
+```
+
+jack1访问:

Review comment:
       ditto




-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org