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 2020/10/21 07:00:02 UTC

[GitHub] [apisix] imjoey opened a new issue #2485: [discuss](Admin API): Need to support creating a new consumer via HTTP post?

imjoey opened a new issue #2485:
URL: https://github.com/apache/apisix/issues/2485


   ### Issue description
   
   As described in [Admin API](https://github.com/apache/apisix/blob/master/doc/admin-api.md#consumer), we could emit a `POST` request to `/apisix/admin/consumers` to create a new consumer. While actually, we could only get a response with `405 Not Allowed`. The source code also shows POST is not supported for consumers, see https://github.com/apache/apisix/blob/master/apisix/admin/consumers.lua#L105 .
   
   Except consumer, all other resources have good support for `POST` method for creation. So may I ask that why not for consumer? Any feedback is welcome. Thanks.
   
   
   


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



[GitHub] [apisix] liuxiran commented on issue #2485: [discuss](Admin API): Need to support creating a new consumer via HTTP post?

Posted by GitBox <gi...@apache.org>.
liuxiran commented on issue #2485:
URL: https://github.com/apache/apisix/issues/2485#issuecomment-716071919


   @membphis this issue means that:
   * Admin-Api doc says: we can  create a consumer via HTTP POST request which can create comsumer id generated by server, but accurately cloud not and return the error msg below
   >  {"error_msg":"not supported `POST` method for consumer"}
    
   this error msg wrote in the code: https://github.com/apache/apisix/blob/master/apisix/admin/consumers.lua#L105 .
   it means that we did it on purpose,  so what is the reason consumer did not support `POST` request?
   
   * other resources in APISIX could support `POST` for creation, so we think `consumer` also need it
   
   reopen this issue and looking forward to your reply, thx again:)
   
   


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



[GitHub] [apisix] imjoey commented on issue #2485: [discuss](Admin API): Need to support creating a new consumer via HTTP post?

Posted by GitBox <gi...@apache.org>.
imjoey commented on issue #2485:
URL: https://github.com/apache/apisix/issues/2485#issuecomment-716079699


   @membphis thanks for clarification. I’m asking here to confirm that what
   the problem is about, lack of a feature or just doc. I’ve got the answer
   and will commit another PR to fix this soon.
   
   On Sunday, October 25, 2020, YuanSheng Wang <no...@github.com>
   wrote:
   
   > so what is the reason consumer did not support POST request
   >
   > for POST method, it means will create new objects always.
   > but for consumer, one name only can create one consumer. so we do not
   > allow to use POST method to create consumer object.
   >
   > —
   > You are receiving this because you authored the thread.
   > Reply to this email directly, view it on GitHub
   > <https://github.com/apache/apisix/issues/2485#issuecomment-716079025>, or
   > unsubscribe
   > <https://github.com/notifications/unsubscribe-auth/AATMWQLWK5NOZLQUSJTVSHLSMN5QJANCNFSM4SZLB5BA>
   > .
   >
   


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



[GitHub] [apisix] membphis commented on issue #2485: [discuss](Admin API): Need to support creating a new consumer via HTTP post?

Posted by GitBox <gi...@apache.org>.
membphis commented on issue #2485:
URL: https://github.com/apache/apisix/issues/2485#issuecomment-716079025


   > so what is the reason consumer did not support POST request
   
   for `POST` method, it means will create new objects always.
   but for consumer, one name only can create one consumer. so we do not allow to use `POST` method to create consumer object.
   


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



[GitHub] [apisix] membphis commented on issue #2485: [discuss](Admin API): Need to support creating a new consumer via HTTP post?

Posted by GitBox <gi...@apache.org>.
membphis commented on issue #2485:
URL: https://github.com/apache/apisix/issues/2485#issuecomment-716069662


   ```
   {"error_msg":"not supported `POST` method for consumer"}
   ```
   
   please see the error message, it has told you the reason. please use `PUT` method.


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



[GitHub] [apisix] membphis closed issue #2485: [discuss](Admin API): Need to support creating a new consumer via HTTP post?

Posted by GitBox <gi...@apache.org>.
membphis closed issue #2485:
URL: https://github.com/apache/apisix/issues/2485


   


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



[GitHub] [apisix] imjoey commented on issue #2485: [discuss](Admin API): Need to support creating a new consumer via HTTP post?

