up
This commit is contained in:
parent
0f300c3e72
commit
90810eefd4
@ -95,7 +95,7 @@ func RoutesPublic(r *mux.Router, bd *gorm.DB) {
|
|||||||
http.Error(w, "Erreur lors de la génération de la playlist", http.StatusInternalServerError)
|
http.Error(w, "Erreur lors de la génération de la playlist", http.StatusInternalServerError)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
r.PathPrefix("/webdav/").Handler(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
|
r.PathPrefix("/webdav/").Handler(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
|
||||||
authHeader := req.Header.Get("Authorization")
|
authHeader := req.Header.Get("Authorization")
|
||||||
if authHeader == "" {
|
if authHeader == "" {
|
||||||
w.Header().Set("WWW-Authenticate", `Basic realm="Restricted"`)
|
w.Header().Set("WWW-Authenticate", `Basic realm="Restricted"`)
|
||||||
@ -110,8 +110,8 @@ r.PathPrefix("/webdav/").Handler(http.HandlerFunc(func(w http.ResponseWriter, re
|
|||||||
http.Error(w, "Unauthorized", http.StatusUnauthorized)
|
http.Error(w, "Unauthorized", http.StatusUnauthorized)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.Printf("✅ email saisie: %s", email)
|
log.Printf("✅ email saisi: %s", email)
|
||||||
log.Printf("✅ passw saisie: %s", password)
|
log.Printf("✅ password saisi: %s", password)
|
||||||
|
|
||||||
var user models.User
|
var user models.User
|
||||||
result := bd.Where("email = ?", email).First(&user)
|
result := bd.Where("email = ?", email).First(&user)
|
||||||
@ -128,17 +128,14 @@ r.PathPrefix("/webdav/").Handler(http.HandlerFunc(func(w http.ResponseWriter, re
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lecture seule
|
// ✅ Ici on autorise TOUTES les méthodes WebDAV (lecture/écriture/suppression)
|
||||||
if req.Method != "GET" && req.Method != "HEAD" && req.Method != "OPTIONS" && req.Method != "PROPFIND" {
|
log.Printf("✅ WebDAV FULL ACCESS for user: %s", email)
|
||||||
http.Error(w, "Read-Only", http.StatusForbidden)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
log.Printf("✅ WebDAV access for user: %s", email)
|
|
||||||
|
|
||||||
|
// Headers WebDAV que certains clients attendent
|
||||||
w.Header().Set("DAV", "1,2")
|
w.Header().Set("DAV", "1,2")
|
||||||
w.Header().Set("MS-Author-Via", "DAV")
|
w.Header().Set("MS-Author-Via", "DAV")
|
||||||
|
|
||||||
|
// Handler WebDAV complet
|
||||||
webdavHandler := &webdav.Handler{
|
webdavHandler := &webdav.Handler{
|
||||||
Prefix: "/webdav/",
|
Prefix: "/webdav/",
|
||||||
FileSystem: webdav.Dir("/app/upload"),
|
FileSystem: webdav.Dir("/app/upload"),
|
||||||
@ -146,7 +143,7 @@ r.PathPrefix("/webdav/").Handler(http.HandlerFunc(func(w http.ResponseWriter, re
|
|||||||
}
|
}
|
||||||
|
|
||||||
webdavHandler.ServeHTTP(w, req)
|
webdavHandler.ServeHTTP(w, req)
|
||||||
}))
|
}))
|
||||||
|
|
||||||
// WebDAV sécurisé
|
// WebDAV sécurisé
|
||||||
// username := "tonuser" // ton login
|
// username := "tonuser" // ton login
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user