diff --git a/main.go b/main.go index 8e64ccc..c9d4180 100644 --- a/main.go +++ b/main.go @@ -33,6 +33,7 @@ var ( buildTime = fmt.Sprintf(time.Now().UTC().Format("01-02-2006 15:04:05")) // configuration variables flagDisableLogin = false + flagRemoteUser = false flagBindAddress = "0.0.0.0:5000" flagSmtpHostname = "127.0.0.1" flagSmtpPort = 25 @@ -77,6 +78,7 @@ var embeddedAssets embed.FS func init() { // command-line flags and env variables flag.BoolVar(&flagDisableLogin, "disable-login", util.LookupEnvOrBool("DISABLE_LOGIN", flagDisableLogin), "Disable authentication on the app. This is potentially dangerous.") + flag.BoolVar(&flagRemoteUser, "remote_user", util.LookupEnvOrBool("REMOTE_USER", flagRemoteUser), "Use HTTP header REMOTE_USER for auth. Commonly used with SSO and a proxy funcion.") flag.StringVar(&flagBindAddress, "bind-address", util.LookupEnvOrString("BIND_ADDRESS", flagBindAddress), "Address:Port to which the app will be bound.") flag.StringVar(&flagSmtpHostname, "smtp-hostname", util.LookupEnvOrString("SMTP_HOSTNAME", flagSmtpHostname), "SMTP Hostname") flag.IntVar(&flagSmtpPort, "smtp-port", util.LookupEnvOrInt("SMTP_PORT", flagSmtpPort), "SMTP Port") @@ -126,6 +128,7 @@ func init() { // update runtime config util.DisableLogin = flagDisableLogin + util.RemoteUser = flagRemoteUser util.BindAddress = flagBindAddress util.SmtpHostname = flagSmtpHostname util.SmtpPort = flagSmtpPort @@ -161,6 +164,7 @@ func init() { fmt.Println("Build Time\t:", buildTime) fmt.Println("Git Repo\t:", "https://github.com/ngoduykhanh/wireguard-ui") fmt.Println("Authentication\t:", !util.DisableLogin) + fmt.Println("Remote_user\t:", util.RemoteUser) fmt.Println("Bind address\t:", util.BindAddress) //fmt.Println("Sendgrid key\t:", util.SendgridApiKey) fmt.Println("Email from\t:", util.EmailFrom) diff --git a/util/config.go b/util/config.go index 4af6bd2..e05b81c 100644 --- a/util/config.go +++ b/util/config.go @@ -10,6 +10,7 @@ import ( // Runtime config var ( DisableLogin bool + RemoteUser bool BindAddress string SmtpHostname string SmtpPort int