12216: Disable lock operations.
authorTom Clegg <tclegg@veritasgenetics.com>
Thu, 12 Oct 2017 05:20:19 +0000 (01:20 -0400)
committerTom Clegg <tclegg@veritasgenetics.com>
Thu, 12 Oct 2017 19:03:27 +0000 (15:03 -0400)
Lock support in a webdav server is optional, and none of the
operations that would be affected by locks (i.e., writes) are
supported here anyway.

Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tclegg@veritasgenetics.com>

services/keep-web/handler.go
services/keep-web/handler_test.go
services/keep-web/webdav.go

index 4c12b8e479fecab8bab6e2f7498f635d279a4dfa..88227677174342f6f29bef52266d96e7c57a3dfc 100644 (file)
@@ -82,6 +82,8 @@ func (h *handler) setup() {
                Prefix: "/_health/",
        }
 
+       // Even though we don't accept LOCK requests, every webdav
+       // handler must have a non-nil LockSystem.
        h.webdavLS = &noLockSystem{}
 }
 
@@ -98,8 +100,6 @@ var (
        webdavMethod = map[string]bool{
                "OPTIONS":  true,
                "PROPFIND": true,
-               "LOCK":     true,
-               "UNLOCK":   true,
        }
        fsMethod = map[string]bool{
                "GET":  true,
@@ -147,7 +147,7 @@ func (h *handler) ServeHTTP(wOrig http.ResponseWriter, r *http.Request) {
                        return
                }
                w.Header().Set("Access-Control-Allow-Headers", "Range")
-               w.Header().Set("Access-Control-Allow-Methods", "GET, POST, OPTIONS, PROPFIND, LOCK, UNLOCK")
+               w.Header().Set("Access-Control-Allow-Methods", "GET, POST, OPTIONS, PROPFIND")
                w.Header().Set("Access-Control-Allow-Origin", "*")
                w.Header().Set("Access-Control-Max-Age", "86400")
                statusCode = http.StatusOK
index d0e92ee079c24d6057d226477bfbae5098a0868f..3bbb4edc0bc907d893443eb0707d21ebb84cfa75 100644 (file)
@@ -43,7 +43,7 @@ func (s *UnitSuite) TestCORSPreflight(c *check.C) {
        c.Check(resp.Code, check.Equals, http.StatusOK)
        c.Check(resp.Body.String(), check.Equals, "")
        c.Check(resp.Header().Get("Access-Control-Allow-Origin"), check.Equals, "*")
-       c.Check(resp.Header().Get("Access-Control-Allow-Methods"), check.Equals, "GET, POST, OPTIONS, PROPFIND, LOCK, UNLOCK")
+       c.Check(resp.Header().Get("Access-Control-Allow-Methods"), check.Equals, "GET, POST, OPTIONS, PROPFIND")
        c.Check(resp.Header().Get("Access-Control-Allow-Headers"), check.Equals, "Range")
 
        // Check preflight for a disallowed request
index 109bfa7cedd052991da1ae1c0c407367a823efd0..0a7b7822b20c7f8f5be5cea10eff434481cfe3f8 100644 (file)
@@ -87,6 +87,10 @@ func (f *webdavFile) Write([]byte) (int, error) {
 // However, it does also permit impossible operations, like acquiring
 // conflicting locks and releasing non-existent locks.  This might
 // confuse some clients if they try to probe for correctness.
+//
+// Currently this is a moot point: the LOCK and UNLOCK methods are not
+// accepted by keep-web, so it suffices to implement the
+// webdav.LockSystem interface.
 type noLockSystem struct{}
 
 func (*noLockSystem) Confirm(time.Time, string, string, ...webdav.Condition) (func(), error) {