Posted by GitBox <gi...@apache.org>.
imjoey commented on issue #2485:
URL: https://github.com/apache/apisix/issues/2485#issuecomment-715876814


   @membphis please see the request and response below:
   
   ```
   ➜  apisix git:(master) curl http://127.0.0.1:9080/apisix/admin/consumers  -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X POST -i -d '
   {
       "username": "jack",
       "plugins": {
           "key-auth": {
               "key": "auth-one"
           },
           "limit-count": {
               "count": 2,
               "time_window": 60,
               "rejected_code": 503,
               "key": "remote_addr"
           }
       }
   }'
   HTTP/1.1 405 Not Allowed
   Transfer-Encoding: chunked
   Access-Control-Allow-Credentials: true
   Access-Control-Allow-Origin: *
   Access-Control-Expose-Headers: *
   Access-Control-Max-Age: 3600
   Connection: keep-alive
   Content-Type: application/json
   Date: Sat, 24 Oct 2020 07:47:35 GMT
   Keep-Alive: timeout=4
   Proxy-Connection: keep-alive
   Server: openresty
   
   {"error_msg":"not supported `POST` method for consumer"}
   ```
   
   The source code https://github.com/apache/apisix/blob/master/apisix/admin/consumers.lua#L105 also shows it up. I guess the reason is that the key of a consumer object equals to the value of `username` field, not equals to the `id` field as the other resources(route/upstream/services/ssl). Did I catch the point? Looking forward to your feedback. Thanks.
   


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



[GitHub] [apisix] imjoey commented on issue #2485: [discuss](Admin API): Need to support creating a new consumer via HTTP post?

Posted by GitBox <gi...@apache.org>.
imjoey commented on issue #2485:
URL: https://github.com/apache/apisix/issues/2485#issuecomment-716080977


   @membphis @liuxiran  I believe that we've got the consensus, so this issue would be closed. I will commit another one for tracking the doc errors. Thank you all guys.


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



[GitHub] [apisix] membphis commented on issue #2485: [discuss](Admin API): Need to support creating a new consumer via HTTP post?

Posted by GitBox <gi...@apache.org>.
membphis commented on issue #2485:
URL: https://github.com/apache/apisix/issues/2485#issuecomment-715663394


   Please provide a mini use case that we can use to reproduce this problem.
   
   


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



[GitHub] [apisix] membphis commented on issue #2485: [discuss](Admin API): Need to support creating a new consumer via HTTP post?

Posted by GitBox <gi...@apache.org>.
membphis commented on issue #2485:
URL: https://github.com/apache/apisix/issues/2485#issuecomment-716078914


   > * Admin-Api doc says: we can  create a consumer via HTTP POST request
   
   where?
   
   here is the link, it is the API of `consumer`, please check it:
   
   https://github.com/apache/apisix/blob/master/doc/admin-api.md#consumer


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



[GitHub] [apisix] imjoey edited a comment on issue #2485: [discuss](Admin API): Need to support creating a new consumer via HTTP post?

Posted by GitBox <gi...@apache.org>.
imjoey edited a comment on issue #2485:
URL: https://github.com/apache/apisix/issues/2485#issuecomment-715876814


   @membphis please see the request and response below:
   
   ```
   ➜  apisix git:(master) curl http://127.0.0.1:9080/apisix/admin/consumers  -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X POST -i -d '
   {
       "username": "jack",
       "plugins": {
           "key-auth": {
               "key": "auth-one"
           },
           "limit-count": {
               "count": 2,
               "time_window": 60,
               "rejected_code": 503,
               "key": "remote_addr"
           }
       }
   }'
   HTTP/1.1 405 Not Allowed
   Transfer-Encoding: chunked
   Access-Control-Allow-Credentials: true
   Access-Control-Allow-Origin: *
   Access-Control-Expose-Headers: *
   Access-Control-Max-Age: 3600
   Connection: keep-alive
   Content-Type: application/json
   Date: Sat, 24 Oct 2020 07:47:35 GMT
   Keep-Alive: timeout=4
   Proxy-Connection: keep-alive
   Server: openresty
   
   {"error_msg":"not supported `POST` method for consumer"}
   ```
   
   The source code https://github.com/apache/apisix/blob/master/apisix/admin/consumers.lua#L105 also shows it up. Looking forward to your feedback. Thanks.
   


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



[GitHub] [apisix] imjoey closed issue #2485: [discuss](Admin API): Need to support creating a new consumer via HTTP post?

Posted by GitBox <gi...@apache.org>.
imjoey closed issue #2485:
URL: https://github.com/apache/apisix/issues/2485


   


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