From 2a113e9f7df0514dd8890be42e3bbcb899554a83 Mon Sep 17 00:00:00 2001 From: Michael Barz Date: Thu, 7 Jul 2022 13:05:00 +0200 Subject: [PATCH 1/9] use spaceID --- .drone.star | 2 +- changelog/unreleased/space-id.md | 5 ++ go.mod | 6 +- go.sum | 8 +- .../gen/ocis/messages/search/v0/search.pb.go | 88 +++++++++++-------- .../services/search/v0/search.swagger.json | 3 + .../ocis/messages/search/v0/search.proto | 1 + services/audit/pkg/service/service_test.go | 71 +++++++-------- services/graph/pkg/service/v0/driveitems.go | 11 ++- services/graph/pkg/service/v0/drives.go | 63 ++++--------- services/graph/pkg/service/v0/graph_test.go | 39 ++++---- services/search/pkg/search/index/index.go | 38 +++++--- .../search/pkg/search/index/index_test.go | 31 ++++--- .../pkg/search/provider/searchprovider.go | 18 ++-- .../features/bootstrap/SpacesContext.php | 10 ++- 15 files changed, 216 insertions(+), 178 deletions(-) create mode 100644 changelog/unreleased/space-id.md diff --git a/.drone.star b/.drone.star index d80e42c1c4e..11482b23624 100644 --- a/.drone.star +++ b/.drone.star @@ -17,7 +17,7 @@ OC_CI_GOLANG = "owncloudci/golang:1.18" OC_CI_NODEJS = "owncloudci/nodejs:%s" OC_CI_PHP = "owncloudci/php:%s" OC_CI_WAIT_FOR = "owncloudci/wait-for:latest" -OC_CS3_API_VALIDATOR = "owncloud/cs3api-validator:0.1.0" +OC_CS3_API_VALIDATOR = "owncloud/cs3api-validator:0.2.0" OC_LITMUS = "owncloud/litmus:latest" OC_OC_TEST_MIDDLEWARE = "owncloud/owncloud-test-middleware:1.6.0" OC_SERVER = "owncloud/server:10" diff --git a/changelog/unreleased/space-id.md b/changelog/unreleased/space-id.md new file mode 100644 index 00000000000..b35b672fce8 --- /dev/null +++ b/changelog/unreleased/space-id.md @@ -0,0 +1,5 @@ +Change: Use the spaceID on the cs3 resource + +We cleaned up the CS3Api to use a proper attribute for the space id. + +https://github.com/owncloud/ocis/pull/4748 diff --git a/go.mod b/go.mod index 383080bb2e0..606d19be4ec 100644 --- a/go.mod +++ b/go.mod @@ -9,8 +9,8 @@ require ( github.com/blevesearch/bleve/v2 v2.3.3 github.com/blevesearch/bleve_index_api v1.0.2 github.com/coreos/go-oidc/v3 v3.2.0 - github.com/cs3org/go-cs3apis v0.0.0-20220512100524-551800f020d8 - github.com/cs3org/reva/v2 v2.6.2-0.20220706093852-e2232b5a63df + github.com/cs3org/go-cs3apis v0.0.0-20220621145831-c38cca0796c2 + github.com/cs3org/reva/v2 v2.0.0-00010101000000-000000000000 github.com/disintegration/imaging v1.6.2 github.com/ggwhite/go-masker v1.0.9 github.com/go-chi/chi/v5 v5.0.7 @@ -267,4 +267,4 @@ require ( stash.kopano.io/kgol/kcc-go/v5 v5.0.1 // indirect ) -replace github.com/cs3org/go-cs3apis => github.com/micbar/go-cs3apis v0.0.0-20220617090231-703c04619761 // temp fork +replace github.com/cs3org/reva/v2 => github.com/micbar/reva/v2 v2.0.0-20220711074018-2773fa144658 diff --git a/go.sum b/go.sum index d4c55ad6cf6..49c5eeacca3 100644 --- a/go.sum +++ b/go.sum @@ -297,8 +297,8 @@ github.com/crewjam/httperr v0.2.0/go.mod h1:Jlz+Sg/XqBQhyMjdDiC+GNNRzZTD7x39Gu3p github.com/crewjam/saml v0.4.6 h1:XCUFPkQSJLvzyl4cW9OvpWUbRf0gE7VUpU8ZnilbeM4= github.com/crewjam/saml v0.4.6/go.mod h1:ZBOXnNPFzB3CgOkRm7Nd6IVdkG+l/wF+0ZXLqD96t1A= github.com/cs3org/cato v0.0.0-20200828125504-e418fc54dd5e/go.mod h1:XJEZ3/EQuI3BXTp/6DUzFr850vlxq11I6satRtz0YQ4= -github.com/cs3org/reva/v2 v2.6.2-0.20220706093852-e2232b5a63df h1:qbfO+xipOcpPsKbzoRAzgq3+JvKkc0JjQR6ov/rE2+I= -github.com/cs3org/reva/v2 v2.6.2-0.20220706093852-e2232b5a63df/go.mod h1:zAHqzr36X4lIalonDQeNbwrIXjn66C38lp5A+MTRS1c= +github.com/cs3org/go-cs3apis v0.0.0-20220621145831-c38cca0796c2 h1:o/ovJzS4pyL/rZgp0MtC4Q7JIle5DikimilTLBw2TjY= +github.com/cs3org/go-cs3apis v0.0.0-20220621145831-c38cca0796c2/go.mod h1:UXha4TguuB52H14EMoSsCqDj7k8a/t7g4gVP+bgY5LY= github.com/cubewise-code/go-mime v0.0.0-20200519001935-8c5762b177d8 h1:Z9lwXumT5ACSmJ7WGnFl+OMLLjpz5uR2fyz7dC255FI= github.com/cubewise-code/go-mime v0.0.0-20200519001935-8c5762b177d8/go.mod h1:4abs/jPXcmJzYoYGF91JF9Uq9s/KL5n1jvFDix8KcqY= github.com/cyberdelia/templates v0.0.0-20141128023046-ca7fffd4298c/go.mod h1:GyV+0YP4qX0UQ7r2MoYZ+AvYDp12OF5yg4q8rGnyNh4= @@ -889,8 +889,8 @@ github.com/maxymania/go-system v0.0.0-20170110133659-647cc364bf0b h1:Q53idHrTuQD github.com/maxymania/go-system v0.0.0-20170110133659-647cc364bf0b/go.mod h1:KirJrATYGbTyUwVR26xIkaipRqRcMRXBf8N5dacvGus= github.com/mendsley/gojwk v0.0.0-20141217222730-4d5ec6e58103 h1:Z/i1e+gTZrmcGeZyWckaLfucYG6KYOXLWo4co8pZYNY= github.com/mendsley/gojwk v0.0.0-20141217222730-4d5ec6e58103/go.mod h1:o9YPB5aGP8ob35Vy6+vyq3P3bWe7NQWzf+JLiXCiMaE= -github.com/micbar/go-cs3apis v0.0.0-20220617090231-703c04619761 h1:vpejExni287rOeBsJxzCDSYJ4d981KXq7HnnaCt2Wn4= -github.com/micbar/go-cs3apis v0.0.0-20220617090231-703c04619761/go.mod h1:UXha4TguuB52H14EMoSsCqDj7k8a/t7g4gVP+bgY5LY= +github.com/micbar/reva/v2 v2.0.0-20220711074018-2773fa144658 h1:M/zjKqRtCNEDRNGkwS3stnA+11pfuqccBZ4Z5tRKsrc= +github.com/micbar/reva/v2 v2.0.0-20220711074018-2773fa144658/go.mod h1:GlPiCJmt6nDrbPm6lL7pShonSUZ0Ld2GLtR+lATjLCE= github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= github.com/miekg/dns v1.1.26/go.mod h1:bPDLeHnStXmXAq1m/Ch/hvfNHr14JKNPMBo3VZKjuso= github.com/miekg/dns v1.1.40/go.mod h1:KNUDUusw/aVsxyTYZM1oqvCicbwhgbNgztCETuNZ7xM= diff --git a/protogen/gen/ocis/messages/search/v0/search.pb.go b/protogen/gen/ocis/messages/search/v0/search.pb.go index f0aa6bb0e5b..d50cb7c38ec 100644 --- a/protogen/gen/ocis/messages/search/v0/search.pb.go +++ b/protogen/gen/ocis/messages/search/v0/search.pb.go @@ -28,6 +28,7 @@ type ResourceID struct { StorageId string `protobuf:"bytes,1,opt,name=storage_id,json=storageId,proto3" json:"storage_id,omitempty"` OpaqueId string `protobuf:"bytes,2,opt,name=opaque_id,json=opaqueId,proto3" json:"opaque_id,omitempty"` + SpaceId string `protobuf:"bytes,3,opt,name=space_id,json=spaceId,proto3" json:"space_id,omitempty"` } func (x *ResourceID) Reset() { @@ -76,6 +77,13 @@ func (x *ResourceID) GetOpaqueId() string { return "" } +func (x *ResourceID) GetSpaceId() string { + if x != nil { + return x.SpaceId + } + return "" +} + type Reference struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -316,50 +324,52 @@ var file_ocis_messages_search_v0_search_proto_rawDesc = []byte{ 0x73, 0x61, 0x67, 0x65, 0x73, 0x2e, 0x73, 0x65, 0x61, 0x72, 0x63, 0x68, 0x2e, 0x76, 0x30, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x22, 0x48, 0x0a, 0x0a, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x49, 0x44, 0x12, 0x1d, + 0x22, 0x63, 0x0a, 0x0a, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x49, 0x44, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x49, 0x64, 0x12, 0x1b, 0x0a, 0x09, 0x6f, 0x70, 0x61, 0x71, 0x75, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x08, 0x6f, 0x70, 0x61, 0x71, 0x75, 0x65, 0x49, 0x64, 0x22, 0x65, 0x0a, 0x09, 0x52, 0x65, - 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x44, 0x0a, 0x0b, 0x72, 0x65, 0x73, 0x6f, 0x75, - 0x72, 0x63, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x6f, - 0x63, 0x69, 0x73, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x2e, 0x73, 0x65, 0x61, - 0x72, 0x63, 0x68, 0x2e, 0x76, 0x30, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x49, - 0x44, 0x52, 0x0a, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x49, 0x64, 0x12, 0x12, 0x0a, - 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x61, 0x74, - 0x68, 0x22, 0xe6, 0x02, 0x0a, 0x06, 0x45, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x12, 0x34, 0x0a, 0x03, - 0x72, 0x65, 0x66, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x6f, 0x63, 0x69, 0x73, + 0x52, 0x08, 0x6f, 0x70, 0x61, 0x71, 0x75, 0x65, 0x49, 0x64, 0x12, 0x19, 0x0a, 0x08, 0x73, 0x70, + 0x61, 0x63, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x73, 0x70, + 0x61, 0x63, 0x65, 0x49, 0x64, 0x22, 0x65, 0x0a, 0x09, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, + 0x63, 0x65, 0x12, 0x44, 0x0a, 0x0b, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x69, + 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x6f, 0x63, 0x69, 0x73, 0x2e, 0x6d, + 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x2e, 0x73, 0x65, 0x61, 0x72, 0x63, 0x68, 0x2e, 0x76, + 0x30, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x49, 0x44, 0x52, 0x0a, 0x72, 0x65, + 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x61, 0x74, 0x68, 0x22, 0xe6, 0x02, 0x0a, + 0x06, 0x45, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x12, 0x34, 0x0a, 0x03, 0x72, 0x65, 0x66, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x6f, 0x63, 0x69, 0x73, 0x2e, 0x6d, 0x65, 0x73, 0x73, + 0x61, 0x67, 0x65, 0x73, 0x2e, 0x73, 0x65, 0x61, 0x72, 0x63, 0x68, 0x2e, 0x76, 0x30, 0x2e, 0x52, + 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x03, 0x72, 0x65, 0x66, 0x12, 0x33, 0x0a, + 0x02, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x6f, 0x63, 0x69, 0x73, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x2e, 0x73, 0x65, 0x61, 0x72, 0x63, 0x68, - 0x2e, 0x76, 0x30, 0x2e, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x03, 0x72, - 0x65, 0x66, 0x12, 0x33, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x23, + 0x2e, 0x76, 0x30, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x49, 0x44, 0x52, 0x02, + 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x65, 0x74, 0x61, 0x67, 0x18, 0x04, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x65, 0x74, 0x61, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x69, + 0x7a, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x04, 0x52, 0x04, 0x73, 0x69, 0x7a, 0x65, 0x12, 0x48, + 0x0a, 0x12, 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x69, 0x65, 0x64, 0x5f, + 0x74, 0x69, 0x6d, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, + 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, + 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x10, 0x6c, 0x61, 0x73, 0x74, 0x4d, 0x6f, 0x64, 0x69, + 0x66, 0x69, 0x65, 0x64, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x6d, 0x69, 0x6d, 0x65, + 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6d, 0x69, 0x6d, + 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, + 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x70, 0x65, 0x72, 0x6d, + 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, + 0x09, 0x20, 0x01, 0x28, 0x04, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x64, + 0x65, 0x6c, 0x65, 0x74, 0x65, 0x64, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x64, 0x65, + 0x6c, 0x65, 0x74, 0x65, 0x64, 0x22, 0x56, 0x0a, 0x05, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x12, 0x37, + 0x0a, 0x06, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x6f, 0x63, 0x69, 0x73, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x2e, 0x73, - 0x65, 0x61, 0x72, 0x63, 0x68, 0x2e, 0x76, 0x30, 0x2e, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, - 0x65, 0x49, 0x44, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, - 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x65, - 0x74, 0x61, 0x67, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x65, 0x74, 0x61, 0x67, 0x12, - 0x12, 0x0a, 0x04, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x04, 0x52, 0x04, 0x73, - 0x69, 0x7a, 0x65, 0x12, 0x48, 0x0a, 0x12, 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x6d, 0x6f, 0x64, 0x69, - 0x66, 0x69, 0x65, 0x64, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, - 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x10, 0x6c, 0x61, 0x73, - 0x74, 0x4d, 0x6f, 0x64, 0x69, 0x66, 0x69, 0x65, 0x64, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x1b, 0x0a, - 0x09, 0x6d, 0x69, 0x6d, 0x65, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x08, 0x6d, 0x69, 0x6d, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x70, 0x65, - 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x0b, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x12, 0x0a, 0x04, - 0x74, 0x79, 0x70, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x04, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, - 0x12, 0x18, 0x0a, 0x07, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x64, 0x18, 0x0a, 0x20, 0x01, 0x28, - 0x08, 0x52, 0x07, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x64, 0x22, 0x56, 0x0a, 0x05, 0x4d, 0x61, - 0x74, 0x63, 0x68, 0x12, 0x37, 0x0a, 0x06, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x6f, 0x63, 0x69, 0x73, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, - 0x67, 0x65, 0x73, 0x2e, 0x73, 0x65, 0x61, 0x72, 0x63, 0x68, 0x2e, 0x76, 0x30, 0x2e, 0x45, 0x6e, - 0x74, 0x69, 0x74, 0x79, 0x52, 0x06, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x12, 0x14, 0x0a, 0x05, - 0x73, 0x63, 0x6f, 0x72, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x02, 0x52, 0x05, 0x73, 0x63, 0x6f, - 0x72, 0x65, 0x42, 0x42, 0x5a, 0x40, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, - 0x2f, 0x6f, 0x77, 0x6e, 0x63, 0x6c, 0x6f, 0x75, 0x64, 0x2f, 0x6f, 0x63, 0x69, 0x73, 0x2f, 0x76, - 0x32, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x67, 0x65, 0x6e, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x6f, - 0x63, 0x69, 0x73, 0x2f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x2f, 0x73, 0x65, 0x61, - 0x72, 0x63, 0x68, 0x2f, 0x76, 0x30, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x65, 0x61, 0x72, 0x63, 0x68, 0x2e, 0x76, 0x30, 0x2e, 0x45, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x52, + 0x06, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x73, 0x63, 0x6f, 0x72, 0x65, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x02, 0x52, 0x05, 0x73, 0x63, 0x6f, 0x72, 0x65, 0x42, 0x42, 0x5a, + 0x40, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6f, 0x77, 0x6e, 0x63, + 0x6c, 0x6f, 0x75, 0x64, 0x2f, 0x6f, 0x63, 0x69, 0x73, 0x2f, 0x76, 0x32, 0x2f, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x67, 0x65, 0x6e, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x6f, 0x63, 0x69, 0x73, 0x2f, 0x6d, + 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x2f, 0x73, 0x65, 0x61, 0x72, 0x63, 0x68, 0x2f, 0x76, + 0x30, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/protogen/gen/ocis/services/search/v0/search.swagger.json b/protogen/gen/ocis/services/search/v0/search.swagger.json index a25a91c758b..99b0f1cca4f 100644 --- a/protogen/gen/ocis/services/search/v0/search.swagger.json +++ b/protogen/gen/ocis/services/search/v0/search.swagger.json @@ -242,6 +242,9 @@ }, "opaqueId": { "type": "string" + }, + "spaceId": { + "type": "string" } } }, diff --git a/protogen/proto/ocis/messages/search/v0/search.proto b/protogen/proto/ocis/messages/search/v0/search.proto index f79488aaffd..3ece6a30800 100644 --- a/protogen/proto/ocis/messages/search/v0/search.proto +++ b/protogen/proto/ocis/messages/search/v0/search.proto @@ -9,6 +9,7 @@ option go_package = "github.com/owncloud/ocis/v2/protogen/gen/ocis/messages/sear message ResourceID { string storage_id = 1; string opaque_id = 2; + string space_id = 3; } message Reference { diff --git a/services/audit/pkg/service/service_test.go b/services/audit/pkg/service/service_test.go index 072c4dc7c09..2f642906c5a 100644 --- a/services/audit/pkg/service/service_test.go +++ b/services/audit/pkg/service/service_test.go @@ -29,7 +29,7 @@ var testCases = []struct { Sharer: userID("sharing-userid"), GranteeUserID: userID("beshared-userid"), GranteeGroupID: nil, - ItemID: resourceID("storage-1", "itemid-1"), + ItemID: resourceID("provider-1", "storage-1", "itemid-1"), CTime: timestamp(0), }, CheckAuditEvent: func(t *testing.T, b []byte) { @@ -56,7 +56,7 @@ var testCases = []struct { Sharer: userID("sharing-userid"), GranteeUserID: nil, GranteeGroupID: groupID("beshared-groupid"), - ItemID: resourceID("storage-1", "itemid-1"), + ItemID: resourceID("provider-1", "storage-1", "itemid-1"), CTime: timestamp(10e8), }, CheckAuditEvent: func(t *testing.T, b []byte) { @@ -85,7 +85,7 @@ var testCases = []struct { Sharer: userID("sharing-userid"), GranteeUserID: nil, GranteeGroupID: groupID("beshared-groupid"), - ItemID: resourceID("storage-1", "itemid-1"), + ItemID: resourceID("provider-1", "storage-1", "itemid-1"), Permissions: sharePermissions("stat", "get_quota"), MTime: timestamp(10e8), Updated: "permissions", @@ -113,7 +113,7 @@ var testCases = []struct { SystemEvent: events.LinkUpdated{ ShareID: linkID("shareid"), Sharer: userID("sharing-userid"), - ItemID: resourceID("storage-1", "itemid-1"), + ItemID: resourceID("provider-1", "storage-1", "itemid-1"), Permissions: linkPermissions("stat"), CTime: timestamp(10e8), DisplayName: "link", @@ -203,7 +203,7 @@ var testCases = []struct { Alias: "Share accepted", SystemEvent: events.ReceivedShareUpdated{ ShareID: shareID("shareid"), - ItemID: resourceID("storageid-1", "itemid-1"), + ItemID: resourceID("provider-1", "storageid-1", "itemid-1"), Permissions: sharePermissions("get_quota"), GranteeUserID: userID("beshared-userid"), GranteeGroupID: nil, @@ -228,7 +228,7 @@ var testCases = []struct { Alias: "Share declined", SystemEvent: events.ReceivedShareUpdated{ ShareID: shareID("shareid"), - ItemID: resourceID("storageid-1", "itemid-1"), + ItemID: resourceID("provider-1", "storageid-1", "itemid-1"), Permissions: sharePermissions("get_quota"), GranteeUserID: userID("beshared-userid"), GranteeGroupID: nil, @@ -254,7 +254,7 @@ var testCases = []struct { SystemEvent: events.LinkAccessed{ ShareID: linkID("shareid"), Sharer: userID("sharing-userid"), - ItemID: resourceID("storage-1", "itemid-1"), + ItemID: resourceID("provider-1", "storage-1", "itemid-1"), Permissions: linkPermissions("stat"), DisplayName: "link", Expiration: timestamp(10e8 + 10e5), @@ -300,7 +300,7 @@ var testCases = []struct { Alias: "File created", SystemEvent: events.FileUploaded{ Executant: userID("uid-123"), - Ref: reference("sto-123", "iid-123", "./item"), + Ref: reference("pro-1", "sto-123", "iid-123", "./item"), Owner: userID("uid-123"), // NOTE: owner not yet implemented in reva }, CheckAuditEvent: func(t *testing.T, b []byte) { @@ -308,15 +308,15 @@ var testCases = []struct { require.NoError(t, json.Unmarshal(b, &ev)) // AuditEvent fields - checkBaseAuditEvent(t, ev.AuditEvent, "uid-123", "", "user 'uid-123' created file 'sto-123!iid-123/item'", "file_create") + checkBaseAuditEvent(t, ev.AuditEvent, "uid-123", "", "user 'uid-123' created file 'pro-1$sto-123!iid-123/item'", "file_create") // AuditEventSharing fields - checkFilesAuditEvent(t, ev.AuditEventFiles, "sto-123!iid-123/item", "uid-123", "./item") + checkFilesAuditEvent(t, ev.AuditEventFiles, "pro-1$sto-123!iid-123/item", "uid-123", "./item") }, }, { Alias: "File read", SystemEvent: events.FileDownloaded{ Executant: userID("uid-123"), - Ref: reference("sto-123", "iid-123", "./item"), + Ref: reference("pro-1", "sto-123", "iid-123", "./item"), Owner: userID("uid-123"), // NOTE: owner not yet implemented in reva }, CheckAuditEvent: func(t *testing.T, b []byte) { @@ -324,15 +324,15 @@ var testCases = []struct { require.NoError(t, json.Unmarshal(b, &ev)) // AuditEvent fields - checkBaseAuditEvent(t, ev.AuditEvent, "uid-123", "", "user 'uid-123' read file 'sto-123!iid-123/item'", "file_read") + checkBaseAuditEvent(t, ev.AuditEvent, "uid-123", "", "user 'uid-123' read file 'pro-1$sto-123!iid-123/item'", "file_read") // AuditEventSharing fields - checkFilesAuditEvent(t, ev.AuditEventFiles, "sto-123!iid-123/item", "uid-123", "./item") + checkFilesAuditEvent(t, ev.AuditEventFiles, "pro-1$sto-123!iid-123/item", "uid-123", "./item") }, }, { Alias: "File trashed", SystemEvent: events.ItemTrashed{ Executant: userID("uid-123"), - Ref: reference("sto-123", "iid-123", "./item"), + Ref: reference("pro-1", "sto-123", "iid-123", "./item"), Owner: userID("uid-123"), // NOTE: owner not yet implemented in reva }, CheckAuditEvent: func(t *testing.T, b []byte) { @@ -340,16 +340,16 @@ var testCases = []struct { require.NoError(t, json.Unmarshal(b, &ev)) // AuditEvent fields - checkBaseAuditEvent(t, ev.AuditEvent, "uid-123", "", "user 'uid-123' trashed file 'sto-123!iid-123/item'", "file_delete") + checkBaseAuditEvent(t, ev.AuditEvent, "uid-123", "", "user 'uid-123' trashed file 'pro-1$sto-123!iid-123/item'", "file_delete") // AuditEventSharing fields - checkFilesAuditEvent(t, ev.AuditEventFiles, "sto-123!iid-123/item", "uid-123", "./item") + checkFilesAuditEvent(t, ev.AuditEventFiles, "pro-1$sto-123!iid-123/item", "uid-123", "./item") }, }, { Alias: "File renamed", SystemEvent: events.ItemMoved{ Executant: userID("uid-123"), - Ref: reference("sto-123", "iid-123", "./item"), - OldReference: reference("sto-123", "iid-123", "./anotheritem"), + Ref: reference("pro-1", "sto-123", "iid-123", "./item"), + OldReference: reference("pro-1", "sto-123", "iid-123", "./anotheritem"), Owner: userID("uid-123"), // NOTE: owner not yet implemented in reva }, CheckAuditEvent: func(t *testing.T, b []byte) { @@ -357,9 +357,9 @@ var testCases = []struct { require.NoError(t, json.Unmarshal(b, &ev)) // AuditEvent fields - checkBaseAuditEvent(t, ev.AuditEvent, "uid-123", "", "user 'uid-123' moved file 'sto-123!iid-123/item' from './anotheritem' to './item'", "file_rename") + checkBaseAuditEvent(t, ev.AuditEvent, "uid-123", "", "user 'uid-123' moved file 'pro-1$sto-123!iid-123/item' from './anotheritem' to './item'", "file_rename") // AuditEventSharing fields - checkFilesAuditEvent(t, ev.AuditEventFiles, "sto-123!iid-123/item", "uid-123", "./item") + checkFilesAuditEvent(t, ev.AuditEventFiles, "pro-1$sto-123!iid-123/item", "uid-123", "./item") // AuditEventFileRenamed fields require.Equal(t, "./anotheritem", ev.OldPath) @@ -368,7 +368,7 @@ var testCases = []struct { Alias: "File purged", SystemEvent: events.ItemPurged{ Executant: userID("uid-123"), - Ref: reference("sto-123", "iid-123", "./item"), + Ref: reference("pro-1", "sto-123", "iid-123", "./item"), Owner: userID("uid-123"), // NOTE: owner not yet implemented in reva }, CheckAuditEvent: func(t *testing.T, b []byte) { @@ -376,17 +376,17 @@ var testCases = []struct { require.NoError(t, json.Unmarshal(b, &ev)) // AuditEvent fields - checkBaseAuditEvent(t, ev.AuditEvent, "uid-123", "", "user 'uid-123' removed file 'sto-123!iid-123/item' from trashbin", "file_trash_delete") + checkBaseAuditEvent(t, ev.AuditEvent, "uid-123", "", "user 'uid-123' removed file 'pro-1$sto-123!iid-123/item' from trashbin", "file_trash_delete") // AuditEventSharing fields - checkFilesAuditEvent(t, ev.AuditEventFiles, "sto-123!iid-123/item", "uid-123", "./item") + checkFilesAuditEvent(t, ev.AuditEventFiles, "pro-1$sto-123!iid-123/item", "uid-123", "./item") }, }, { Alias: "File restored", SystemEvent: events.ItemRestored{ Executant: userID("uid-123"), - Ref: reference("sto-123", "iid-123", "./item"), + Ref: reference("pro-1", "sto-123", "iid-123", "./item"), Owner: userID("uid-123"), // NOTE: owner not yet implemented in reva - OldReference: reference("sto-123", "sto-123!iid-123/item", "./oldpath"), + OldReference: reference("pro-1", "sto-123", "sto-123!iid-123/item", "./oldpath"), Key: "", }, CheckAuditEvent: func(t *testing.T, b []byte) { @@ -394,9 +394,9 @@ var testCases = []struct { require.NoError(t, json.Unmarshal(b, &ev)) // AuditEvent fields - checkBaseAuditEvent(t, ev.AuditEvent, "uid-123", "", "user 'uid-123' restored file 'sto-123!iid-123/item' from trashbin to './item'", "file_trash_restore") + checkBaseAuditEvent(t, ev.AuditEvent, "uid-123", "", "user 'uid-123' restored file 'pro-1$sto-123!iid-123/item' from trashbin to './item'", "file_trash_restore") // AuditEventSharing fields - checkFilesAuditEvent(t, ev.AuditEventFiles, "sto-123!iid-123/item", "uid-123", "./item") + checkFilesAuditEvent(t, ev.AuditEventFiles, "pro-1$sto-123!iid-123/item", "uid-123", "./item") // AuditEventFileRestored fields require.Equal(t, "./oldpath", ev.OldPath) @@ -405,7 +405,7 @@ var testCases = []struct { Alias: "File version restored", SystemEvent: events.FileVersionRestored{ Executant: userID("uid-123"), - Ref: reference("sto-123", "iid-123", "./item"), + Ref: reference("pro-1", "sto-123", "iid-123", "./item"), Owner: userID("uid-123"), // NOTE: owner not yet implemented in reva Key: "v1", }, @@ -414,9 +414,9 @@ var testCases = []struct { require.NoError(t, json.Unmarshal(b, &ev)) // AuditEvent fields - checkBaseAuditEvent(t, ev.AuditEvent, "uid-123", "", "user 'uid-123' restored file 'sto-123!iid-123/item' in version 'v1'", "file_version_restore") + checkBaseAuditEvent(t, ev.AuditEvent, "uid-123", "", "user 'uid-123' restored file 'pro-1$sto-123!iid-123/item' in version 'v1'", "file_version_restore") // AuditEventSharing fields - checkFilesAuditEvent(t, ev.AuditEventFiles, "sto-123!iid-123/item", "uid-123", "./item") + checkFilesAuditEvent(t, ev.AuditEventFiles, "pro-1$sto-123!iid-123/item", "uid-123", "./item") // AuditEventFileRestored fields require.Equal(t, "v1", ev.Key) @@ -427,7 +427,7 @@ var testCases = []struct { Executant: userID("uid-123"), ID: &provider.StorageSpaceId{OpaqueId: "space-123"}, Owner: userID("uid-123"), - Root: resourceID("sto-123", "iid-123"), + Root: resourceID("pro-1", "sto-123", "iid-123"), Name: "test-space", Type: "project", Quota: nil, // Quota not interesting atm @@ -443,7 +443,7 @@ var testCases = []struct { checkSpacesAuditEvent(t, ev.AuditEventSpaces, "space-123") // AuditEventFileRestored fields require.Equal(t, "uid-123", ev.Owner) - require.Equal(t, "sto-123!iid-123", ev.RootItem) + require.Equal(t, "pro-1$sto-123!iid-123", ev.RootItem) require.Equal(t, "test-space", ev.Name) require.Equal(t, "project", ev.Type) }, @@ -595,16 +595,17 @@ func groupID(id string) *group.GroupId { } } -func resourceID(sid, oid string) *provider.ResourceId { +func resourceID(sid, spid, oid string) *provider.ResourceId { return &provider.ResourceId{ StorageId: sid, + SpaceId: spid, OpaqueId: oid, } } -func reference(sid, oid, path string) *provider.Reference { +func reference(sid, spid, oid, path string) *provider.Reference { return &provider.Reference{ - ResourceId: resourceID(sid, oid), + ResourceId: resourceID(sid, spid, oid), Path: path, } } diff --git a/services/graph/pkg/service/v0/driveitems.go b/services/graph/pkg/service/v0/driveitems.go index 0307bdf006c..e49c3b832d9 100644 --- a/services/graph/pkg/service/v0/driveitems.go +++ b/services/graph/pkg/service/v0/driveitems.go @@ -113,7 +113,14 @@ func (g Graph) getRemoteItem(ctx context.Context, root *storageprovider.Resource return nil, err } - item.WebDavUrl = libregraph.PtrString(baseURL.String() + storagespace.FormatResourceID(*root)) + if baseURL != nil { + // TODO read from StorageSpace ... needs Opaque for now + // TODO how do we build the url? + // for now: read from request + webDavURL := *baseURL + webDavURL.Path = path.Join(webDavURL.Path, storagespace.FormatResourceID(*root)) + item.WebDavUrl = libregraph.PtrString(webDavURL.String()) + } return item, nil } @@ -231,7 +238,7 @@ func (g Graph) GetExtendedSpaceProperties(ctx context.Context, baseURL *url.URL, func (g Graph) getSpecialDriveItem(ctx context.Context, id storageprovider.ResourceId, itemName string, baseURL *url.URL, space *storageprovider.StorageSpace) *libregraph.DriveItem { var spaceItem *libregraph.DriveItem - if id.StorageId == "" && id.OpaqueId == "" { + if id.SpaceId == "" && id.OpaqueId == "" { return nil } diff --git a/services/graph/pkg/service/v0/drives.go b/services/graph/pkg/service/v0/drives.go index 956b5b6d705..9ec9984dbf8 100644 --- a/services/graph/pkg/service/v0/drives.go +++ b/services/graph/pkg/service/v0/drives.go @@ -285,18 +285,13 @@ func (g Graph) UpdateDrive(w http.ResponseWriter, r *http.Request) { root := &storageprovider.ResourceId{} - identifierParts := strings.Split(driveID, "!") - switch len(identifierParts) { - case 1: - _, sID := storagespace.SplitStorageID(identifierParts[0]) - root.StorageId, root.OpaqueId = identifierParts[0], sID - case 2: - root.StorageId, root.OpaqueId = identifierParts[0], identifierParts[1] - default: - errorcode.GeneralException.Render(w, r, http.StatusBadRequest, fmt.Sprintf("invalid resource id: %v", driveID)) + rid, err := storagespace.ParseID(driveID) + if err != nil { + errorcode.GeneralException.Render(w, r, http.StatusBadRequest, fmt.Sprintf("invalid resource id: %v", rid)) w.WriteHeader(http.StatusInternalServerError) return } + root = &rid client := g.GetGatewayClient() @@ -305,7 +300,7 @@ func (g Graph) UpdateDrive(w http.ResponseWriter, r *http.Request) { // the original storage space. StorageSpace: &storageprovider.StorageSpace{ Id: &storageprovider.StorageSpaceId{ - OpaqueId: root.StorageId + "!" + root.OpaqueId, + OpaqueId: storagespace.FormatResourceID(rid), }, Root: root, }, @@ -453,25 +448,15 @@ func (g Graph) ListStorageSpacesWithFilters(ctx context.Context, filters []*stor return res, err } -func generateSpaceId(id *storageprovider.ResourceId) (spaceID string) { - spaceID = id.GetStorageId() - // 2nd ID to compare is the opaque ID of the Space Root - spaceID2 := id.GetOpaqueId() - if strings.Contains(spaceID, "$") { - _, spaceID2 = storagespace.SplitStorageID(spaceID) - } - // Append opaqueID only if it is different from the spaceID2 - if id.OpaqueId != spaceID2 { - spaceID += "!" + id.OpaqueId - } - return spaceID -} - func (g Graph) cs3StorageSpaceToDrive(ctx context.Context, baseURL *url.URL, space *storageprovider.StorageSpace) (*libregraph.Drive, error) { if space.Root == nil { return nil, fmt.Errorf("space has no root") } - spaceID := generateSpaceId(space.Root) + spaceRid := *space.Root + if space.Root.GetSpaceId() == space.Root.GetOpaqueId() { + spaceRid.OpaqueId = "" + } + spaceID := storagespace.FormatResourceID(spaceRid) var permissions []libregraph.Permission if space.Opaque != nil { @@ -540,7 +525,7 @@ func (g Graph) cs3StorageSpaceToDrive(ctx context.Context, baseURL *url.URL, spa //"description": "string", // TODO read from StorageSpace ... needs Opaque for now DriveType: &space.SpaceType, Root: &libregraph.DriveItem{ - Id: libregraph.PtrString(storagespace.FormatResourceID(*space.Root)), + Id: libregraph.PtrString(storagespace.FormatResourceID(spaceRid)), Permissions: permissions, }, } @@ -548,9 +533,10 @@ func (g Graph) cs3StorageSpaceToDrive(ctx context.Context, baseURL *url.URL, spa var remoteItem *libregraph.RemoteItem grantID := storageprovider.ResourceId{ StorageId: utils.ReadPlainFromOpaque(space.Opaque, "grantStorageID"), + SpaceId: utils.ReadPlainFromOpaque(space.Opaque, "grantSpaceID"), OpaqueId: utils.ReadPlainFromOpaque(space.Opaque, "grantOpaqueID"), } - if grantID.StorageId != "" && grantID.OpaqueId != "" { + if grantID.SpaceId != "" && grantID.OpaqueId != "" { var err error remoteItem, err = g.getRemoteItem(ctx, &grantID, baseURL) if err != nil { @@ -625,11 +611,8 @@ func (g Graph) getDriveQuota(ctx context.Context, space *storageprovider.Storage req := &gateway.GetQuotaRequest{ Ref: &storageprovider.Reference{ - ResourceId: &storageprovider.ResourceId{ - StorageId: space.Root.StorageId, - OpaqueId: space.Root.OpaqueId, - }, - Path: ".", + ResourceId: space.Root, + Path: ".", }, } res, err := client.GetQuota(ctx, req) @@ -771,17 +754,9 @@ func (g Graph) DeleteDrive(w http.ResponseWriter, r *http.Request) { return } - root := &storageprovider.ResourceId{} - - identifierParts := strings.Split(driveID, "!") - _, sID := storagespace.SplitStorageID(identifierParts[0]) - switch len(identifierParts) { - case 1: - root.StorageId, root.OpaqueId = identifierParts[0], sID - case 2: - root.StorageId, root.OpaqueId = identifierParts[0], identifierParts[1] - default: - errorcode.GeneralException.Render(w, r, http.StatusBadRequest, fmt.Sprintf("invalid resource id: %v", driveID)) + rid, err := storagespace.ParseID(driveID) + if err != nil { + errorcode.GeneralException.Render(w, r, http.StatusBadRequest, fmt.Sprintf("invalid resource id: %v", rid)) w.WriteHeader(http.StatusInternalServerError) return } @@ -800,7 +775,7 @@ func (g Graph) DeleteDrive(w http.ResponseWriter, r *http.Request) { dRes, err := g.gatewayClient.DeleteStorageSpace(r.Context(), &storageprovider.DeleteStorageSpaceRequest{ Opaque: opaque, Id: &storageprovider.StorageSpaceId{ - OpaqueId: root.StorageId, + OpaqueId: storagespace.FormatResourceID(rid), }, }) if err != nil { diff --git a/services/graph/pkg/service/v0/graph_test.go b/services/graph/pkg/service/v0/graph_test.go index 9354449d7b5..0629e6ff674 100644 --- a/services/graph/pkg/service/v0/graph_test.go +++ b/services/graph/pkg/service/v0/graph_test.go @@ -76,7 +76,8 @@ var _ = Describe("Graph", func() { Id: &provider.StorageSpaceId{OpaqueId: "sameID"}, SpaceType: "aspacetype", Root: &provider.ResourceId{ - StorageId: "sameID", + StorageId: "pro-1", + SpaceId: "sameID", OpaqueId: "sameID", }, Name: "aspacename", @@ -102,11 +103,11 @@ var _ = Describe("Graph", func() { "value":[ { "driveType":"aspacetype", - "id":"sameID", + "id":"pro-1$sameID", "name":"aspacename", "root":{ - "id":"sameID!sameID", - "webDavUrl":"https://localhost:9200/dav/spaces/sameID" + "id":"pro-1$sameID", + "webDavUrl":"https://localhost:9200/dav/spaces/pro-1$sameID" } } ] @@ -121,7 +122,8 @@ var _ = Describe("Graph", func() { Id: &provider.StorageSpaceId{OpaqueId: "bsameID"}, SpaceType: "bspacetype", Root: &provider.ResourceId{ - StorageId: "bsameID", + StorageId: "pro-1", + SpaceId: "bsameID", OpaqueId: "bsameID", }, Name: "bspacename", @@ -136,7 +138,8 @@ var _ = Describe("Graph", func() { Id: &provider.StorageSpaceId{OpaqueId: "asameID"}, SpaceType: "aspacetype", Root: &provider.ResourceId{ - StorageId: "asameID", + StorageId: "pro-1", + SpaceId: "asameID", OpaqueId: "asameID", }, Name: "aspacename", @@ -169,23 +172,23 @@ var _ = Describe("Graph", func() { { "driveAlias":"aspacetype/aspacename", "driveType":"aspacetype", - "id":"asameID", + "id":"pro-1$asameID", "name":"aspacename", "root":{ "eTag":"101112131415", - "id":"asameID!asameID", - "webDavUrl":"https://localhost:9200/dav/spaces/asameID" + "id":"pro-1$asameID", + "webDavUrl":"https://localhost:9200/dav/spaces/pro-1$asameID" } }, { "driveAlias":"bspacetype/bspacename", "driveType":"bspacetype", - "id":"bsameID", + "id":"pro-1$bsameID", "name":"bspacename", "root":{ "eTag":"123456789", - "id":"bsameID!bsameID", - "webDavUrl":"https://localhost:9200/dav/spaces/bsameID" + "id":"pro-1$bsameID", + "webDavUrl":"https://localhost:9200/dav/spaces/pro-1$bsameID" } } ] @@ -197,10 +200,11 @@ var _ = Describe("Graph", func() { Status: status.NewOK(ctx), StorageSpaces: []*provider.StorageSpace{ { - Id: &provider.StorageSpaceId{OpaqueId: "aID!differentID"}, + Id: &provider.StorageSpaceId{OpaqueId: "prID$aID!differentID"}, SpaceType: "mountpoint", Root: &provider.ResourceId{ - StorageId: "prID$aID", + StorageId: "prID", + SpaceId: "aID", OpaqueId: "differentID", }, Name: "New Folder", @@ -209,6 +213,7 @@ var _ = Describe("Graph", func() { "spaceAlias": {Decoder: "plain", Value: []byte("mountpoint/new-folder")}, "etag": {Decoder: "plain", Value: []byte("101112131415")}, "grantStorageID": {Decoder: "plain", Value: []byte("ownerStorageID")}, + "grantSpaceID": {Decoder: "plain", Value: []byte("spaceID")}, "grantOpaqueID": {Decoder: "plain", Value: []byte("opaqueID")}, }, }, @@ -220,7 +225,7 @@ var _ = Describe("Graph", func() { Info: &provider.ResourceInfo{ Etag: "123456789", Type: provider.ResourceType_RESOURCE_TYPE_CONTAINER, - Id: &provider.ResourceId{StorageId: "ownerStorageID", OpaqueId: "opaqueID"}, + Id: &provider.ResourceId{StorageId: "ownerStorageID", SpaceId: "spaceID", OpaqueId: "opaqueID"}, Path: "New Folder", Mtime: &typesv1beta1.Timestamp{Seconds: 1648327606, Nanos: 0}, Size: uint64(1234), @@ -252,12 +257,12 @@ var _ = Describe("Graph", func() { Expect(*value.Root.ETag).To(Equal("101112131415")) Expect(*value.Root.Id).To(Equal("prID$aID!differentID")) Expect(*value.Root.RemoteItem.ETag).To(Equal("123456789")) - Expect(*value.Root.RemoteItem.Id).To(Equal("ownerStorageID!opaqueID")) + Expect(*value.Root.RemoteItem.Id).To(Equal("ownerStorageID$spaceID!opaqueID")) Expect(value.Root.RemoteItem.LastModifiedDateTime.UTC()).To(Equal(time.Unix(1648327606, 0).UTC())) Expect(*value.Root.RemoteItem.Folder).To(Equal(libregraph.Folder{})) Expect(*value.Root.RemoteItem.Name).To(Equal("New Folder")) Expect(*value.Root.RemoteItem.Size).To(Equal(int64(1234))) - Expect(*value.Root.RemoteItem.WebDavUrl).To(Equal("https://localhost:9200/dav/spaces/ownerStorageID!opaqueID")) + Expect(*value.Root.RemoteItem.WebDavUrl).To(Equal("https://localhost:9200/dav/spaces/ownerStorageID$spaceID%21opaqueID")) }) It("can not list spaces with wrong sort parameter", func() { gatewayClient.On("ListStorageSpaces", mock.Anything, mock.Anything).Return(&provider.ListStorageSpacesResponse{ diff --git a/services/search/pkg/search/index/index.go b/services/search/pkg/search/index/index.go index 7ad01074087..345a3433583 100644 --- a/services/search/pkg/search/index/index.go +++ b/services/search/pkg/search/index/index.go @@ -33,6 +33,7 @@ import ( "github.com/blevesearch/bleve/v2/analysis/token/lowercase" "github.com/blevesearch/bleve/v2/analysis/tokenizer/single" "github.com/blevesearch/bleve/v2/mapping" + "github.com/cs3org/reva/v2/pkg/storagespace" "google.golang.org/protobuf/types/known/timestamppb" sprovider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1" @@ -218,7 +219,11 @@ func (i *Index) Search(ctx context.Context, req *searchsvc.SearchIndexRequest) ( query := bleve.NewConjunctionQuery( bleve.NewQueryStringQuery(req.Query), deletedQuery, // Skip documents that have been marked as deleted - bleve.NewQueryStringQuery("RootID:"+req.Ref.ResourceId.StorageId+"!"+req.Ref.ResourceId.OpaqueId), // Limit search to the space + bleve.NewQueryStringQuery("RootID:"+idToBleveId(&sprovider.ResourceId{ + StorageId: req.Ref.GetResourceId().GetStorageId(), + SpaceId: req.Ref.GetResourceId().GetSpaceId(), + OpaqueId: req.Ref.GetResourceId().GetOpaqueId(), + })), // Limit search to the space bleve.NewQueryStringQuery("Path:"+queryEscape(utils.MakeRelativePath(path.Join(req.Ref.Path, "/"))+"*")), // Limit search to this directory in the space ) bleveReq := bleve.NewSearchRequest(query) @@ -307,22 +312,22 @@ func fieldsToEntity(fields map[string]interface{}) *indexDocument { } func fromFields(fields map[string]interface{}) (*searchmsg.Match, error) { - rootIDParts := strings.SplitN(fields["RootID"].(string), "!", 2) - IDParts := strings.SplitN(fields["ID"].(string), "!", 2) + rootID, err := storagespace.ParseID(fields["RootID"].(string)) + if err != nil { + return nil, err + } + rID, err := storagespace.ParseID(fields["ID"].(string)) + if err != nil { + return nil, err + } match := &searchmsg.Match{ Entity: &searchmsg.Entity{ Ref: &searchmsg.Reference{ - ResourceId: &searchmsg.ResourceID{ - StorageId: rootIDParts[0], - OpaqueId: rootIDParts[1], - }, - Path: fields["Path"].(string), - }, - Id: &searchmsg.ResourceID{ - StorageId: IDParts[0], - OpaqueId: IDParts[1], + ResourceId: resourceIDtoSearchID(rootID), + Path: fields["Path"].(string), }, + Id: resourceIDtoSearchID(rID), Name: fields["Name"].(string), Size: uint64(fields["Size"].(float64)), Type: uint64(fields["Type"].(float64)), @@ -342,7 +347,14 @@ func idToBleveId(id *sprovider.ResourceId) string { if id == nil { return "" } - return id.StorageId + "!" + id.OpaqueId + return storagespace.FormatResourceID(*id) +} + +func resourceIDtoSearchID(id sprovider.ResourceId) *searchmsg.ResourceID { + return &searchmsg.ResourceID{ + StorageId: id.GetStorageId(), + SpaceId: id.GetSpaceId(), + OpaqueId: id.GetOpaqueId()} } func queryEscape(s string) string { diff --git a/services/search/pkg/search/index/index_test.go b/services/search/pkg/search/index/index_test.go index cbc77cf16a9..368c7049796 100644 --- a/services/search/pkg/search/index/index_test.go +++ b/services/search/pkg/search/index/index_test.go @@ -21,7 +21,8 @@ var _ = Describe("Index", func() { ctx context.Context rootId = &sprovider.ResourceId{ - StorageId: "storageid", + StorageId: "provider-1", + SpaceId: "spaceid", OpaqueId: "rootopaqueid", } filename string @@ -33,7 +34,8 @@ var _ = Describe("Index", func() { } parentRi = &sprovider.ResourceInfo{ Id: &sprovider.ResourceId{ - StorageId: "storageid", + StorageId: "provider-1", + SpaceId: "spaceid", OpaqueId: "parentopaqueid", }, Path: "sub d!r", @@ -47,11 +49,13 @@ var _ = Describe("Index", func() { } childRi = &sprovider.ResourceInfo{ Id: &sprovider.ResourceId{ - StorageId: "storageid", + StorageId: "provider-1", + SpaceId: "spaceid", OpaqueId: "childopaqueid", }, ParentId: &sprovider.ResourceId{ - StorageId: "storageid", + StorageId: "provider-1", + SpaceId: "spaceid", OpaqueId: "parentopaqueid", }, Path: "child.pdf", @@ -65,7 +69,8 @@ var _ = Describe("Index", func() { Query: query, Ref: &searchmsg.Reference{ ResourceId: &searchmsg.ResourceID{ - StorageId: rootId.StorageId, + StorageId: "provider-1", + SpaceId: rootId.SpaceId, OpaqueId: rootId.OpaqueId, }, }, @@ -96,11 +101,13 @@ var _ = Describe("Index", func() { } ri = &sprovider.ResourceInfo{ Id: &sprovider.ResourceId{ - StorageId: "storageid", + StorageId: "provider-1", + SpaceId: "spaceid", OpaqueId: "opaqueid", }, ParentId: &sprovider.ResourceId{ - StorageId: "storageid", + StorageId: "provider-1", + SpaceId: "spaceid", OpaqueId: "someopaqueid", }, Path: filename, @@ -172,7 +179,8 @@ var _ = Describe("Index", func() { It("scopes the search to the specified space", func() { resourceId := &sprovider.ResourceId{ - StorageId: "differentstorageid", + StorageId: "provider-1", + SpaceId: "differentspaceid", OpaqueId: "differentopaqueid", } assertDocCount(resourceId, `Name:foo.pdf`, 0) @@ -222,14 +230,16 @@ var _ = Describe("Index", func() { BeforeEach(func() { nestedRef = &sprovider.Reference{ ResourceId: &sprovider.ResourceId{ - StorageId: "storageid", + StorageId: "provider-1", + SpaceId: "spaceid", OpaqueId: "rootopaqueid", }, Path: "./nested/nestedpdf.pdf", } nestedRI = &sprovider.ResourceInfo{ Id: &sprovider.ResourceId{ - StorageId: "storageid", + StorageId: "provider-1", + SpaceId: "spaceid", OpaqueId: "nestedopaqueid", }, Path: "nestedpdf.pdf", @@ -251,6 +261,7 @@ var _ = Describe("Index", func() { Ref: &searchmsg.Reference{ ResourceId: &searchmsg.ResourceID{ StorageId: ref.ResourceId.StorageId, + SpaceId: ref.ResourceId.SpaceId, OpaqueId: ref.ResourceId.OpaqueId, }, Path: "./nested/", diff --git a/services/search/pkg/search/provider/searchprovider.go b/services/search/pkg/search/provider/searchprovider.go index d82c7246397..f19bed80692 100644 --- a/services/search/pkg/search/provider/searchprovider.go +++ b/services/search/pkg/search/provider/searchprovider.go @@ -92,6 +92,7 @@ func (p *Provider) Search(ctx context.Context, req *searchsvc.SearchRequest) (*s opaqueMap := sdk.DecodeOpaqueMap(space.Opaque) grantSpaceId := storagespace.FormatResourceID(provider.ResourceId{ StorageId: opaqueMap["grantStorageID"], + SpaceId: opaqueMap["grantSpaceID"], OpaqueId: opaqueMap["grantOpaqueID"], }) mountpointMap[grantSpaceId] = space.Id.OpaqueId @@ -122,25 +123,26 @@ func (p *Provider) Search(ctx context.Context, req *searchsvc.SearchRequest) (*s continue } mountpointPrefix = utils.MakeRelativePath(gpRes.Path) - sid, oid, err := storagespace.SplitID(mountpointId) + sid, spid, oid, err := storagespace.SplitID(mountpointId) if err != nil { p.logger.Error().Err(err).Str("space", space.Id.OpaqueId).Str("mountpointId", mountpointId).Msg("invalid mountpoint space id") continue } mountpointRootId = &searchmsg.ResourceID{ StorageId: sid, + SpaceId: spid, OpaqueId: oid, } p.logger.Debug().Interface("grantSpace", space).Interface("mountpointRootId", mountpointRootId).Msg("searching a grant") } - _, rootStorageID := storagespace.SplitStorageID(space.Root.StorageId) res, err := p.indexClient.Search(ctx, &searchsvc.SearchIndexRequest{ Query: formatQuery(req.Query), Ref: &searchmsg.Reference{ ResourceId: &searchmsg.ResourceID{ StorageId: space.Root.StorageId, - OpaqueId: rootStorageID, + SpaceId: space.Root.SpaceId, + OpaqueId: space.Root.OpaqueId, }, Path: mountpointPrefix, }, @@ -197,14 +199,18 @@ func (p *Provider) IndexSpace(ctx context.Context, req *searchsvc.IndexSpaceRequ // Walk the space and index all files walker := walker.NewWalker(p.gwClient) - rootId := &provider.ResourceId{StorageId: req.SpaceId, OpaqueId: req.SpaceId} - err = walker.Walk(ownerCtx, rootId, func(wd string, info *provider.ResourceInfo, err error) error { + rootId, err := storagespace.ParseID(req.SpaceId) + if err != nil { + p.logger.Error().Err(err).Msg(err.Error()) + return nil, err + } + err = walker.Walk(ownerCtx, &rootId, func(wd string, info *provider.ResourceInfo, err error) error { if err != nil { p.logger.Error().Err(err).Msg("error walking the tree") } ref := &provider.Reference{ Path: utils.MakeRelativePath(filepath.Join(wd, info.Path)), - ResourceId: rootId, + ResourceId: &rootId, } err = p.indexClient.Add(ref, info) if err != nil { diff --git a/tests/acceptance/features/bootstrap/SpacesContext.php b/tests/acceptance/features/bootstrap/SpacesContext.php index df291e845f1..7c8bcac7d0b 100644 --- a/tests/acceptance/features/bootstrap/SpacesContext.php +++ b/tests/acceptance/features/bootstrap/SpacesContext.php @@ -389,7 +389,7 @@ public function deleteAllSpacesOfTheType(string $driveType): void { $userAdmin = $this->featureContext->getAdminUsername(); for ($i = 0; $i < 2; ++$i) { - $this->theUserListsAllHisAvailableSpacesUsingTheGraphApi( + $this->theUserListsAllAvailableSpacesUsingTheGraphApi( $userAdmin, $query ); @@ -593,17 +593,19 @@ public function theUserListsAllHisAvailableSpacesUsingTheGraphApi(string $user, /** * * @param string $user + * @param string $query * * @return void * * @throws GuzzleException * @throws Exception */ - public function theUserListsAllAvailableSpacesUsingTheGraphApi(string $user): void { + public function theUserListsAllAvailableSpacesUsingTheGraphApi(string $user, string $query = ''): void { $this->featureContext->setResponse( $this->listAllSpacesRequest( $user, - $this->featureContext->getPasswordForUser($user) + $this->featureContext->getPasswordForUser($user), + "?" . $query ) ); $this->rememberTheAvailableSpaces(); @@ -2366,7 +2368,7 @@ public function downloadVersionOfTheFile( ); } $url = $this->baseUrl . $fileVersion[$index][0]; - + $this->featureContext->setResponse( HttpRequestHelper::sendRequest( $url, From f02e0c833e597cc147cd907b63ffc4253bd97853 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Mon, 11 Jul 2022 11:32:10 +0000 Subject: [PATCH 2/9] add missing storageid MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jörn Friedrich Dreyer --- services/webdav/pkg/dav/requests/thumbnail.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/services/webdav/pkg/dav/requests/thumbnail.go b/services/webdav/pkg/dav/requests/thumbnail.go index 4f8d5036c72..0c703d37253 100644 --- a/services/webdav/pkg/dav/requests/thumbnail.go +++ b/services/webdav/pkg/dav/requests/thumbnail.go @@ -7,6 +7,9 @@ import ( "path/filepath" "strconv" + providerv1beta1 "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1" + "github.com/cs3org/reva/v2/pkg/storagespace" + "github.com/cs3org/reva/v2/pkg/utils" "github.com/go-chi/chi/v5" "github.com/owncloud/ocis/v2/services/webdav/pkg/constants" @@ -37,6 +40,15 @@ type ThumbnailRequest struct { Identifier string } +func addMissingStorageID(id string) string { + rid := providerv1beta1.ResourceId{} + rid.StorageId, rid.SpaceId, rid.OpaqueId, _ = storagespace.SplitID(id) + if rid.StorageId == "" && rid.SpaceId == utils.ShareStorageSpaceID { + rid.StorageId = utils.ShareStorageProviderID + } + return storagespace.FormatResourceID(rid) +} + // ParseThumbnailRequest extracts all required parameters from a http request. func ParseThumbnailRequest(r *http.Request) (*ThumbnailRequest, error) { ctx := r.Context() @@ -46,7 +58,7 @@ func ParseThumbnailRequest(r *http.Request) (*ThumbnailRequest, error) { id := "" v := ctx.Value(constants.ContextKeyID) if v != nil { - id = v.(string) + id = addMissingStorageID(v.(string)) } q := r.URL.Query() From 18039ff394e79d00ebdf93654fa294ca63846303 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Mon, 11 Jul 2022 11:52:45 +0000 Subject: [PATCH 3/9] update to cb988d5dfb11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jörn Friedrich Dreyer --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 606d19be4ec..6428fe965dc 100644 --- a/go.mod +++ b/go.mod @@ -267,4 +267,4 @@ require ( stash.kopano.io/kgol/kcc-go/v5 v5.0.1 // indirect ) -replace github.com/cs3org/reva/v2 => github.com/micbar/reva/v2 v2.0.0-20220711074018-2773fa144658 +replace github.com/cs3org/reva/v2 => github.com/micbar/reva/v2 v2.0.0-20220711114725-cb988d5dfb11 diff --git a/go.sum b/go.sum index 49c5eeacca3..4d00856b967 100644 --- a/go.sum +++ b/go.sum @@ -889,8 +889,8 @@ github.com/maxymania/go-system v0.0.0-20170110133659-647cc364bf0b h1:Q53idHrTuQD github.com/maxymania/go-system v0.0.0-20170110133659-647cc364bf0b/go.mod h1:KirJrATYGbTyUwVR26xIkaipRqRcMRXBf8N5dacvGus= github.com/mendsley/gojwk v0.0.0-20141217222730-4d5ec6e58103 h1:Z/i1e+gTZrmcGeZyWckaLfucYG6KYOXLWo4co8pZYNY= github.com/mendsley/gojwk v0.0.0-20141217222730-4d5ec6e58103/go.mod h1:o9YPB5aGP8ob35Vy6+vyq3P3bWe7NQWzf+JLiXCiMaE= -github.com/micbar/reva/v2 v2.0.0-20220711074018-2773fa144658 h1:M/zjKqRtCNEDRNGkwS3stnA+11pfuqccBZ4Z5tRKsrc= -github.com/micbar/reva/v2 v2.0.0-20220711074018-2773fa144658/go.mod h1:GlPiCJmt6nDrbPm6lL7pShonSUZ0Ld2GLtR+lATjLCE= +github.com/micbar/reva/v2 v2.0.0-20220711114725-cb988d5dfb11 h1:PwUWM1IV582lAFHm6jvkny8qokBWkt9Z0Va0s24vmL8= +github.com/micbar/reva/v2 v2.0.0-20220711114725-cb988d5dfb11/go.mod h1:GlPiCJmt6nDrbPm6lL7pShonSUZ0Ld2GLtR+lATjLCE= github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= github.com/miekg/dns v1.1.26/go.mod h1:bPDLeHnStXmXAq1m/Ch/hvfNHr14JKNPMBo3VZKjuso= github.com/miekg/dns v1.1.40/go.mod h1:KNUDUusw/aVsxyTYZM1oqvCicbwhgbNgztCETuNZ7xM= From 1e4d28e8c0d22b98f4322511e730d21736818b57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Mon, 11 Jul 2022 13:24:33 +0000 Subject: [PATCH 4/9] update reva to b9df4027992b MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jörn Friedrich Dreyer --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index ca365281e19..cd94f5104c3 100644 --- a/go.mod +++ b/go.mod @@ -267,4 +267,4 @@ require ( stash.kopano.io/kgol/kcc-go/v5 v5.0.1 // indirect ) -replace github.com/cs3org/reva/v2 => github.com/micbar/reva/v2 v2.0.0-20220711114725-cb988d5dfb11 +replace github.com/cs3org/reva/v2 => github.com/micbar/reva/v2 v2.0.0-20220711131809-b9df4027992b diff --git a/go.sum b/go.sum index c0ad8105be0..c82b0679675 100644 --- a/go.sum +++ b/go.sum @@ -889,8 +889,8 @@ github.com/maxymania/go-system v0.0.0-20170110133659-647cc364bf0b h1:Q53idHrTuQD github.com/maxymania/go-system v0.0.0-20170110133659-647cc364bf0b/go.mod h1:KirJrATYGbTyUwVR26xIkaipRqRcMRXBf8N5dacvGus= github.com/mendsley/gojwk v0.0.0-20141217222730-4d5ec6e58103 h1:Z/i1e+gTZrmcGeZyWckaLfucYG6KYOXLWo4co8pZYNY= github.com/mendsley/gojwk v0.0.0-20141217222730-4d5ec6e58103/go.mod h1:o9YPB5aGP8ob35Vy6+vyq3P3bWe7NQWzf+JLiXCiMaE= -github.com/micbar/reva/v2 v2.0.0-20220711114725-cb988d5dfb11 h1:PwUWM1IV582lAFHm6jvkny8qokBWkt9Z0Va0s24vmL8= -github.com/micbar/reva/v2 v2.0.0-20220711114725-cb988d5dfb11/go.mod h1:GlPiCJmt6nDrbPm6lL7pShonSUZ0Ld2GLtR+lATjLCE= +github.com/micbar/reva/v2 v2.0.0-20220711131809-b9df4027992b h1:rGosXQ9AwUVLxmmGbe1AN+YBk6OF7xnMxGzE2sALhJs= +github.com/micbar/reva/v2 v2.0.0-20220711131809-b9df4027992b/go.mod h1:GlPiCJmt6nDrbPm6lL7pShonSUZ0Ld2GLtR+lATjLCE= github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= github.com/miekg/dns v1.1.26/go.mod h1:bPDLeHnStXmXAq1m/Ch/hvfNHr14JKNPMBo3VZKjuso= github.com/miekg/dns v1.1.40/go.mod h1:KNUDUusw/aVsxyTYZM1oqvCicbwhgbNgztCETuNZ7xM= From 761a09247c713d74a6b6615760f0f889e4d26f36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Tue, 12 Jul 2022 08:58:55 +0000 Subject: [PATCH 5/9] log owner when machine auth fails MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jörn Friedrich Dreyer --- services/search/pkg/search/provider/events.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/services/search/pkg/search/provider/events.go b/services/search/pkg/search/provider/events.go index 37c62c237f9..b68a13a418a 100644 --- a/services/search/pkg/search/provider/events.go +++ b/services/search/pkg/search/provider/events.go @@ -147,14 +147,14 @@ func (p *Provider) getAuthContext(owner *user.User) (context.Context, error) { ownerCtx := ctxpkg.ContextSetUser(context.Background(), owner) authRes, err := p.gwClient.Authenticate(ownerCtx, &gateway.AuthenticateRequest{ Type: "machine", - ClientId: "userid:" + owner.Id.OpaqueId, + ClientId: "userid:" + owner.GetId().GetOpaqueId(), ClientSecret: p.machineAuthAPIKey, }) if err == nil && authRes.GetStatus().GetCode() != rpc.Code_CODE_OK { err = errtypes.NewErrtypeFromStatus(authRes.Status) } if err != nil { - p.logger.Error().Err(err).Interface("authRes", authRes).Msg("error using machine auth") + p.logger.Error().Err(err).Interface("owner", owner).Interface("authRes", authRes).Msg("error using machine auth") return nil, err } return metadata.AppendToOutgoingContext(ownerCtx, ctxpkg.TokenHeader, authRes.Token), nil From 2b6f52a2c50a5555a46285d06cb1aca164a55b10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Tue, 12 Jul 2022 09:00:43 +0000 Subject: [PATCH 6/9] update reva to 2832f4d MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jörn Friedrich Dreyer --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index cd94f5104c3..69794ba38b6 100644 --- a/go.mod +++ b/go.mod @@ -267,4 +267,4 @@ require ( stash.kopano.io/kgol/kcc-go/v5 v5.0.1 // indirect ) -replace github.com/cs3org/reva/v2 => github.com/micbar/reva/v2 v2.0.0-20220711131809-b9df4027992b +replace github.com/cs3org/reva/v2 => github.com/micbar/reva/v2 v2.0.0-20220712083851-2832f4d5031e diff --git a/go.sum b/go.sum index c82b0679675..872ab45a2cf 100644 --- a/go.sum +++ b/go.sum @@ -889,8 +889,8 @@ github.com/maxymania/go-system v0.0.0-20170110133659-647cc364bf0b h1:Q53idHrTuQD github.com/maxymania/go-system v0.0.0-20170110133659-647cc364bf0b/go.mod h1:KirJrATYGbTyUwVR26xIkaipRqRcMRXBf8N5dacvGus= github.com/mendsley/gojwk v0.0.0-20141217222730-4d5ec6e58103 h1:Z/i1e+gTZrmcGeZyWckaLfucYG6KYOXLWo4co8pZYNY= github.com/mendsley/gojwk v0.0.0-20141217222730-4d5ec6e58103/go.mod h1:o9YPB5aGP8ob35Vy6+vyq3P3bWe7NQWzf+JLiXCiMaE= -github.com/micbar/reva/v2 v2.0.0-20220711131809-b9df4027992b h1:rGosXQ9AwUVLxmmGbe1AN+YBk6OF7xnMxGzE2sALhJs= -github.com/micbar/reva/v2 v2.0.0-20220711131809-b9df4027992b/go.mod h1:GlPiCJmt6nDrbPm6lL7pShonSUZ0Ld2GLtR+lATjLCE= +github.com/micbar/reva/v2 v2.0.0-20220712083851-2832f4d5031e h1:pg0HwOJXvCQfikOnHGXN0ImfYjC4MvuaT47OzYtcMqE= +github.com/micbar/reva/v2 v2.0.0-20220712083851-2832f4d5031e/go.mod h1:GlPiCJmt6nDrbPm6lL7pShonSUZ0Ld2GLtR+lATjLCE= github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= github.com/miekg/dns v1.1.26/go.mod h1:bPDLeHnStXmXAq1m/Ch/hvfNHr14JKNPMBo3VZKjuso= github.com/miekg/dns v1.1.40/go.mod h1:KNUDUusw/aVsxyTYZM1oqvCicbwhgbNgztCETuNZ7xM= From 66b62ab3e17ac2ae452ec2256a7ed235a3964ef0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Tue, 12 Jul 2022 09:04:28 +0000 Subject: [PATCH 7/9] cat generated config in drone for debugging MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jörn Friedrich Dreyer --- .drone.star | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.drone.star b/.drone.star index 0f1b0213912..7cae6f2d60c 100644 --- a/.drone.star +++ b/.drone.star @@ -1647,6 +1647,7 @@ def ocisServer(storage, accounts_hash_difficulty = 4, volumes = [], depends_on = user = "0:0" environment = { "OCIS_URL": OCIS_URL, + "OCIS_CONFIG_DIR": "/root/.ocis/config", "GATEWAY_GRPC_ADDR": "0.0.0.0:9142", # cs3api-validator needs the cs3api gatway exposed "STORAGE_USERS_DRIVER": "%s" % (storage), "STORAGE_USERS_DRIVER_LOCAL_ROOT": "/srv/app/tmp/ocis/local/root", @@ -1743,6 +1744,7 @@ def ocisServer(storage, accounts_hash_difficulty = 4, volumes = [], depends_on = "user": user, "commands": [ "ocis/bin/ocis init --insecure true", + "cat $OCIS_CONFIG_DIR/ocis.yaml", "ocis/bin/ocis server", ], "volumes": volumes, From b67d41868b1ef0b7144ba1725b7ccf2f3562811a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Tue, 12 Jul 2022 10:02:02 +0000 Subject: [PATCH 8/9] update expected failures MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jörn Friedrich Dreyer --- tests/acceptance/expected-failures-API-on-OCIS-storage.md | 6 ------ 1 file changed, 6 deletions(-) diff --git a/tests/acceptance/expected-failures-API-on-OCIS-storage.md b/tests/acceptance/expected-failures-API-on-OCIS-storage.md index c213afa4f7f..04cdd0c517c 100644 --- a/tests/acceptance/expected-failures-API-on-OCIS-storage.md +++ b/tests/acceptance/expected-failures-API-on-OCIS-storage.md @@ -1482,12 +1482,6 @@ Not everything needs to be implemented for ocis. While the oc10 testsuite covers - [apiShareManagementToShares/moveShareInsideAnotherShare.feature:86](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiShareManagementToShares/moveShareInsideAnotherShare.feature#L86) - [apiShareManagementToShares/moveShareInsideAnotherShare.feature:100](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiShareManagementToShares/moveShareInsideAnotherShare.feature#L100) -#### [TUS upload file with invalid name sends false response](https://github.com/owncloud/ocis/issues/3050) - -- [apiWebdavUploadTUS/uploadFile.feature:215](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiWebdavUploadTUS/uploadFile.feature#L215) -- [apiWebdavUploadTUS/uploadFile.feature:216](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiWebdavUploadTUS/uploadFile.feature#L216) -- [apiWebdavUploadTUS/uploadFile.feature:218](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiWebdavUploadTUS/uploadFile.feature#L218) - #### [unable to create resource using TUS inside Shares dir](https://github.com/owncloud/ocis/issues/3048) - [apiWebdavUploadTUS/uploadFileMtimeShares.feature:33](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiWebdavUploadTUS/uploadFileMtimeShares.feature#L33) From f7a6c08cad2654c78c5fa6ad143f6f75bf7055ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Tue, 12 Jul 2022 11:42:25 +0000 Subject: [PATCH 9/9] update reva to 66029006fc69 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jörn Friedrich Dreyer --- go.mod | 4 +--- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/go.mod b/go.mod index 69794ba38b6..65e080619d3 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,7 @@ require ( github.com/blevesearch/bleve_index_api v1.0.2 github.com/coreos/go-oidc/v3 v3.2.0 github.com/cs3org/go-cs3apis v0.0.0-20220621145831-c38cca0796c2 - github.com/cs3org/reva/v2 v2.0.0-00010101000000-000000000000 + github.com/cs3org/reva/v2 v2.6.2-0.20220712113935-66029006fc69 github.com/disintegration/imaging v1.6.2 github.com/ggwhite/go-masker v1.0.9 github.com/go-chi/chi/v5 v5.0.7 @@ -266,5 +266,3 @@ require ( gopkg.in/yaml.v3 v3.0.1 // indirect stash.kopano.io/kgol/kcc-go/v5 v5.0.1 // indirect ) - -replace github.com/cs3org/reva/v2 => github.com/micbar/reva/v2 v2.0.0-20220712083851-2832f4d5031e diff --git a/go.sum b/go.sum index 872ab45a2cf..d78363f881d 100644 --- a/go.sum +++ b/go.sum @@ -299,6 +299,8 @@ github.com/crewjam/saml v0.4.6/go.mod h1:ZBOXnNPFzB3CgOkRm7Nd6IVdkG+l/wF+0ZXLqD9 github.com/cs3org/cato v0.0.0-20200828125504-e418fc54dd5e/go.mod h1:XJEZ3/EQuI3BXTp/6DUzFr850vlxq11I6satRtz0YQ4= github.com/cs3org/go-cs3apis v0.0.0-20220621145831-c38cca0796c2 h1:o/ovJzS4pyL/rZgp0MtC4Q7JIle5DikimilTLBw2TjY= github.com/cs3org/go-cs3apis v0.0.0-20220621145831-c38cca0796c2/go.mod h1:UXha4TguuB52H14EMoSsCqDj7k8a/t7g4gVP+bgY5LY= +github.com/cs3org/reva/v2 v2.6.2-0.20220712113935-66029006fc69 h1:5qArWHDuCM86+X1CkC7ca7sJ3YIjGvZiFRqRusKgxlA= +github.com/cs3org/reva/v2 v2.6.2-0.20220712113935-66029006fc69/go.mod h1:GlPiCJmt6nDrbPm6lL7pShonSUZ0Ld2GLtR+lATjLCE= github.com/cubewise-code/go-mime v0.0.0-20200519001935-8c5762b177d8 h1:Z9lwXumT5ACSmJ7WGnFl+OMLLjpz5uR2fyz7dC255FI= github.com/cubewise-code/go-mime v0.0.0-20200519001935-8c5762b177d8/go.mod h1:4abs/jPXcmJzYoYGF91JF9Uq9s/KL5n1jvFDix8KcqY= github.com/cyberdelia/templates v0.0.0-20141128023046-ca7fffd4298c/go.mod h1:GyV+0YP4qX0UQ7r2MoYZ+AvYDp12OF5yg4q8rGnyNh4= @@ -889,8 +891,6 @@ github.com/maxymania/go-system v0.0.0-20170110133659-647cc364bf0b h1:Q53idHrTuQD github.com/maxymania/go-system v0.0.0-20170110133659-647cc364bf0b/go.mod h1:KirJrATYGbTyUwVR26xIkaipRqRcMRXBf8N5dacvGus= github.com/mendsley/gojwk v0.0.0-20141217222730-4d5ec6e58103 h1:Z/i1e+gTZrmcGeZyWckaLfucYG6KYOXLWo4co8pZYNY= github.com/mendsley/gojwk v0.0.0-20141217222730-4d5ec6e58103/go.mod h1:o9YPB5aGP8ob35Vy6+vyq3P3bWe7NQWzf+JLiXCiMaE= -github.com/micbar/reva/v2 v2.0.0-20220712083851-2832f4d5031e h1:pg0HwOJXvCQfikOnHGXN0ImfYjC4MvuaT47OzYtcMqE= -github.com/micbar/reva/v2 v2.0.0-20220712083851-2832f4d5031e/go.mod h1:GlPiCJmt6nDrbPm6lL7pShonSUZ0Ld2GLtR+lATjLCE= github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= github.com/miekg/dns v1.1.26/go.mod h1:bPDLeHnStXmXAq1m/Ch/hvfNHr14JKNPMBo3VZKjuso= github.com/miekg/dns v1.1.40/go.mod h1:KNUDUusw/aVsxyTYZM1oqvCicbwhgbNgztCETuNZ7xM=