mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 00:40:14 +01:00
🔓 refactor: Make Image URL Security Optional (#2415)
This commit is contained in:
parent
2cc580ba52
commit
fce7246ac1
4 changed files with 14 additions and 1 deletions
|
|
@ -3,9 +3,14 @@ const jwt = require('jsonwebtoken');
|
|||
const { logger } = require('~/config');
|
||||
|
||||
/**
|
||||
* Middleware to validate image request
|
||||
* Middleware to validate image request.
|
||||
* Must be set by `secureImageLinks` via custom config file.
|
||||
*/
|
||||
function validateImageRequest(req, res, next) {
|
||||
if (!req.app.locals.secureImageLinks) {
|
||||
return next();
|
||||
}
|
||||
|
||||
const refreshToken = req.headers.cookie ? cookies.parse(req.headers.cookie).refreshToken : null;
|
||||
if (!refreshToken) {
|
||||
logger.warn('[validateImageRequest] Refresh token not provided');
|
||||
|
|
|
|||
|
|
@ -180,6 +180,7 @@ const AppService = async (app) => {
|
|||
fileStrategy,
|
||||
fileConfig: config?.fileConfig,
|
||||
interface: config?.interface,
|
||||
secureImageLinks: config?.secureImageLinks,
|
||||
paths,
|
||||
...endpointLocals,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -203,6 +203,12 @@ This example configuration file sets up LibreChat with detailed options across s
|
|||
- **Description**: Determines where to save user uploaded/generated files. Defaults to `"local"` if omitted.
|
||||
- **Example**: `fileStrategy: "firebase"`
|
||||
|
||||
### Image Links
|
||||
- **Key**: `secureImageLinks`
|
||||
- **Type**: Boolean
|
||||
- **Description**: Whether or not to secure access to image links that are hosted locally by the app. Default: false.
|
||||
- **Example**: `secureImageLinks: true`
|
||||
|
||||
### File Configuration
|
||||
- **Key**: `fileConfig`
|
||||
- **Type**: Object
|
||||
|
|
|
|||
|
|
@ -189,6 +189,7 @@ export const rateLimitSchema = z.object({
|
|||
export const configSchema = z.object({
|
||||
version: z.string(),
|
||||
cache: z.boolean().optional().default(true),
|
||||
secureImageLinks: z.boolean().optional(),
|
||||
interface: z
|
||||
.object({
|
||||
privacyPolicy: z
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue