Due to the minimal amount of documentation around Kafka authentication using a simple username and password approach, here is an example of a docker-based Kafka setup along with a sample producer and consumer implementing simple SASL authentication which uses pre-defined credentials (username and password) to authenticate connections to the Kafka broker.
An explanation of the code written here as well as the basic concepts, can be found here : https://noobjoint.medium.com/deploying-kafka-with-plain-sasl-authentication-using-docker-347a74b3be16