From 2a324eeca9a2622c79d2d6d9614fecdb467b961b Mon Sep 17 00:00:00 2001 From: Fergal Kearns Date: Tue, 21 Nov 2023 19:47:45 +0000 Subject: [PATCH] Allow password to be specified via environment variable for auth-user plugin --- cmd/plugin-auth-user/main.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/cmd/plugin-auth-user/main.go b/cmd/plugin-auth-user/main.go index e5c06ccc..e91a4852 100644 --- a/cmd/plugin-auth-user/main.go +++ b/cmd/plugin-auth-user/main.go @@ -2,12 +2,15 @@ package main import ( "flag" + "os" + "github.com/grepplabs/kafka-proxy/plugin/local-auth/shared" "github.com/hashicorp/go-plugin" "github.com/sirupsen/logrus" - "os" ) +const EnvSaslPassword = "SASL_PASSWORD" + type PasswordAuthenticator struct { Username string Password string @@ -29,6 +32,11 @@ func main() { passwordAuthenticator := &PasswordAuthenticator{} flags := passwordAuthenticator.flagSet() flags.Parse(os.Args[1:]) + + if passwordAuthenticator.Password == "" { + passwordAuthenticator.Password = os.Getenv(EnvSaslPassword) + } + if passwordAuthenticator.Username == "" || passwordAuthenticator.Password == "" { logrus.Errorf("parameters username and password are required") os.Exit(1)