mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-02-04 13:17:36 +01:00
Rename PERUSER => PER_USER
This commit is contained in:
parent
5765ea8500
commit
b9375ed7ea
@ -65,7 +65,7 @@ const DEFAULT_WHITELIST = true;
|
|||||||
const DEFAULT_ACCOUNTS = false;
|
const DEFAULT_ACCOUNTS = false;
|
||||||
const DEFAULT_CSRF_DISABLED = false;
|
const DEFAULT_CSRF_DISABLED = false;
|
||||||
const DEFAULT_BASIC_AUTH = 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_IPV6 = false;
|
||||||
const DEFAULT_ENABLE_IPV4 = true;
|
const DEFAULT_ENABLE_IPV4 = true;
|
||||||
@ -185,7 +185,7 @@ const enableWhitelist = cliArguments.whitelist ?? getConfigValue('whitelistMode'
|
|||||||
const dataRoot = cliArguments.dataRoot ?? getConfigValue('dataRoot', './data');
|
const dataRoot = cliArguments.dataRoot ?? getConfigValue('dataRoot', './data');
|
||||||
const disableCsrf = cliArguments.disableCsrf ?? getConfigValue('disableCsrfProtection', DEFAULT_CSRF_DISABLED);
|
const disableCsrf = cliArguments.disableCsrf ?? getConfigValue('disableCsrfProtection', DEFAULT_CSRF_DISABLED);
|
||||||
const basicAuthMode = cliArguments.basicAuthMode ?? getConfigValue('basicAuthMode', DEFAULT_BASIC_AUTH);
|
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 enableAccounts = getConfigValue('enableUserAccounts', DEFAULT_ACCOUNTS);
|
||||||
|
|
||||||
const uploadsPath = path.join(dataRoot, require('./src/constants').UPLOADS_DIRECTORY);
|
const uploadsPath = path.join(dataRoot, require('./src/constants').UPLOADS_DIRECTORY);
|
||||||
@ -758,7 +758,7 @@ const postSetupTasks = async function (v6Failed, v4Failed) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (basicAuthMode) {
|
if (basicAuthMode) {
|
||||||
if (!PERUSER_BASIC_AUTH) {
|
if (!perUserBasicAuth) {
|
||||||
const basicAuthUser = getConfigValue('basicAuthUser', {});
|
const basicAuthUser = getConfigValue('basicAuthUser', {});
|
||||||
if (!basicAuthUser?.username || !basicAuthUser?.password) {
|
if (!basicAuthUser?.username || !basicAuthUser?.password) {
|
||||||
console.warn(color.yellow('Basic Authentication is enabled, but username or password is not set or empty!'));
|
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');
|
|||||||
const { getConfig, getConfigValue } = require('../util.js');
|
const { getConfig, getConfigValue } = require('../util.js');
|
||||||
const storage = require('node-persist');
|
const storage = require('node-persist');
|
||||||
|
|
||||||
const PERUSER_BASIC_AUTH = getConfigValue('perUserBasicAuth', false);
|
const PER_USER_BASIC_AUTH = getConfigValue('perUserBasicAuth', false);
|
||||||
|
|
||||||
const unauthorizedResponse = (res) => {
|
const unauthorizedResponse = (res) => {
|
||||||
res.set('WWW-Authenticate', 'Basic realm="SillyTavern", charset="UTF-8"');
|
res.set('WWW-Authenticate', 'Basic realm="SillyTavern", charset="UTF-8"');
|
||||||
@ -31,9 +31,9 @@ const basicAuthMiddleware = async function (request, response, callback) {
|
|||||||
.toString('utf8')
|
.toString('utf8')
|
||||||
.split(':');
|
.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();
|
return callback();
|
||||||
} else if (PERUSER_BASIC_AUTH) {
|
} else if (PER_USER_BASIC_AUTH) {
|
||||||
const userHandles = await getAllUserHandles();
|
const userHandles = await getAllUserHandles();
|
||||||
for (const userHandle of userHandles) {
|
for (const userHandle of userHandles) {
|
||||||
if (username == userHandle) {
|
if (username == userHandle) {
|
||||||
|
@ -20,7 +20,7 @@ const KEY_PREFIX = 'user:';
|
|||||||
const AVATAR_PREFIX = 'avatar:';
|
const AVATAR_PREFIX = 'avatar:';
|
||||||
const ENABLE_ACCOUNTS = getConfigValue('enableUserAccounts', false);
|
const ENABLE_ACCOUNTS = getConfigValue('enableUserAccounts', false);
|
||||||
const AUTHELIA_AUTH = getConfigValue('autheliaAuth', 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');
|
const ANON_CSRF_SECRET = crypto.randomBytes(64).toString('base64');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -588,7 +588,7 @@ async function tryAutoLogin(request) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PERUSER_BASIC_AUTH && await basicUserLogin(request)) {
|
if (PER_USER_BASIC_AUTH && await basicUserLogin(request)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user