Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:lock: Perform authentication on paths such as widgets, plugins, and templates https://github.com/siyuan-note/siyuan/issues/17118#issuecomment-3984053596

Danield1170e7b71f9
diff --git a/kernel/server/serve.go b/kernel/server/serve.go
index 5277d3c1a6..10d174f78c 100644
--- a/kernel/server/serve.go
+++ b/kernel/server/serve.go
@@ -369,6 +369,13 @@ func servePublic(ginServer *gin.Engine) {
func serveSnippets(ginServer *gin.Engine) {
ginServer.Handle("GET", "/snippets/*filepath", model.CheckAuth, func(c *gin.Context) {
filePath := strings.TrimPrefix(c.Request.URL.Path, "/snippets/")
+ if !model.IsAdminRoleContext(c) {
+ if "conf.json" == filePath {
+ c.Status(http.StatusUnauthorized)
+ return
+ }
+ }
+
ext := filepath.Ext(filePath)
name := strings.TrimSuffix(filePath, ext)
confSnippets, err := model.LoadSnippets()