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 2019/12/16 08:31:24 UTC

[GitHub] [incubator-apisix] totemofwolf opened a new pull request #976: Added password support for plugin limit-count-redis

totemofwolf opened a new pull request #976: Added password support for plugin limit-count-redis
URL: https://github.com/apache/incubator-apisix/pull/976
 
 
   NOTE: Please read the Contributing.md guidelines before submitting your patch:
   
   https://github.com/apache/incubator-apisix/blob/master/Contributing.md#how-to-add-a-new-feature-or-change-an-existing-one
   
   ### Summary
   
   SUMMARY_HERE
   
   ### Full changelog
   
   * Support password for plugin `limit-count-redis`
   * Test 1: without redis_pass
   
   ``` bash
   curl -i 127.0.0.1:9180/apisix/admin/routes/ -X POST -H 'Content-Type: application/json' -d '
   {
       "uris":[
           "/api/admin/login"
       ],
       "hosts":[
           "blog.nsa.work"
       ],
       "methods":[
           "POST"
       ],
       "plugins":{
           "limit-count":{
               "count":2,
               "time_window":60,
               "rejected_code":503,
               "key":"remote_addr",
               "policy":"redis",
               "redis_host":"127.0.0.1",
               "redis_port":6379,
               "redis_timeout":1000
           }
       },
       "vars":[
           [
               "scheme",
               "==",
               "https"
           ]
       ],
       "upstream_id":"2",
       "desc":"https://blog.nsa.work/api/admin/login"
   }'
   ```
   
   * Test 2 : with nil value redis_password
   
   ``` bash
   curl -i 127.0.0.1:9180/apisix/admin/routes/ -X POST -H 'Content-Type: application/json' -d '
   {
       "uris":[
           "/api/admin/login"
       ],
       "hosts":[
           "blog.nsa.work"
       ],
       "methods":[
           "POST"
       ],
       "plugins":{
           "limit-count":{
               "count":2,
               "time_window":60,
               "rejected_code":503,
               "key":"remote_addr",
               "policy":"redis",
               "redis_host":"127.0.0.1",
               "redis_port":6379,
               "redis_pass":"",
               "redis_timeout":1000
           }
       },
       "vars":[
           [
               "scheme",
               "==",
               "https"
           ]
       ],
       "upstream_id":"2",
       "desc":"https://blog.nsa.work/api/admin/login"
   }'
   ```
   
   * Test 3 : with password not nil
   
   ``` bash
   curl -i 127.0.0.1:9180/apisix/admin/routes/ -X POST -H 'Content-Type: application/json' -d '
   {
       "uris":[
           "/api/admin/login"
       ],
       "hosts":[
           "blog.nsa.work"
       ],
       "methods":[
           "POST"
       ],
       "plugins":{
           "limit-count":{
               "count":2,
               "time_window":60,
               "rejected_code":503,
               "key":"remote_addr",
               "policy":"redis",
               "redis_host":"127.0.0.1",
               "redis_port":6379,
               "redis_pass":"password",
               "redis_timeout":1000
           }
       },
       "vars":[
           [
               "scheme",
               "==",
               "https"
           ]
       ],
       "upstream_id":"2",
       "desc":"https://blog.nsa.work/api/admin/login"
   }'
   ```
   
   * logs:
   
   ``` bash
   apisix_1  | 1.1.1.1 - - [15/Dec/2019:19:24:29 +0800] blog.nsa.work "POST /api/admin/login HTTP/2.0" 400 87 1.461 "https://blog.nsa.work/admin/index.html" "UA" 127.0.0.1:56381 400 1.460
   apisix_1  | 1.1.1.1 - - [15/Dec/2019:19:24:37 +0800] blog.nsa.work "POST /api/admin/login HTTP/2.0" 400 87 0.794 "https://blog.nsa.work/admin/index.html" "UA" 127.0.0.1:56381 400 0.792
   apisix_1  | 1.1.1.1 - - [15/Dec/2019:19:24:42 +0800] blog.nsa.work "POST /api/admin/login HTTP/2.0" 503 635 0.001 "https://blog.nsa.work/admin/index.html" "UA" - - -
   ```
   

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services