zjncs opened a new pull request, #4360:
URL: https://github.com/apache/hertzbeat/pull/4360

   ## What's changed
   
   The Redis collector passed the configured `username` to 
`RedisURI.Builder.withClientName`, which only sets the informational `CLIENT 
SETNAME` sent after connecting and plays no role in authentication (lettuce 
6.8.2 resolves the username exclusively from `RedisURI` credentials).
   
   As a result, with a Redis 6+ ACL user (e.g. `ACL SETUSER monitor on 
>secretpass ~* +@read`) and a monitor configured with `username=monitor`, 
`password=secretpass` (both exposed by `app-redis.yml`), lettuce authenticated 
as the `default` user and the collection failed with `WRONGPASS`/`NOAUTH` — the 
username setting never worked.
   
   Fix: use `withAuthentication(username, password)` so the username and 
password are applied as credentials. An ACL user without a password 
authenticates with an empty one (`AUTH <username> ""`); password-only 
configuration keeps the previous `withPassword` behavior.
   
   ## Checklist
   
   - [x] I have read the [Contributing Guidelines](CONTRIBUTING.md).
   - [x] I have added unit tests for the change (`RedisCommonCollectImplTest` — 
the module previously had no Redis collector tests).
   - [x] All tests pass locally (`mvn -pl 
hertzbeat-collector/hertzbeat-collector-basic -am test`: 273 tests, 0 failures).
   
   ---
   
   **Verification**
   
   - fail-before: `redisUriShouldUseUsernameForAuthentication` fails on master 
— `expected: <monitor> but was: <null>` (`RedisURI.getUsername()` is null 
because the username went to `CLIENT NAME`)
   - pass-after: both new tests pass; full module suite passes (273 tests, 0 
failures, 4 pre-existing skips)
   - Verified against lettuce-core 6.8.2.RELEASE (the version resolved by the 
build): `withClientName` sets only the client name, `withAuthentication(String, 
char[])` sets the credentials used for `AUTH`
   
   **AI assistance disclosure**: the bug analysis, fix and tests in this PR 
were prepared with the help of an AI coding agent, and were verified locally by 
the author as described above.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to