@@ -234,9 +234,9 @@ private void hello(ContextInternal ctx, RedisConnection connection, RedisURI red
234234 Request hello = Request .cmd (Command .HELLO ).arg (RESPParser .VERSION );
235235
236236 String password = redisURI .password () != null ? redisURI .password () : options .getPassword ();
237+ String user = redisURI .user ();
237238
238239 if (password != null ) {
239- String user = redisURI .user ();
240240 // will perform auth at hello level
241241 hello
242242 .arg ("AUTH" )
@@ -261,7 +261,7 @@ private void hello(ContextInternal ctx, RedisConnection connection, RedisURI red
261261 if (err instanceof ErrorType ) {
262262 final ErrorType redisErr = (ErrorType ) err ;
263263 if (redisErr .is ("NOAUTH" )) {
264- authenticate (ctx , connection , password , handler );
264+ authenticate (ctx , connection , user , password , handler );
265265 return ;
266266 }
267267 if (redisErr .is ("ERR" )) {
@@ -296,7 +296,7 @@ private void ping(ContextInternal ctx, RedisConnection connection, Handler<Async
296296 if (((ErrorType ) err ).is ("NOAUTH" )) {
297297 // old authentication required
298298 String password = redisURI .password () != null ? redisURI .password () : options .getPassword ();
299- authenticate (ctx , connection , password , handler );
299+ authenticate (ctx , connection , redisURI . user (), password , handler );
300300 return ;
301301 }
302302 }
@@ -306,13 +306,21 @@ private void ping(ContextInternal ctx, RedisConnection connection, Handler<Async
306306 });
307307 }
308308
309- private void authenticate (ContextInternal ctx , RedisConnection connection , String password , Handler <AsyncResult <Void >> handler ) {
309+ private void authenticate (ContextInternal ctx , RedisConnection connection , String user , String password , Handler <AsyncResult <Void >> handler ) {
310310 if (password == null ) {
311311 ctx .execute (ctx .succeededFuture (), handler );
312312 return ;
313313 }
314+
314315 // perform authentication
315- connection .send (Request .cmd (Command .AUTH ).arg (password ), auth -> {
316+ final Request cmd = Request .cmd (Command .AUTH );
317+ // when working with ACLs (Redis >= 6) we may use usernames
318+ if (user != null ) {
319+ cmd .arg (user );
320+ }
321+ cmd .arg (password );
322+
323+ connection .send (cmd , auth -> {
316324 if (auth .failed ()) {
317325 ctx .execute (ctx .failedFuture (auth .cause ()), handler );
318326 } else {
0 commit comments