Repository navigation
[ISSUE #11446] fix(tools): stop trimming the ACL password in mqadmin create/updateUser - #11447
iloveeyjafjalla wants to merge 1 commit into
Conversation
The secret is a payload, not a name: the broker stores the secret verbatim and derives the client's credentials from it, so a passphrase with leading or trailing whitespace is legal - and pasted secrets routinely carry one. CreateUserSubCommand and UpdateUserSubCommand ran it through StringUtils.trim before the call, which stores a secret the operator never typed: every client that presents the real secret is then rejected with no hint about the difference. The sendMessage body carried the same shape until apache#11414. Drop the trim on the password only - the username, user type and address keep theirs - and give both commands the createAdminExt seam CopyUsersSubCommand already exposes, so the behaviour is pinned by a test.
RockteMQ-AI
left a comment
There was a problem hiding this comment.
Review by github-manager-bot
Summary
Fixes a bug where mqadmin createUser and updateUser silently trimmed the ACL password before storing it, causing authentication failures when the actual secret contained leading/trailing whitespace. The broker stores the secret verbatim, so the CLI must not alter it.
Findings
-
[Info]
CreateUserSubCommand.java:78/UpdateUserSubCommand.java:83— ThecreateAdminExt(RPCHook)seam is package-private, which is appropriate for same-package test access. This is consistent with the existing pattern inCopyUsersSubCommand. ✓ -
[Info]
CreateUserSubCommand.java:80— The comment clearly explains the rationale for removing the trim. Good documentation of the intent. -
[Info] Tests — Both test classes use
ArgumentCaptorto verify the exact password value reaching the admin API, which directly validates the fix. The test data (" s3cret "and" p@ss word ") covers both leading/trailing spaces and internal spaces.
Observations
-
The test only exercises the
-b(direct broker) code path. The-c(cluster) path shares the same password handling (trim removal happens before the branch), so coverage is adequate for this fix. -
Other fields (
username,userType,userStatus,address) retain theirStringUtils.trim()calls, which is correct — those are identifiers, not secrets. -
Minor backward note: Users who previously created accounts with space-padded passwords via the CLI (where spaces were silently stripped) will need to re-create those users with the correct password. This is the intended behavior change and is documented in the PR body.
Verdict
Clean, focused fix with good test coverage. The createAdminExt seam improves testability without changing production behavior beyond the intended bug fix.
Automated review by github-manager-bot
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #11447 +/- ##
=============================================
- Coverage 49.76% 49.75% -0.02%
+ Complexity 14377 14369 -8
=============================================
Files 1390 1390
Lines 103262 103264 +2
Branches 13504 13504
=============================================
- Hits 51392 51380 -12
+ Misses 45681 45679 -2
- Partials 6189 6205 +16 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Which Issue(s) This PR Fixes
Fixes #11446
Problem
CreateUserSubCommandandUpdateUserSubCommandtrimmed the ACL password before calling the admin API:The broker stores the secret verbatim (
AuthMigratorcopiesaccessConfig.getSecretKey();User.of(accessKey, secretKey, ...)in the authentication manager builds the credential from it), so a passphrase with leading or trailing whitespace is legal and is what a client must present. The CLI stored the trimmed value instead: the real secret is then rejected as unauthenticated, nothing in the CLI output or the broker log points at the difference, and the admin API stores the same secret verbatim, so the CLI and the API disagree about the same user.sendMessagecarried the same shape for the message body until #11414.Change
createAdminExt(RPCHook)seamCopyUsersSubCommandalready exposes, so the argument that reaches the admin API can be captured in a test.Verification
New tests capture the password the mocked
DefaultMQAdminExtreceives. With the trim in place:After the change, in the
toolsmodule with JDK 8 (mvn -B -ntp -pl tools test -Dtest='CreateUserSubCommandTest,UpdateUserSubCommandTest,CopyUsersSubCommandTest' -DfailIfNoTests=false -Djacoco.skip=true):The unit test is the verification for this one; it exercises the command class, not a live broker. The change was prepared with AI assistance and reviewed, tested and verified by me.