mirror of https://github.com/Xhofe/alist
Add IsStorageSigned func to judge if Signing is enabled in the storage settings.
It should be working now.pull/3924/head
parent
21c8e07baa
commit
0e2a22ec8c
|
@ -0,0 +1,19 @@
|
|||
package sign
|
||||
|
||||
import (
|
||||
"github.com/alist-org/alist/v3/internal/op"
|
||||
json "github.com/json-iterator/go"
|
||||
)
|
||||
|
||||
func IsStorageSigned(rawPath string) bool {
|
||||
storage := op.GetBalancedStorage(rawPath).GetStorage()
|
||||
var jsonData = map[string]interface{}{}
|
||||
err := json.Unmarshal([]byte(storage.Addition), &jsonData)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
if jsonData["sign"] == "true" {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
|
@ -264,7 +264,7 @@ func FsGet(c *gin.Context) {
|
|||
if storage.Config().MustProxy() || storage.GetStorage().WebProxy {
|
||||
query := "?"
|
||||
if needSign(meta, reqPath) {
|
||||
query = query + "sign=" + sign.Sign(reqPath) + "&"
|
||||
query = query + "sign=" + sign.Sign(reqPath)
|
||||
}
|
||||
if query == "?" {
|
||||
query = ""
|
||||
|
@ -374,6 +374,9 @@ func needSign(meta *model.Meta, path string) bool {
|
|||
if setting.GetBool(conf.SignAll) {
|
||||
return true
|
||||
}
|
||||
if sign.IsStorageSigned(path) {
|
||||
return true
|
||||
}
|
||||
if meta == nil || meta.Password == "" {
|
||||
return false
|
||||
}
|
||||
|
|
|
@ -36,8 +36,6 @@ func Down(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
}
|
||||
// verify token
|
||||
|
||||
c.Next()
|
||||
}
|
||||
|
||||
|
@ -51,6 +49,9 @@ func needSign(meta *model.Meta, path string) bool {
|
|||
if setting.GetBool(conf.SignAll) {
|
||||
return true
|
||||
}
|
||||
if sign.IsStorageSigned(path) {
|
||||
return true
|
||||
}
|
||||
if meta == nil || meta.Password == "" {
|
||||
return false
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue