1
0
mirror of https://github.com/redis/go-redis.git synced 2025-07-31 05:04:23 +03:00

Add AuthACL

This commit is contained in:
filipe oliveira
2020-05-21 08:59:20 +03:00
committed by Vladimir Mihailenco
parent 64bb0b7f3a
commit cf6cf7f450
7 changed files with 70 additions and 2 deletions

View File

@ -40,8 +40,13 @@ type Options struct {
// Hook that is called when new connection is established.
OnConnect func(*Conn) error
// Use the specified Username to authenticate the current connection with one of the connections defined in the ACL
// list when connecting to a Redis 6.0 instance, or greater, that is using the Redis ACL system.
Username string
// Optional password. Must match the password specified in the
// requirepass server configuration option.
// requirepass server configuration option (if connecting to a Redis 5.0 instance, or lower),
// or the User Password when connecting to a Redis 6.0 instance, or greater, that is using the Redis ACL system.
Password string
// Database to be selected after connecting to the server.
DB int
@ -187,6 +192,7 @@ func ParseURL(redisURL string) (*Options, error) {
}
if u.User != nil {
o.Username = u.User.Username()
if p, ok := u.User.Password(); ok {
o.Password = p
}