Integrate the relay authentication

This commit is contained in:
Zoltan Papp
2024-07-05 16:12:30 +02:00
parent 8845e8fbc7
commit 836072098b
30 changed files with 3055 additions and 1594 deletions
+8 -2
View File
@@ -24,6 +24,7 @@ var (
letsencryptDomains []string
tlsCertFile string
tlsKeyFile string
authSecret string
rootCmd = &cobra.Command{
Use: "relay",
@@ -41,7 +42,7 @@ func init() {
rootCmd.PersistentFlags().StringArrayVarP(&letsencryptDomains, "letsencrypt-domains", "a", nil, "list of domains to issue Let's Encrypt certificate for. Enables TLS using Let's Encrypt. Will fetch and renew certificate, and run the server with TLS")
rootCmd.PersistentFlags().StringVarP(&tlsCertFile, "tls-cert-file", "c", "", "")
rootCmd.PersistentFlags().StringVarP(&tlsKeyFile, "tls-key-file", "k", "", "")
rootCmd.PersistentFlags().StringVarP(&authSecret, "auth-secret", "s", "", "log level")
}
func waitForExitSignal() {
@@ -56,6 +57,11 @@ func execute(cmd *cobra.Command, args []string) {
os.Exit(1)
}
if authSecret == "" {
log.Errorf("auth secret is required")
os.Exit(1)
}
srvListenerCfg := server.ListenerConfig{
Address: listenAddress,
}
@@ -76,7 +82,7 @@ func execute(cmd *cobra.Command, args []string) {
}
tlsSupport := srvListenerCfg.TLSConfig != nil
srv := server.NewServer(exposedAddress, tlsSupport)
srv := server.NewServer(exposedAddress, tlsSupport, authSecret)
log.Infof("server will be available on: %s", srv.InstanceURL())
err := srv.Listen(srvListenerCfg)
if err != nil {