mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-11-16 21:08:17 +00:00
* fix: Enable Bundled Database Auth and Warn On Plain-HTTP Ingress * fix: Render the Env ConfigMap When librechat.configEnv Is Unset * fix: Respect User-Supplied Mongo and Redis Credentials Over Generated Ones * docs: Add Upgrade Notice for Bundled MongoDB Auth Default * fix: Order Supplied Credentials First and Split Bundled Credential Opt-Outs * fix: Percent-Encode the Bundled MongoDB Root Username in MONGO_URI * fix: Warn Per Ingress Host Without TLS Coverage and Document Credential Rotation * docs: Document Password Persistence and Release the Auth Default as a Major Chart Version * fix: Fail Render When a Supplied Redis Password Does Not Match the Bundled Redis * fix: Validate Supplied MongoDB Root Password Against the Bundled Server * docs: Include the Langfuse Fanout Deployment in the Rotation Restart * fix: Derive Ingress URL Scheme Per Host and Document the MongoDB Replica Set Key * fix: Validate configEnv Mongo Password and Keep Upgrade Passwords as Strings * fix: Reject Supplied Database Passwords That Differ From the Bundled Subchart * fix: Ignore Inherited Literals When a Secret Reference Overrides the Password * fix: Skip Password Comparison When an Existing Secret Supplies Credentials * fix: Deny Placeholder Expansion of the Bundled MongoDB Root Password
86 lines
2.3 KiB
TypeScript
86 lines
2.3 KiB
TypeScript
export const envVarRegex = /^\${(.+)}$/;
|
|
|
|
/**
|
|
* Infrastructure env vars that must never be resolved via placeholder expansion.
|
|
* These are internal secrets whose exposure would compromise the system —
|
|
* they have no legitimate reason to appear in outbound headers, MCP env/args, or OAuth config.
|
|
*
|
|
* Intentionally excludes API keys (operators reference them in config) and
|
|
* OAuth/session secrets (referenced in MCP OAuth config via processMCPEnv).
|
|
*/
|
|
const SENSITIVE_ENV_VARS = new Set([
|
|
'JWT_SECRET',
|
|
'JWT_REFRESH_SECRET',
|
|
'CREDS_KEY',
|
|
'CREDS_IV',
|
|
'MEILI_MASTER_KEY',
|
|
'MONGO_URI',
|
|
'MONGODB_ROOT_PASSWORD',
|
|
'REDIS_URI',
|
|
'REDIS_PASSWORD',
|
|
]);
|
|
|
|
/** Returns true when `varName` refers to an infrastructure secret that must not leak. */
|
|
export function isSensitiveEnvVar(varName: string): boolean {
|
|
return SENSITIVE_ENV_VARS.has(varName);
|
|
}
|
|
|
|
/** Extracts the environment variable name from a template literal string */
|
|
export function extractVariableName(value: string): string | null {
|
|
if (!value) {
|
|
return null;
|
|
}
|
|
|
|
const match = value.trim().match(envVarRegex);
|
|
return match ? match[1] : null;
|
|
}
|
|
|
|
/** Extracts the value of an environment variable from a string. */
|
|
export function extractEnvVariable(value: string) {
|
|
if (!value) {
|
|
return value;
|
|
}
|
|
|
|
const trimmed = value.trim();
|
|
|
|
const singleMatch = trimmed.match(envVarRegex);
|
|
if (singleMatch) {
|
|
const varName = singleMatch[1];
|
|
if (isSensitiveEnvVar(varName)) {
|
|
return trimmed;
|
|
}
|
|
return process.env[varName] || trimmed;
|
|
}
|
|
|
|
const regex = /\${([^}]+)}/g;
|
|
let result = trimmed;
|
|
|
|
const matches = [];
|
|
let match;
|
|
while ((match = regex.exec(trimmed)) !== null) {
|
|
matches.push({
|
|
fullMatch: match[0],
|
|
varName: match[1],
|
|
index: match.index,
|
|
});
|
|
}
|
|
|
|
for (let i = matches.length - 1; i >= 0; i--) {
|
|
const { fullMatch, varName, index } = matches[i];
|
|
if (isSensitiveEnvVar(varName)) {
|
|
continue;
|
|
}
|
|
const envValue = process.env[varName] || fullMatch;
|
|
result = result.substring(0, index) + envValue + result.substring(index + fullMatch.length);
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Normalize the endpoint name to system-expected value.
|
|
* @param name
|
|
*/
|
|
export function normalizeEndpointName(name = ''): string {
|
|
return name.toLowerCase() === 'ollama' ? 'ollama' : name;
|
|
}
|