Skip to content

Commit

Permalink
Merge pull request #153 from fhke/feature/password-env-var
Browse files Browse the repository at this point in the history
Allow password to be specified via environment variable
  • Loading branch information
everesio authored Nov 23, 2023
2 parents 0293b26 + 2a324ee commit b1d938d
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion cmd/plugin-auth-user/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down

0 comments on commit b1d938d

Please sign in to comment.