kafka-jaas.config


Overview

The `kafka-jaas.config` file is a configuration file used by Apache Kafka to define Java Authentication and Authorization Service (JAAS) settings. This file specifies the login module and credentials for authenticating Kafka clients and brokers using SASL/PLAIN mechanism. It enables Kafka to securely identify and authorize users or services attempting to connect to the Kafka cluster.

This particular file configures a JAAS login context named `KafkaServer` that uses the `PlainLoginModule` for simple username-password authentication. It defines an administrative user as well as other Kafka users with their respective credentials.


Configuration Structure and Purpose

The JAAS configuration syntax in this file follows the general format:

<loginContextName> {
    <loginModuleClass> <controlFlag>
    <options>;
};

Detailed Explanation of Configuration Entries

KafkaServer Login Context

KafkaServer {
    org.apache.kafka.common.security.plain.PlainLoginModule required
    serviceName="kafka"
    username="admin"
    password="admin-secret"
    user_admin="admin-secret"
    user_camel="camel-secret";
};

Usage Example

This JAAS configuration file is referenced by Kafka broker or client processes via the system property:

-Djava.security.auth.login.config=/path/to/kafka-jaas.config

Example Kafka broker startup command snippet:

kafka-server-start.sh config/server.properties \
  -Djava.security.auth.login.config=/etc/kafka/kafka-jaas.config

This enables the Kafka server to authenticate clients connecting with SASL/PLAIN mechanism using the credentials defined in this JAAS config.


Important Implementation Details


Interaction with Other System Components


Mermaid Diagram

Below is a flowchart illustrating how the `kafka-jaas.config` fits into the Kafka SASL authentication workflow:

flowchart TD
    Client["Kafka Client"]
    Broker["Kafka Broker"]
    JAASConfig["kafka-jaas.config\n(PlainLoginModule)"]
    SASL_PLAIN["SASL/PLAIN Auth"]
    Credentials["Username & Password"]
    AuthResult["Authentication Result"]

    Client -->|Sends Credentials| SASL_PLAIN
    Broker -->|Uses| JAASConfig
    SASL_PLAIN -->|Validates Credentials\nusing JAASConfig| JAASConfig
    SASL_PLAIN -->|Success or Failure| AuthResult
    AuthResult --> Broker
    AuthResult --> Client

Summary


This documentation provides a comprehensive understanding of the `kafka-jaas.config` file, its role in Kafka security, and how it supports SASL/PLAIN authentication workflows.