Rename PERUSER => PER_USER
| @@ -65,7 +65,7 @@ const DEFAULT_WHITELIST = true; | |||
| 65 | const DEFAULT_ACCOUNTS = false; | 65 | const DEFAULT_ACCOUNTS = false; |
| 66 | const DEFAULT_CSRF_DISABLED = false; | 66 | const DEFAULT_CSRF_DISABLED = false; |
| 67 | const DEFAULT_BASIC_AUTH = false; | 67 | const DEFAULT_BASIC_AUTH = false; |
| 68 | const DEFAULT_PERUSER_BASIC_AUTH = false; | 68 | const DEFAULT_PER_USER_BASIC_AUTH = false; |
| 69 | 69 | ||
| 70 | const DEFAULT_ENABLE_IPV6 = false; | 70 | const DEFAULT_ENABLE_IPV6 = false; |
| 71 | const DEFAULT_ENABLE_IPV4 = true; | 71 | const DEFAULT_ENABLE_IPV4 = true; |
| @@ -185,7 +185,7 @@ const enableWhitelist = cliArguments.whitelist ?? getConfigValue('whitelistMode' | |||
| 185 | const dataRoot = cliArguments.dataRoot ?? getConfigValue('dataRoot', './data'); | 185 | const dataRoot = cliArguments.dataRoot ?? getConfigValue('dataRoot', './data'); |
| 186 | const disableCsrf = cliArguments.disableCsrf ?? getConfigValue('disableCsrfProtection', DEFAULT_CSRF_DISABLED); | 186 | const disableCsrf = cliArguments.disableCsrf ?? getConfigValue('disableCsrfProtection', DEFAULT_CSRF_DISABLED); |
| 187 | const basicAuthMode = cliArguments.basicAuthMode ?? getConfigValue('basicAuthMode', DEFAULT_BASIC_AUTH); | 187 | const basicAuthMode = cliArguments.basicAuthMode ?? getConfigValue('basicAuthMode', DEFAULT_BASIC_AUTH); |
| 188 | const PERUSER_BASIC_AUTH = getConfigValue('perUserBasicAuth', DEFAULT_PERUSER_BASIC_AUTH); | 188 | const perUserBasicAuth = getConfigValue('perUserBasicAuth', DEFAULT_PER_USER_BASIC_AUTH); |
| 189 | const enableAccounts = getConfigValue('enableUserAccounts', DEFAULT_ACCOUNTS); | 189 | const enableAccounts = getConfigValue('enableUserAccounts', DEFAULT_ACCOUNTS); |
| 190 | 190 | ||
| 191 | const uploadsPath = path.join(dataRoot, require('./src/constants').UPLOADS_DIRECTORY); | 191 | const uploadsPath = path.join(dataRoot, require('./src/constants').UPLOADS_DIRECTORY); |
| @@ -758,7 +758,7 @@ const postSetupTasks = async function (v6Failed, v4Failed) { | |||
| 758 | } | 758 | } |
| 759 | 759 | ||
| 760 | if (basicAuthMode) { | 760 | if (basicAuthMode) { |
| 761 | if (!PERUSER_BASIC_AUTH) { | 761 | if (!perUserBasicAuth) { |
| 762 | const basicAuthUser = getConfigValue('basicAuthUser', {}); | 762 | const basicAuthUser = getConfigValue('basicAuthUser', {}); |
| 763 | if (!basicAuthUser?.username || !basicAuthUser?.password) { | 763 | if (!basicAuthUser?.username || !basicAuthUser?.password) { |
| 764 | console.warn(color.yellow('Basic Authentication is enabled, but username or password is not set or empty!')); | 764 | console.warn(color.yellow('Basic Authentication is enabled, but username or password is not set or empty!')); |
| @@ -6,7 +6,7 @@ const { getAllUserHandles, toKey, getPasswordHash } = require('../users.js'); | |||
| 6 | const { getConfig, getConfigValue } = require('../util.js'); | 6 | const { getConfig, getConfigValue } = require('../util.js'); |
| 7 | const storage = require('node-persist'); | 7 | const storage = require('node-persist'); |
| 8 | 8 | ||
| 9 | const PERUSER_BASIC_AUTH = getConfigValue('perUserBasicAuth', false); | 9 | const PER_USER_BASIC_AUTH = getConfigValue('perUserBasicAuth', false); |
| 10 | 10 | ||
| 11 | const unauthorizedResponse = (res) => { | 11 | const unauthorizedResponse = (res) => { |
| 12 | res.set('WWW-Authenticate', 'Basic realm="SillyTavern", charset="UTF-8"'); | 12 | res.set('WWW-Authenticate', 'Basic realm="SillyTavern", charset="UTF-8"'); |
| @@ -31,9 +31,9 @@ const basicAuthMiddleware = async function (request, response, callback) { | |||
| 31 | .toString('utf8') | 31 | .toString('utf8') |
| 32 | .split(':'); | 32 | .split(':'); |
| 33 | 33 | ||
| 34 | if (! PERUSER_BASIC_AUTH && username === config.basicAuthUser.username && password === config.basicAuthUser.password) { | 34 | if (! PER_USER_BASIC_AUTH && username === config.basicAuthUser.username && password === config.basicAuthUser.password) { |
| 35 | return callback(); | 35 | return callback(); |
| 36 | } else if (PERUSER_BASIC_AUTH) { | 36 | } else if (PER_USER_BASIC_AUTH) { |
| 37 | const userHandles = await getAllUserHandles(); | 37 | const userHandles = await getAllUserHandles(); |
| 38 | for (const userHandle of userHandles) { | 38 | for (const userHandle of userHandles) { |
| 39 | if (username == userHandle) { | 39 | if (username == userHandle) { |
| @@ -20,7 +20,7 @@ const KEY_PREFIX = 'user:'; | |||
| 20 | const AVATAR_PREFIX = 'avatar:'; | 20 | const AVATAR_PREFIX = 'avatar:'; |
| 21 | const ENABLE_ACCOUNTS = getConfigValue('enableUserAccounts', false); | 21 | const ENABLE_ACCOUNTS = getConfigValue('enableUserAccounts', false); |
| 22 | const AUTHELIA_AUTH = getConfigValue('autheliaAuth', false); | 22 | const AUTHELIA_AUTH = getConfigValue('autheliaAuth', false); |
| 23 | const PERUSER_BASIC_AUTH = getConfigValue('perUserBasicAuth', false); | 23 | const PER_USER_BASIC_AUTH = getConfigValue('perUserBasicAuth', false); |
| 24 | const ANON_CSRF_SECRET = crypto.randomBytes(64).toString('base64'); | 24 | const ANON_CSRF_SECRET = crypto.randomBytes(64).toString('base64'); |
| 25 | 25 | ||
| 26 | /** | 26 | /** |
| @@ -588,7 +588,7 @@ async function tryAutoLogin(request) { | |||
| 588 | return true; | 588 | return true; |
| 589 | } | 589 | } |
| 590 | 590 | ||
| 591 | if (PERUSER_BASIC_AUTH && await basicUserLogin(request)) { | 591 | if (PER_USER_BASIC_AUTH && await basicUserLogin(request)) { |
| 592 | return true; | 592 | return true; |
| 593 | } | 593 | } |
| 594 | } | 594 | } |