Consumer
For the API gateway, it is usually possible to identify a certain type of requester by using a domain name such as a request domain name, a client IP address, etc., and then perform plugin filtering and forward the request to the specified upstream, but sometimes the depth is insufficient.

As shown in the image above, as an API gateway, you should know who the API Consumer is, so you can configure different rules for different API Consumers.
| Field | Required | Description |
|---|---|---|
| username | Yes | Consumer Name. |
| plugins | No | The corresponding plugin configuration of the Consumer, which has the highest priority: Consumer > Route > Service. For specific plugin configurations, refer to the Plugins section. |
In APISIX, the process of identifying a Consumer is as follows:

- Authorization certification: e.g key-auth, JWT, etc.
- Get consumer_name: By authorization, you can naturally get the corresponding Consumer
id, which is the unique identifier of the Consumer object. - Get the Plugin or Upstream information bound to the Consumer: Complete the different configurations for different Consumers.
To sum up, Consumer is a consumer of certain types of services and needs to be used in conjunction with the user authentication system.
For example, different consumers request the same API, and the gateway service corresponds to different Plugin or Upstream configurations according to the current request user information.
In addition, you can refer to the key-auth authentication authorization plugin call logic to help you further understand the Consumer concept and usage.
How to enable a specific plugin for a Consumer, you can see the following example:
Use the consumer-restriction plug-in to restrict the access of Jack to this API.