diff --git a/cmd/wonderwall/main.go b/cmd/wonderwall/main.go index 432b642..40646f4 100644 --- a/cmd/wonderwall/main.go +++ b/cmd/wonderwall/main.go @@ -119,14 +119,18 @@ func setupSessionStore(cfg *config.Config) session.Store { } func configureRedisClient(cfg *config.Config) (*redis.Client, error) { - redisClient := redis.NewClient(&redis.Options{ - Network: "tcp", - Addr: cfg.Redis.Address, - Username: cfg.Redis.Username, - Password: cfg.Redis.Password, - MaxRetries: 10, - TLSConfig: &tls.Config{}, - }) + opts := &redis.Options{ + Network: "tcp", + Addr: cfg.Redis.Address, + Username: cfg.Redis.Username, + Password: cfg.Redis.Password, + } + + if cfg.Redis.TLS { + opts.TLSConfig = &tls.Config{} + } + + redisClient := redis.NewClient(opts) return redisClient, nil } diff --git a/pkg/config/config.go b/pkg/config/config.go index ef78f97..39f3284 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -28,6 +28,7 @@ type Redis struct { Address string `json:"address"` Username string `json:"username"` Password string `json:"password"` + TLS bool `json:"tls"` } type IDPorten struct { @@ -63,6 +64,7 @@ const ( RedisAddress = "redis.address" RedisUsername = "redis.username" RedisPassword = "redis.password" + RedisTLS = "redis.tls" Ingress = "ingress" ErrorRedirectURI = "error-redirect-uri" AutoLogin = "auto-login" @@ -99,6 +101,7 @@ func Initialize() *Config { flag.String(RedisAddress, "", "Address of Redis. An empty value will use in-memory session storage.") flag.String(RedisUsername, "", "Username for Redis.") flag.String(RedisPassword, "", "Password for Redis.") + flag.Bool(RedisTLS, true, "Whether or not to use TLS for connecting to Redis.") flag.String(Ingress, "/", "Ingress used to access the main application.") flag.String(ErrorRedirectURI, "", "URI to redirect user to on errors for custom error handling.") flag.Bool(AutoLogin, false, "Automatically redirect user to login if the user does not have a valid session for all proxied downstream requests.")