File tree Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ Yii Framework 2 redis extension Change Log
4
4
2.0.16 under development
5
5
------------------------
6
6
7
- - no changes in this release.
7
+ - Enh # 223 : Add ` Connection::$username ` for using username for authentication (samdark, rvkulikov)
8
8
9
9
10
10
2.0.15 May 05, 2021
Original file line number Diff line number Diff line change @@ -276,6 +276,14 @@ class Connection extends Component
276
276
* @since 2.0.1
277
277
*/
278
278
public $ unixSocket ;
279
+ /**
280
+ * @var string|null username for establishing DB connection. Defaults to `null` meaning AUTH command will be performed without username.
281
+ * Username was introduced in Redis 6.
282
+ * @link https://redis.io/commands/auth
283
+ * @link https://redis.io/topics/acl
284
+ * @since 2.0.16
285
+ */
286
+ public $ username ;
279
287
/**
280
288
* @var string the password for establishing DB connection. Defaults to null meaning no AUTH command is sent.
281
289
* See https://redis.io/commands/auth
@@ -638,7 +646,7 @@ public function open()
638
646
stream_socket_enable_crypto ($ socket , true , STREAM_CRYPTO_METHOD_TLS_CLIENT );
639
647
}
640
648
if ($ this ->password !== null ) {
641
- $ this ->executeCommand ('AUTH ' , [$ this ->password ]);
649
+ $ this ->executeCommand ('AUTH ' , array_filter ( [$ this ->username , $ this -> password ]) );
642
650
}
643
651
if ($ this ->database !== null ) {
644
652
$ this ->executeCommand ('SELECT ' , [$ this ->database ]);
You can’t perform that action at this time.
0 commit comments