This policy runs in the cluster phase, evaluating rules against the content of specific Kafka request types.
- A Kafka client sends a request, for example to create a topic or produce a message.
- Event Gateway evaluates every configured rule for that request type.
- If a rule’s expression evaluates to
true, the request satisfies that rule.
- If a rule’s expression evaluates to
false, Event Gateway runs the rule’s configured action.
- If any rule configured with the
reject action fails, Event Gateway responds with the Kafka POLICY_VIOLATION error code and doesn’t forward the request to the backend cluster.
sequenceDiagram
autonumber
participant client as Client
participant egw as Event Gateway
participant broker as Event broker
client->>egw: request (e.g. CreateTopics)
egw->>egw: evaluate rules for the request type
alt If every reject rule passes
egw->>broker: forward request
else If a reject rule fails
egw-x client: POLICY_VIOLATION
end
You configure rules per Kafka request type.
Each request type exposes a different set of values to the rule’s CEL expression, matching the fields of that request.
All rule expressions also have access to the authentication fields.
See the policy reference for the supported request types and the values available to each one.
When at least one create_topics rule is configured, Event Gateway turns off automatic topic creation on Metadata requests.
Otherwise, clients could create topics through Metadata requests and bypass the create_topics rules.
Some request types, like create_topics, carry a batch of items in a single request.
Event Gateway evaluates every rule against each item independently.
When one item in a batch violates a reject rule, only that item is rejected with POLICY_VIOLATION, while the rest of the batch proceeds normally.
Each rule configures one of two actions, which runs when the rule’s expression evaluates to false:
reject: Fails the request, or the offending item in a batch, with the POLICY_VIOLATION error code.
passthrough: Lets the request continue, but records the violation the same way reject does (metrics and logs on a debug level).
If a rule’s expression can’t be evaluated, for example because a value has an unexpected format, Event Gateway treats the result as false and runs the rule’s action.
You can configure more than one rule per request type, and more than one Request Rule Validator policy on a virtual cluster. Like other cluster policies, they run in the order they’re configured.
We recommend placing the Request Rule Validator policy after the ACLs policy, so an unauthorized client learns nothing about your rules before it’s rejected on authorization grounds.