Consumer

    But this level of depth can be insufficient on some occasions.

    The fields for defining a Consumer are defined as below.

    The process of identifying a Consumer in APISIX is described below:

    1. The first step is Authentication. This is achieved by Authentication Plugins like and JWT.
    2. After authenticating, you can obtain the id of the Consumer. This id will be the unique identifier of a Consumer.
    3. The configurations like Plugins and Upstream bound to the Consumer are then executed.

    Consumers are useful when you have different consumers requesting the same API and you need to execute different Plugin and Upstream configurations based on the consumer. These need to be used in conjunction with the user authentication system.

    Refer to the documentation for the authentication Plugin to further understand the concept of a Consumer.

    We can use the Plugin to restrict our user “Jack” from accessing the API.

    1. # Add Jack to the blacklist
    2. $ curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
    3. "plugins": {
    4. "key-auth": {},
    5. "blacklist": [
    6. "jack"
    7. ]
    8. }
    9. },
    10. "upstream": {
    11. "127.0.0.1:1980": 1
    12. "type": "roundrobin"
    13. },
    14. "uri": "/hello"
    15. }'
    16. # Repeated tests, all return 403; Jack is forbidden to access this API
    17. $ curl http://127.0.0.1:9080/hello -H 'apikey: auth-one' -I