You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by GitBox <gi...@apache.org> on 2021/11/06 08:50:16 UTC
[GitHub] [kafka] dongjinleekr commented on pull request #11454: KAFKA-13341: Quotas are not applied to requests with null clientId
dongjinleekr commented on pull request #11454:
URL: https://github.com/apache/kafka/pull/11454#issuecomment-962420341
Hi @splett2,
I inspected this issue a little bit.
According to [KIP-55](https://cwiki.apache.org/confluence/display/KAFKA/KIP-55%3A+Secure+Quotas+for+Authenticated+Users), the notion of client quota and user principal was introduced in 0.9, and [the per-user principal quota configuration was adopted in 0.10](https://github.com/apache/kafka/pull/1753) by @rajinisivaram.
> User principal is an authenticated user or a grouping of unauthenticated users chosen by the broker using a configurable PrincipalBuilder and is currently used for ACLs.
> Multi-user systems have a hierarchy - user owns zero or more clients. <user-principal, client-id> defines a safe group of clients. The shorter unsafe client-id is sufficient in client metrics and logs, but **quotas should be allocated to safe groups to avoid clients of one user throttling clients of another user with the same client-id.**
> For a given client connection, the most specific quota matching the connection will be applied.
Every time Kafka client creates a `KafkaChannel` to the server with `ChannelBuilder`, it makes a `KafkaPrincipal` - the default implementation, `DefaultKafkaPrincipalBuilder#build`, returns `KafkaPrincipal.ANONYMOUS` when Plaintext connection of SSL authentication fails. So, it seems like we should treat `KafkaPrincipal.ANONYMOUS` as a default user principal and not applying the (null or empty) client quota limit to `KafkaPrincipal.ANONYMOUS` seems like a bug.
In fact, after reviewing the related code, I found that I was taking the wrong approach here; Since `DefaultQuotaCallback#quotaMetricTags` returns appropriate metric tag per given <user principal, client id> and `DefaultQuotaCallback#quotaLimit` calculates the quota per given metric tag in precedence order, the null or empty client case should be handled by `DefaultQuotaCallback#quotaMetricTags`, not `DefaultQuotaCallback#quotaMetricTags`.
So I updated the PR. Following [KIP-55](https://cwiki.apache.org/confluence/display/KAFKA/KIP-55%3A+Secure+Quotas+for+Authenticated+Users), it will use `/config/users/<default>` and `/config/clients/<default>` in order.
--
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.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org