Authentication support SASL_PLAINTEXT#68
Conversation
KKNithin
commented
Jun 20, 2025
- New docker file for secure kafka dev
- Modified code to use environment variables
- Added kafka auth configuration for user along with input required
- Currently we can use multiple brokers for one cluster with one user
| github.com/IBM/sarama v1.45.2 | ||
| github.com/gorilla/mux v1.8.1 | ||
| github.com/jedib0t/go-pretty/v6 v6.6.7 | ||
| github.com/joho/godotenv v1.5.1 |
There was a problem hiding this comment.
you can load the variables from the env file via Makefile, see here for example. We don't really have a use case for writing the env variables to an env file, so you can remove this library.
| s.adminClient = nil | ||
| s.isAuthenticated = false | ||
| s.version = constants.SaramaKafkaVersion | ||
| s.isSecureKafka = false |
There was a problem hiding this comment.
I think if you just do s = session{} it will be better. This way you don't have to worry about clearing all the properties from the session object when you want to log out
|
|
||
| sessionData := SessionData{Brokers: currentSession.brokers, IsAuthenticated: currentSession.isAuthenticated, Version: currentSession.version.String()} | ||
| err = json.NewEncoder(file).Encode(sessionData) | ||
| envMap := make(map[string]string) |
There was a problem hiding this comment.
I'm a bit confused, did we move the config file to the env file? I am not a big fan of introducing a third party library for a trivial task like writing to a file, so if we decide this is the direction we want to take, we can easily implement this functionality ourselves.
Or we can have a hybrid solution where the broker metadata is stored in a flat file on disk and only the credentials are preserved in the env variable.
@DuarteMartinho what do you think?
| broker = strings.TrimSpace(broker) | ||
| if broker == "" { | ||
| broker = constants.KafkaBroker | ||
| currentSession.isSecureKafka = readUserClosedInput("Is your kafka configured with SASL_PLAINTEXT security? (y/n): ") |
There was a problem hiding this comment.
the isSecureKafka flag should be changed to isSaslPlaintext, because there are many ways to secure a kafka cluster