mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-03-09 22:22:34 +01:00
🧑💻 Kernel serve WebDAV service on path /webdav/ (#12412)
* 🎨 Add a WebDAV service to the kernel * 🎨 Add more writable WebDAV methods
This commit is contained in:
parent
f88296c4d2
commit
9cff5cc235
6 changed files with 65 additions and 5 deletions
|
|
@ -250,6 +250,16 @@ func CheckAuth(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
// 通过 BasicAuth (header: Authorization)
|
||||
if username, password, ok := c.Request.BasicAuth(); ok {
|
||||
// 使用访问授权码作为密码
|
||||
if util.WorkspaceName == username && Conf.AccessAuthCode == password {
|
||||
c.Set(RoleContextKey, RoleAdministrator)
|
||||
c.Next()
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// 通过 API token (header: Authorization)
|
||||
if authHeader := c.GetHeader("Authorization"); "" != authHeader {
|
||||
var token string
|
||||
|
|
@ -289,7 +299,15 @@ func CheckAuth(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
if "/check-auth" == c.Request.URL.Path { // 跳过访问授权页
|
||||
// WebDAV BasicAuth Authenticate
|
||||
if strings.HasPrefix(c.Request.RequestURI, "/webdav") {
|
||||
c.Header("WWW-Authenticate", "Basic realm=Authorization Required")
|
||||
c.AbortWithStatus(http.StatusUnauthorized)
|
||||
return
|
||||
}
|
||||
|
||||
// 跳过访问授权页
|
||||
if "/check-auth" == c.Request.URL.Path {
|
||||
c.Next()
|
||||
return
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue