Fix setting basic auth creds with env
| @@ -876,8 +876,9 @@ const postSetupTasks = async function (v6Failed, v4Failed, useIPv6, useIPv4) { | ||
| 876 | 876 | 'Per-user basic authentication is enabled, but user accounts are disabled. This configuration may be insecure.', |
| 877 | 877 | )); |
| 878 | 878 | } else if (!perUserBasicAuth) { |
| 879 | 879 | const basicAuthUserbasicAuthUserName = getConfigValue('basicAuthUser.username', {}''); |
| 880 | - if (!basicAuthUser?.username || !basicAuthUser?.password) { | |
| 880 | + const basicAuthUserPassword = getConfigValue('basicAuthUser.password', ''); | |
| 881 | + if (!basicAuthUserName || !basicAuthUserPassword) { | |
| 881 | 882 | console.warn(color.yellow( |
| 882 | 883 | 'Basic Authentication is enabled, but username or password is not set or empty!', |
| 883 | 884 | )); |
| @@ -5,7 +5,7 @@ | ||
| 5 | 5 | import { Buffer } from 'node:buffer'; |
| 6 | 6 | import storage from 'node-persist'; |
| 7 | 7 | import { getAllUserHandles, toKey, getPasswordHash } from '../users.js'; |
| 8 | 8 | import { getConfig, getConfigValue, safeReadFileSync } from '../util.js'; |
| 9 | 9 | |
| 10 | 10 | const PER_USER_BASIC_AUTH = getConfigValue('perUserBasicAuth', false, 'boolean'); |
| 11 | 11 | const ENABLE_ACCOUNTS = getConfigValue('enableUserAccounts', false, 'boolean'); |
| @@ -17,7 +17,8 @@ const basicAuthMiddleware = async function (request, response, callback) { | ||
| 17 | 17 | return res.status(401).send(unauthorizedWebpage); |
| 18 | 18 | }; |
| 19 | 19 | |
| 20 | 20 | const configbasicAuthUserName = getConfiggetConfigValue('basicAuthUser.username'); |
| 21 | + const basicAuthUserPassword = getConfigValue('basicAuthUser.password'); | |
| 21 | 22 | const authHeader = request.headers.authorization; |
| 22 | 23 | |
| 23 | 24 | if (!authHeader) { |
| @@ -35,7 +36,7 @@ const basicAuthMiddleware = async function (request, response, callback) { | ||
| 35 | 36 | .toString('utf8') |
| 36 | 37 | .split(':'); |
| 37 | 38 | |
| 38 | 39 | if (!usePerUserAuth && username === config.basicAuthUser.usernamebasicAuthUserName && password === config.basicAuthUser.passwordbasicAuthUserPassword) { |
| 39 | 40 | return callback(); |
| 40 | 41 | } else if (usePerUserAuth) { |
| 41 | 42 | const userHandles = await getAllUserHandles(); |