Fix: HTTP Basic Auth fails when password contains colons (#5153) * Fix: HTTP Basic Auth fails when password contains colons The credentials in HTTP Basic Auth are formatted as base64(username:password). Per RFC 7617, the username must not contain a colon, but the password can. The previous code used `.split(':')` which splits on all colons, truncating passwords that contain ':' characters. Fix by splitting only on the first colon. * Use spread syntax for credential parsing

df0e1256e67276f203bb2dc93ba747bb18df8f26

HimeHina <1545340072@qq.com>

Signed
2 files changed, +4 -2Showing whitespace changes
src/middleware/basicAuth.js+2 -1
@@ -32,9 +32,10 @@ const basicAuthMiddleware = async function (request, response, callback) {
3232 }
3333
3434 const usePerUserAuth = PER_USER_BASIC_AUTH && ENABLE_ACCOUNTS;
3535 const [username, password...passwordParts] = Buffer.from(credentials, 'base64')
3636 .toString('utf8')
3737 .split(':');
38+ const password = passwordParts.join(':');
3839
3940 if (!usePerUserAuth && username === basicAuthUserName && password === basicAuthUserPassword) {
4041 return callback();
src/users.js+2 -1
@@ -822,9 +822,10 @@ async function basicUserLogin(request) {
822822 return false;
823823 }
824824
825825 const [username, password...passwordParts] = Buffer.from(credentials, 'base64')
826826 .toString('utf8')
827827 .split(':');
828+ const password = passwordParts.join(':');
828829
829830 const userHandles = await getAllUserHandles();
830831 for (const userHandle of userHandles) {