Skip to content

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

:art: Authenticate requests with the Origin header other than 127.0.0.1 https://github.com/siyuan-note/siyuan/issues/9180

Daniel0e7dcc0ea19c
diff --git a/kernel/model/session.go b/kernel/model/session.go
index 089d89b329..04dbd9cccf 100644
--- a/kernel/model/session.go
+++ b/kernel/model/session.go
@@ -165,12 +165,21 @@ func CheckAuth(c *gin.Context) {
u, parseErr := url.Parse(origin)
if nil != parseErr {
logging.LogWarnf("parse origin [%s] failed: %s", origin, parseErr)
- } else {
- if !strings.HasPrefix(u.Host, util.LocalHost) && !strings.HasPrefix(u.Host, "[::1]") {
- c.JSON(401, map[string]interface{}{"code": -1, "msg": "Auth failed"})
- c.Abort()
- return
- }
+ c.JSON(401, map[string]interface{}{"code": -1, "msg": "Auth failed"})
+ c.Abort()
+ return
+
+ }
+
+ if "chrome-extension" == strings.ToLower(u.Scheme) {
+ c.Next()
+ return
+ }
+
+ if !strings.HasPrefix(u.Host, util.LocalHost) && !strings.HasPrefix(u.Host, "[::1]") {
+ c.JSON(401, map[string]interface{}{"code": -1, "msg": "Auth failed"})
+ c.Abort()
+ return
}
}