mirror of
https://github.com/DayuanJiang/next-ai-draw-io.git
synced 2026-09-03 01:50:23 +08:00
Adds Ollama to SSRF protection exception list
Ollama is a local/self-hosted model that doesn't require API keys. The SSRF protection was incorrectly blocking Ollama connections when users provided a custom base URL without an API key. Fixes #652
This commit is contained in:
@@ -572,12 +572,13 @@ export function getAIModel(overrides?: ClientOverrides): ModelConfig {
|
|||||||
// SECURITY: Prevent SSRF attacks (GHSA-9qf7-mprq-9qgm)
|
// SECURITY: Prevent SSRF attacks (GHSA-9qf7-mprq-9qgm)
|
||||||
// If a custom baseUrl is provided, an API key MUST also be provided.
|
// If a custom baseUrl is provided, an API key MUST also be provided.
|
||||||
// This prevents attackers from redirecting server API keys to malicious endpoints.
|
// This prevents attackers from redirecting server API keys to malicious endpoints.
|
||||||
// Exception: EdgeOne provider doesn't require API key (uses Edge AI runtime)
|
// Exception: EdgeOne and Ollama providers don't require API keys
|
||||||
if (
|
if (
|
||||||
overrides?.baseUrl &&
|
overrides?.baseUrl &&
|
||||||
!overrides?.apiKey &&
|
!overrides?.apiKey &&
|
||||||
!(overrides?.provider === "vertexai" && overrides?.vertexApiKey) &&
|
!(overrides?.provider === "vertexai" && overrides?.vertexApiKey) &&
|
||||||
overrides?.provider !== "edgeone"
|
overrides?.provider !== "edgeone" &&
|
||||||
|
overrides?.provider !== "ollama"
|
||||||
) {
|
) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`API key is required when using a custom base URL. ` +
|
`API key is required when using a custom base URL. ` +
|
||||||
|
|||||||
Reference in New Issue
Block a user