mirror of
https://github.com/minio/minio.git
synced 2025-02-02 17:35:58 -05:00
feat: add user specific redis auth (#19285)
This commit is contained in:
parent
7213bd7131
commit
d7fb6fddf6
@ -674,6 +674,12 @@ var (
|
|||||||
Sensitive: true,
|
Sensitive: true,
|
||||||
Secret: true,
|
Secret: true,
|
||||||
},
|
},
|
||||||
|
config.HelpKV{
|
||||||
|
Key: target.RedisUser,
|
||||||
|
Description: "Redis server user for the auth",
|
||||||
|
Optional: true,
|
||||||
|
Type: "string",
|
||||||
|
},
|
||||||
config.HelpKV{
|
config.HelpKV{
|
||||||
Key: target.RedisQueueDir,
|
Key: target.RedisQueueDir,
|
||||||
Description: queueDirComment,
|
Description: queueDirComment,
|
||||||
|
@ -250,6 +250,10 @@ func SetNotifyRedis(s config.Config, redisName string, cfg target.RedisArgs) err
|
|||||||
Key: target.RedisPassword,
|
Key: target.RedisPassword,
|
||||||
Value: cfg.Password,
|
Value: cfg.Password,
|
||||||
},
|
},
|
||||||
|
config.KV{
|
||||||
|
Key: target.RedisUser,
|
||||||
|
Value: cfg.User,
|
||||||
|
},
|
||||||
config.KV{
|
config.KV{
|
||||||
Key: target.RedisKey,
|
Key: target.RedisKey,
|
||||||
Value: cfg.Key,
|
Value: cfg.Key,
|
||||||
|
@ -1282,6 +1282,10 @@ var (
|
|||||||
Key: target.RedisPassword,
|
Key: target.RedisPassword,
|
||||||
Value: "",
|
Value: "",
|
||||||
},
|
},
|
||||||
|
config.KV{
|
||||||
|
Key: target.RedisUser,
|
||||||
|
Value: "",
|
||||||
|
},
|
||||||
config.KV{
|
config.KV{
|
||||||
Key: target.RedisQueueDir,
|
Key: target.RedisQueueDir,
|
||||||
Value: "",
|
Value: "",
|
||||||
@ -1334,6 +1338,10 @@ func GetNotifyRedis(redisKVS map[string]config.KVS) (map[string]target.RedisArgs
|
|||||||
if k != config.Default {
|
if k != config.Default {
|
||||||
passwordEnv = passwordEnv + config.Default + k
|
passwordEnv = passwordEnv + config.Default + k
|
||||||
}
|
}
|
||||||
|
userEnv := target.EnvRedisUser
|
||||||
|
if k != config.Default {
|
||||||
|
userEnv = userEnv + config.Default + k
|
||||||
|
}
|
||||||
keyEnv := target.EnvRedisKey
|
keyEnv := target.EnvRedisKey
|
||||||
if k != config.Default {
|
if k != config.Default {
|
||||||
keyEnv = keyEnv + config.Default + k
|
keyEnv = keyEnv + config.Default + k
|
||||||
@ -1347,6 +1355,7 @@ func GetNotifyRedis(redisKVS map[string]config.KVS) (map[string]target.RedisArgs
|
|||||||
Format: env.Get(formatEnv, kv.Get(target.RedisFormat)),
|
Format: env.Get(formatEnv, kv.Get(target.RedisFormat)),
|
||||||
Addr: *addr,
|
Addr: *addr,
|
||||||
Password: env.Get(passwordEnv, kv.Get(target.RedisPassword)),
|
Password: env.Get(passwordEnv, kv.Get(target.RedisPassword)),
|
||||||
|
User: env.Get(userEnv, kv.Get(target.RedisUser)),
|
||||||
Key: env.Get(keyEnv, kv.Get(target.RedisKey)),
|
Key: env.Get(keyEnv, kv.Get(target.RedisKey)),
|
||||||
QueueDir: env.Get(queueDirEnv, kv.Get(target.RedisQueueDir)),
|
QueueDir: env.Get(queueDirEnv, kv.Get(target.RedisQueueDir)),
|
||||||
QueueLimit: uint64(queueLimit),
|
QueueLimit: uint64(queueLimit),
|
||||||
|
@ -41,6 +41,7 @@ const (
|
|||||||
RedisFormat = "format"
|
RedisFormat = "format"
|
||||||
RedisAddress = "address"
|
RedisAddress = "address"
|
||||||
RedisPassword = "password"
|
RedisPassword = "password"
|
||||||
|
RedisUser = "user"
|
||||||
RedisKey = "key"
|
RedisKey = "key"
|
||||||
RedisQueueDir = "queue_dir"
|
RedisQueueDir = "queue_dir"
|
||||||
RedisQueueLimit = "queue_limit"
|
RedisQueueLimit = "queue_limit"
|
||||||
@ -49,6 +50,7 @@ const (
|
|||||||
EnvRedisFormat = "MINIO_NOTIFY_REDIS_FORMAT"
|
EnvRedisFormat = "MINIO_NOTIFY_REDIS_FORMAT"
|
||||||
EnvRedisAddress = "MINIO_NOTIFY_REDIS_ADDRESS"
|
EnvRedisAddress = "MINIO_NOTIFY_REDIS_ADDRESS"
|
||||||
EnvRedisPassword = "MINIO_NOTIFY_REDIS_PASSWORD"
|
EnvRedisPassword = "MINIO_NOTIFY_REDIS_PASSWORD"
|
||||||
|
EnvRedisUser = "MINIO_NOTIFY_REDIS_USER"
|
||||||
EnvRedisKey = "MINIO_NOTIFY_REDIS_KEY"
|
EnvRedisKey = "MINIO_NOTIFY_REDIS_KEY"
|
||||||
EnvRedisQueueDir = "MINIO_NOTIFY_REDIS_QUEUE_DIR"
|
EnvRedisQueueDir = "MINIO_NOTIFY_REDIS_QUEUE_DIR"
|
||||||
EnvRedisQueueLimit = "MINIO_NOTIFY_REDIS_QUEUE_LIMIT"
|
EnvRedisQueueLimit = "MINIO_NOTIFY_REDIS_QUEUE_LIMIT"
|
||||||
@ -60,6 +62,7 @@ type RedisArgs struct {
|
|||||||
Format string `json:"format"`
|
Format string `json:"format"`
|
||||||
Addr xnet.Host `json:"address"`
|
Addr xnet.Host `json:"address"`
|
||||||
Password string `json:"password"`
|
Password string `json:"password"`
|
||||||
|
User string `json:"user"`
|
||||||
Key string `json:"key"`
|
Key string `json:"key"`
|
||||||
QueueDir string `json:"queueDir"`
|
QueueDir string `json:"queueDir"`
|
||||||
QueueLimit uint64 `json:"queueLimit"`
|
QueueLimit uint64 `json:"queueLimit"`
|
||||||
@ -334,9 +337,16 @@ func NewRedisTarget(id string, args RedisArgs, loggerOnce logger.LogOnce) (*Redi
|
|||||||
}
|
}
|
||||||
|
|
||||||
if args.Password != "" {
|
if args.Password != "" {
|
||||||
if _, err = conn.Do("AUTH", args.Password); err != nil {
|
if args.User != "" {
|
||||||
conn.Close()
|
if _, err = conn.Do("AUTH", args.User, args.Password); err != nil {
|
||||||
return nil, err
|
conn.Close()
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if _, err = conn.Do("AUTH", args.Password); err != nil {
|
||||||
|
conn.Close()
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user