mirror of
https://github.com/mickael-kerjean/filestash
synced 2025-12-06 16:32:31 +01:00
fix (webdav): network drive permissions
This commit is contained in:
parent
26ab48a635
commit
87d6911288
1 changed files with 14 additions and 4 deletions
|
|
@ -19,10 +19,10 @@ func WebdavHandler(ctx *App, res http.ResponseWriter, req *http.Request) {
|
||||||
|
|
||||||
// https://github.com/golang/net/blob/master/webdav/webdav.go#L49-L68
|
// https://github.com/golang/net/blob/master/webdav/webdav.go#L49-L68
|
||||||
canRead := model.CanRead(ctx)
|
canRead := model.CanRead(ctx)
|
||||||
canWrite := model.CanRead(ctx)
|
canWrite := model.CanEdit(ctx)
|
||||||
canUpload := model.CanUpload(ctx)
|
canUpload := model.CanUpload(ctx)
|
||||||
switch req.Method {
|
switch req.Method {
|
||||||
case "OPTIONS", "GET", "HEAD", "POST", "PROPFIND":
|
case "OPTIONS", "HEAD", "GET":
|
||||||
if canRead == false {
|
if canRead == false {
|
||||||
SendErrorResult(res, ErrPermissionDenied)
|
SendErrorResult(res, ErrPermissionDenied)
|
||||||
return
|
return
|
||||||
|
|
@ -32,8 +32,18 @@ func WebdavHandler(ctx *App, res http.ResponseWriter, req *http.Request) {
|
||||||
SendErrorResult(res, ErrPermissionDenied)
|
SendErrorResult(res, ErrPermissionDenied)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
case "PUT", "LOCK", "UNLOCK":
|
case "PROPFIND":
|
||||||
if canWrite == false && canUpload == false {
|
if canRead == false {
|
||||||
|
SendErrorResult(res, ErrPermissionDenied)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
case "PUT":
|
||||||
|
if canWrite == false || canUpload == false {
|
||||||
|
SendErrorResult(res, ErrPermissionDenied)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
case "LOCK", "UNLOCK":
|
||||||
|
if canWrite == false || canUpload == false {
|
||||||
SendErrorResult(res, ErrPermissionDenied)
|
SendErrorResult(res, ErrPermissionDenied)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue