mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-04-25 16:08:44 +02:00
Rename basic auth middleware
This commit is contained in:
parent
fad718baa1
commit
dd7ac914a6
@ -37,7 +37,7 @@ util.inspect.defaultOptions.maxArrayLength = null;
|
|||||||
util.inspect.defaultOptions.maxStringLength = null;
|
util.inspect.defaultOptions.maxStringLength = null;
|
||||||
|
|
||||||
// local library imports
|
// local library imports
|
||||||
const basicAuthMiddleware = require('./src/middleware/basicAuthMiddleware');
|
const basicAuthMiddleware = require('./src/middleware/basicAuth');
|
||||||
const whitelistMiddleware = require('./src/middleware/whitelist');
|
const whitelistMiddleware = require('./src/middleware/whitelist');
|
||||||
const { jsonParser, urlencodedParser } = require('./src/express-common.js');
|
const { jsonParser, urlencodedParser } = require('./src/express-common.js');
|
||||||
const contentManager = require('./src/endpoints/content-manager');
|
const contentManager = require('./src/endpoints/content-manager');
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* When applied, this middleware will ensure the request contains the required header for basic authentication and only
|
* When applied, this middleware will ensure the request contains the required header for basic authentication and only
|
||||||
* allow access to the endpoint after successful authentication.
|
* allow access to the endpoint after successful authentication.
|
||||||
*/
|
*/
|
||||||
const { getConfig } = require('./../util.js');
|
const { getConfig } = require('../util.js');
|
||||||
|
|
||||||
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"');
|
@ -7,7 +7,9 @@ const { color, getConfigValue } = require('../util');
|
|||||||
|
|
||||||
const whitelistPath = path.join(process.cwd(), './whitelist.txt');
|
const whitelistPath = path.join(process.cwd(), './whitelist.txt');
|
||||||
let whitelist = getConfigValue('whitelist', []);
|
let whitelist = getConfigValue('whitelist', []);
|
||||||
|
let knownIPs = new Set();
|
||||||
const listen = getConfigValue('listen', false);
|
const listen = getConfigValue('listen', false);
|
||||||
|
const whitelistMode = getConfigValue('whitelistMode', true);
|
||||||
|
|
||||||
if (fs.existsSync(whitelistPath)) {
|
if (fs.existsSync(whitelistPath)) {
|
||||||
try {
|
try {
|
||||||
@ -18,11 +20,6 @@ if (fs.existsSync(whitelistPath)) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const whitelistMode = getConfigValue('whitelistMode', true);
|
|
||||||
|
|
||||||
// IP Whitelist //
|
|
||||||
let knownIPs = new Set();
|
|
||||||
|
|
||||||
function getIpFromRequest(req) {
|
function getIpFromRequest(req) {
|
||||||
let clientIp = req.connection.remoteAddress;
|
let clientIp = req.connection.remoteAddress;
|
||||||
let ip = ipaddr.parse(clientIp);
|
let ip = ipaddr.parse(clientIp);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user