This repository provides a setup for running Kafka with SCRAM (Simple Authentication and Security Layer) and SSL authentication mechanisms.
Ensure the following tools and dependencies are installed on your system before proceeding:
- Docker
- Docker Compose
- Bash (for running shell scripts)
- Proper permissions for executing scripts (e.g.,
chmod
permissions)
git clone https://github.com/tarikflz/kafka-with-scram-ssl.git
cd kafka-with-scram-ssl
The initialization script located at security/init.sh requires execution permissions. To set the proper permissions, run the following command:
chmod +x security/init.sh
Run the initialization script to generate SSL certificates and configure the SCRAM users:
./security/init.sh
Note: The script handles sensitive configurations, so ensure that it runs in a secure environment.
Use Docker Compose to start the Kafka and Zookeeper services:
docker-compose up -d
This will bring up the Kafka broker and Zookeeper with the configured authentication mechanisms.
Once the containers are running, you can verify the setup by connecting to the Kafka broker using a client configured for SCRAM-SSL authentication.
Example Kafka connection settings:
- Bootstrap Servers: localhost:9093
- SSL Key/Cert Paths: As generated in the security/ directory
- SCRAM Credentials: As configured in the security/init.sh script
To stop the services, run:
docker-compose down
- Ensure the generated SSL certificates and configuration files are stored securely to prevent unauthorized access.
- For production environments, fine-tune the Docker Compose file and security configurations according to your requirements.
Feel free to open issues or submit pull requests to improve this repository.