mirror of
https://github.com/distribution/distribution.git
synced 2025-09-15 14:48:31 +00:00
feat: added support for redis username configuration
Redis introduced an Access Control List (ACL) mechanism since version 6.0. This commit implements the necessary changes to support configuring the username for Redis. Users can now define a specific username to authenticate with Redis and enhance security through the ACL feature. Signed-off-by: chlins <chenyuzh@vmware.com>
This commit is contained in:
@@ -546,8 +546,16 @@ func (app *App) configureRedis(configuration *configuration.Configuration) {
|
||||
}
|
||||
|
||||
// authorize the connection
|
||||
authArgs := make([]interface{}, 0, 2)
|
||||
if configuration.Redis.Username != "" {
|
||||
authArgs = append(authArgs, configuration.Redis.Username)
|
||||
}
|
||||
if configuration.Redis.Password != "" {
|
||||
if _, err = conn.Do("AUTH", configuration.Redis.Password); err != nil {
|
||||
authArgs = append(authArgs, configuration.Redis.Password)
|
||||
}
|
||||
|
||||
if len(authArgs) > 0 {
|
||||
if _, err = conn.Do("AUTH", authArgs...); err != nil {
|
||||
defer conn.Close()
|
||||
done(err)
|
||||
return nil, err
|
||||
|
Reference in New Issue
Block a user