-
Notifications
You must be signed in to change notification settings - Fork 7
Authentication support SASL_PLAINTEXT #68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the isSecureKafka flag should be changed to isSaslPlaintext, because there are many ways to secure a kafka cluster