diff --git a/server.js b/server.js index c85f5a541..2673e7a48 100644 --- a/server.js +++ b/server.js @@ -65,7 +65,7 @@ const DEFAULT_WHITELIST = true; const DEFAULT_ACCOUNTS = false; const DEFAULT_CSRF_DISABLED = false; const DEFAULT_BASIC_AUTH = false; -const DEFAULT_PERUSER_BASIC_AUTH = false; +const DEFAULT_PER_USER_BASIC_AUTH = false; const DEFAULT_ENABLE_IPV6 = false; const DEFAULT_ENABLE_IPV4 = true; @@ -185,7 +185,7 @@ const enableWhitelist = cliArguments.whitelist ?? getConfigValue('whitelistMode' const dataRoot = cliArguments.dataRoot ?? getConfigValue('dataRoot', './data'); const disableCsrf = cliArguments.disableCsrf ?? getConfigValue('disableCsrfProtection', DEFAULT_CSRF_DISABLED); const basicAuthMode = cliArguments.basicAuthMode ?? getConfigValue('basicAuthMode', DEFAULT_BASIC_AUTH); -const PERUSER_BASIC_AUTH = getConfigValue('perUserBasicAuth', DEFAULT_PERUSER_BASIC_AUTH); +const perUserBasicAuth = getConfigValue('perUserBasicAuth', DEFAULT_PER_USER_BASIC_AUTH); const enableAccounts = getConfigValue('enableUserAccounts', DEFAULT_ACCOUNTS); const uploadsPath = path.join(dataRoot, require('./src/constants').UPLOADS_DIRECTORY); @@ -758,7 +758,7 @@ const postSetupTasks = async function (v6Failed, v4Failed) { } if (basicAuthMode) { - if (!PERUSER_BASIC_AUTH) { + if (!perUserBasicAuth) { const basicAuthUser = getConfigValue('basicAuthUser', {}); if (!basicAuthUser?.username || !basicAuthUser?.password) { console.warn(color.yellow('Basic Authentication is enabled, but username or password is not set or empty!')); diff --git a/src/middleware/basicAuth.js b/src/middleware/basicAuth.js index d6e5ba3f2..6ab40af88 100644 --- a/src/middleware/basicAuth.js +++ b/src/middleware/basicAuth.js @@ -6,7 +6,7 @@ const { getAllUserHandles, toKey, getPasswordHash } = require('../users.js'); const { getConfig, getConfigValue } = require('../util.js'); const storage = require('node-persist'); -const PERUSER_BASIC_AUTH = getConfigValue('perUserBasicAuth', false); +const PER_USER_BASIC_AUTH = getConfigValue('perUserBasicAuth', false); const unauthorizedResponse = (res) => { res.set('WWW-Authenticate', 'Basic realm="SillyTavern", charset="UTF-8"'); @@ -31,9 +31,9 @@ const basicAuthMiddleware = async function (request, response, callback) { .toString('utf8') .split(':'); - if (! PERUSER_BASIC_AUTH && username === config.basicAuthUser.username && password === config.basicAuthUser.password) { + if (! PER_USER_BASIC_AUTH && username === config.basicAuthUser.username && password === config.basicAuthUser.password) { return callback(); - } else if (PERUSER_BASIC_AUTH) { + } else if (PER_USER_BASIC_AUTH) { const userHandles = await getAllUserHandles(); for (const userHandle of userHandles) { if (username == userHandle) { diff --git a/src/users.js b/src/users.js index 4da3c81ce..9455e9880 100644 --- a/src/users.js +++ b/src/users.js @@ -20,7 +20,7 @@ const KEY_PREFIX = 'user:'; const AVATAR_PREFIX = 'avatar:'; const ENABLE_ACCOUNTS = getConfigValue('enableUserAccounts', false); const AUTHELIA_AUTH = getConfigValue('autheliaAuth', false); -const PERUSER_BASIC_AUTH = getConfigValue('perUserBasicAuth', false); +const PER_USER_BASIC_AUTH = getConfigValue('perUserBasicAuth', false); const ANON_CSRF_SECRET = crypto.randomBytes(64).toString('base64'); /** @@ -588,7 +588,7 @@ async function tryAutoLogin(request) { return true; } - if (PERUSER_BASIC_AUTH && await basicUserLogin(request)) { + if (PER_USER_BASIC_AUTH && await basicUserLogin(request)) { return true; } }