mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-02-25 16:34:06 +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
|
|
@ -441,7 +441,7 @@ func ExportData() (zipPath string, err error) {
|
|||
util.PushEndlessProgress(Conf.Language(65))
|
||||
defer util.ClearPushProgress(100)
|
||||
|
||||
name := util.FilterFileName(filepath.Base(util.WorkspaceDir)) + "-" + util.CurrentTimeSecondsStr()
|
||||
name := util.FilterFileName(util.WorkspaceName) + "-" + util.CurrentTimeSecondsStr()
|
||||
exportFolder := filepath.Join(util.TempDir, "export", name)
|
||||
zipPath, err = exportData(exportFolder)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -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