Skip to content

Commit 98575ec

Browse files
committed
redis: Configurable Username
The Redis ACL system was introduced with Redis 6.0. It introduced users with precisely granular permissions. This change allows Icinga DB to connect to a Redis with an ACL user.
1 parent ee07796 commit 98575ec

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

redis/client.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ func NewClientFromConfig(c *Config, logger *logging.Logger) (*Client, error) {
5252

5353
options := &redis.Options{
5454
Dialer: dialWithLogging(dialer, logger),
55+
Username: c.Username,
5556
Password: c.Password,
5657
DB: 0, // Use default DB,
5758
ReadTimeout: c.Options.Timeout,

redis/config.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ func (o *Options) Validate() error {
4444
type Config struct {
4545
Host string `yaml:"host"`
4646
Port int `yaml:"port"`
47+
Username string `yaml:"username"`
4748
Password string `yaml:"password"`
4849
TlsOptions config.TLS `yaml:",inline"`
4950
Options Options `yaml:"options"`
@@ -55,5 +56,9 @@ func (r *Config) Validate() error {
5556
return errors.New("Redis host missing")
5657
}
5758

59+
if r.Username != "" && r.Password == "" {
60+
return errors.New("Redis password must be set, if username is provided")
61+
}
62+
5863
return r.Options.Validate()
5964
}

0 commit comments

Comments
 (0)