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/13 10:53:50 UTC

[GitHub] [incubator-apisix] totemofwolf opened a new issue #971: request help: How to add password auth support for limit-count-redis

totemofwolf opened a new issue #971: request help: How to add password auth support for limit-count-redis
URL: https://github.com/apache/incubator-apisix/issues/971
 
 
   ### Issue description
   
   We need to support auth password for redis in production env.
   So i modified the file `limit-count/limit-count-redis.lua` as follows:
   
   ``` bash
   --- a/lua/apisix/plugins/limit-count/limit-count-redis.lua
   +++ b/lua/apisix/plugins/limit-count/limit-count-redis.lua
   @@ -51,6 +51,20 @@ function _M.incoming(self, key)
            return false, err
        end
    
   +    if pass then
   +        local ok, err = red:auth(conf.redis_pass)
   +        if not ok then
   +            return nil, redis_err(err)
   +        end
   +    end
   +
   +    if dbid then
   +        local ok, err = red:select(conf.redis_dbid)
   +        if not ok then
   +            return nil, redis_err(err)
   +        end
   +    end
   +
        local limit = self.limit
        local window = self.window
        local remaining
   ```
   
   when i do this request again, it says that:
   
   ``` bash
   $ curl -i 127.0.0.1:9180/apisix/admin/routes/00000000000000000075 -X PUT -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":"http_x_forwarded_for",
   >             "policy":"redis",
   >             "redis_host":"127.0.0.1",
   >             "redis_port":6389,
   >             "redis_pass":"xxxx",
   >             "redis_timeout":1000
   >         }
   >     },
   >     "vars":[
   >         [
   >             "scheme",
   >             "==",
   >             "https"
   >         ]
   >     ],
   >     "upstream_id":"2",
   >     "desc":"https://blog.nsa.work/api/admin/login"
   > }'
   HTTP/1.1 400 Bad Request
   Date: Fri, 13 Dec 2019 10:36:41 GMT
   Content-Type: text/plain
   Transfer-Encoding: chunked
   Connection: keep-alive
   Server: APISIX web server
   
   {"error_msg":"failed to check the configuration of plugin limit-count err: additional properties forbidden, found redis_pass"}
   ```
   
   How to support this additional properties of plugin limit-count ?
   
   ### Environment
   
   * apisix version (cmd: `apisix version`): 0.9
   * OS: alpine 3.7
   
   

----------------------------------------------------------------
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