security: redact sensitive config values and protect update endpoints
This commit is contained in:
@@ -93,7 +93,14 @@ function loadConfig() {
|
|||||||
loadConfig();
|
loadConfig();
|
||||||
|
|
||||||
export function getPublicConfig() {
|
export function getPublicConfig() {
|
||||||
return { ...config };
|
// Create a deep copy and redact sensitive fields
|
||||||
|
const publicConfig = JSON.parse(JSON.stringify(config));
|
||||||
|
|
||||||
|
// Redact sensitive values
|
||||||
|
if (publicConfig.webuiPassword) publicConfig.webuiPassword = '********';
|
||||||
|
if (publicConfig.apiKey) publicConfig.apiKey = '********';
|
||||||
|
|
||||||
|
return publicConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function saveConfig(updates) {
|
export function saveConfig(updates) {
|
||||||
|
|||||||
@@ -127,8 +127,9 @@ function createAuthMiddleware() {
|
|||||||
|
|
||||||
// Determine if this path should be protected
|
// Determine if this path should be protected
|
||||||
const isApiRoute = req.path.startsWith('/api/');
|
const isApiRoute = req.path.startsWith('/api/');
|
||||||
const isException = req.path === '/api/auth/url' || req.path === '/api/config';
|
const isAuthUrl = req.path === '/api/auth/url';
|
||||||
const isProtected = (isApiRoute && !isException) || req.path === '/account-limits' || req.path === '/health';
|
const isConfigGet = req.path === '/api/config' && req.method === 'GET';
|
||||||
|
const isProtected = (isApiRoute && !isAuthUrl && !isConfigGet) || req.path === '/account-limits' || req.path === '/health';
|
||||||
|
|
||||||
if (isProtected) {
|
if (isProtected) {
|
||||||
const providedPassword = req.headers['x-webui-password'] || req.query.password;
|
const providedPassword = req.headers['x-webui-password'] || req.query.password;
|
||||||
|
|||||||
Reference in New Issue
Block a user