feat: add STORAGE_ALLOW_LIST env var

This commit is contained in:
Windfarer
2026-04-29 18:58:09 +08:00
parent 2beb64c429
commit 6601a483be
9 changed files with 198 additions and 33 deletions
+6
View File
@@ -5,6 +5,7 @@ import (
stderrors "errors"
"net/http"
"strconv"
"strings"
"time"
"github.com/Tencent/WeKnora/internal/application/repository"
@@ -128,6 +129,11 @@ func (h *KnowledgeBaseHandler) CreateKnowledgeBase(c *gin.Context) {
c.Error(err)
return
}
provider := strings.ToLower(strings.TrimSpace(req.GetStorageProvider()))
if provider != "" && !isStorageProviderAllowed(provider) {
c.Error(apperrors.NewBadRequestError("Storage provider is not allowed by STORAGE_ALLOW_LIST"))
return
}
logger.Infof(ctx, "Creating knowledge base, name: %s", secutils.SanitizeForLog(req.Name))
// Create knowledge base using the service