Course contentsShow
← System Design
Lesson 727 of 1,91919. Event Streaming PlatformsFree lesson

Kafka Security: Authentication and Encryption

Securing Kafka with SSL/TLS encryption, SASL authentication, and ACLs for authorization at topic and cluster levels.

Kafka Security: Authentication and Encryption

What You'll Learn

How to secure Kafka communications and control access using SSL/TLS, SASL, and ACLs.

Why Security Matters in Kafka

By default, Kafka operates without authentication or encryption—anyone who can reach your brokers can produce, consume, or even delete topics. In production systems handling sensitive data, this is unacceptable. Kafka provides three layers of security: encryption (protecting data in transit), authentication (verifying identities), and authorization (controlling who can do what).

Encryption with SSL/TLS

SSL/TLS encrypts data flowing between clients and brokers, preventing eavesdropping. Think of it as sealing envelopes before sending letters through the mail.

You configure brokers to listen on encrypted ports and distribute certificates to clients. Both broker-to-client and broker-to-broker traffic can be encrypted.

Authentication with SASL

SASL (Simple Authentication and Security Layer) verifies who's connecting. Kafka supports multiple mechanisms:

  • PLAIN: Username/password (use only over SSL)
  • SCRAM: Salted Challenge Response (more secure than PLAIN)
  • GSSAPI/Kerberos: Enterprise-grade, ticket-based authentication
  • OAUTHBEARER: Token-based authentication for modern systems

Pick SCRAM for simplicity or Kerberos for enterprise integration.

Authorization with ACLs

Once authenticated, ACLs (Access Control Lists) define permissions. You specify which user/group can perform operations on specific resources:

  • Resource types: Topics, consumer groups, clusters
  • Operations: Read, Write, Create, Delete, Describe, Alter

Example: User "analytics-app" can READ from topic "events" but cannot CREATE topics.

ACLs are stored in ZooKeeper (or KRaft metadata) and enforced by brokers on every request.

Putting It Together

A typical secure setup: SSL encrypts traffic, SCRAM authenticates users, and ACLs restrict topic access. An unauthorized consumer can't even connect, and an authenticated one can only read permitted topics.

Key Takeaway: Kafka security layers work together—SSL/TLS encrypts communications, SASL authenticates identities, and ACLs authorize specific operations, creating defense-in-depth for your streaming platform.