A plugin’s config can be computed per request from a CEL expression, for example, reading an attribute of the authenticated Consumer or Principal, instead of always using a fixed value.
This is useful when you want to change plugin behavior depending on a specific situation, such as for authenticated users.
For example, you can set different limits for Consumers tagged with vip versus Consumers that don’t have that tag on the Rate Limiting Advanced plugin.
Kong Gateway supports this through the following mechanisms:
- Expressible config fields: A config field has a paired CEL expression field. If the expression evaluates successfully, Kong Gateway uses its result; otherwise, it falls back to the field’s static value.
- Direct CEL fields: A config field’s value is a CEL expression. There’s no separate static value to fall back to.
Both are different from a plugin’s condition field, which decides whether the whole plugin runs for a request. Expressible config fields and direct CEL fields don’t skip the plugin; they only change the value of one specific field.
The following plugins support expressions in fields:
|
Plugin |
Mechanism |
Fields |
|---|---|---|
| ACL | Direct CEL fields |
allow_when, deny_when
|
| Rate Limiting | Expressible config fields |
custom_key, second, minute, hour, day, month, year
|
| Rate Limiting Advanced | Expressible config fields |
limit, custom_key
|
See each plugin’s own documentation for how its fields are used.