From ba7a5a482669ebbc02388cbe30737fd9e53df1f1 Mon Sep 17 00:00:00 2001 From: jkoberg Date: Tue, 29 Aug 2023 10:56:46 +0200 Subject: [PATCH] bump reva Signed-off-by: jkoberg --- changelog/unreleased/bump-reva.md | 5 ++++ go.mod | 2 +- go.sum | 4 +-- .../sharesstorageprovider.go | 13 ++++++++- .../http/services/owncloud/ocdav/locks.go | 29 ++++++++++++++++--- .../owncloud/ocdav/propfind/propfind.go | 11 +++++++ .../cs3org/reva/v2/pkg/events/sse.go | 19 ++++++++++++ vendor/modules.txt | 2 +- 8 files changed, 76 insertions(+), 9 deletions(-) create mode 100644 changelog/unreleased/bump-reva.md create mode 100644 vendor/github.com/cs3org/reva/v2/pkg/events/sse.go diff --git a/changelog/unreleased/bump-reva.md b/changelog/unreleased/bump-reva.md new file mode 100644 index 00000000000..36011d7ffe2 --- /dev/null +++ b/changelog/unreleased/bump-reva.md @@ -0,0 +1,5 @@ +Enhancement: Bump Reva + +bumps reva version + +https://github.com/owncloud/ocis/pull/7138 diff --git a/go.mod b/go.mod index 32df197a60e..ce4861e3f29 100644 --- a/go.mod +++ b/go.mod @@ -13,7 +13,7 @@ require ( github.com/coreos/go-oidc v2.2.1+incompatible github.com/coreos/go-oidc/v3 v3.6.0 github.com/cs3org/go-cs3apis v0.0.0-20230516150832-730ac860c71d - github.com/cs3org/reva/v2 v2.16.0 + github.com/cs3org/reva/v2 v2.16.1-0.20230828111521-594d4e103741 github.com/disintegration/imaging v1.6.2 github.com/dutchcoders/go-clamd v0.0.0-20170520113014-b970184f4d9e github.com/egirna/icap-client v0.1.1 diff --git a/go.sum b/go.sum index 0e7bca26682..bbb5b15d5ec 100644 --- a/go.sum +++ b/go.sum @@ -858,8 +858,8 @@ github.com/crewjam/httperr v0.2.0 h1:b2BfXR8U3AlIHwNeFFvZ+BV1LFvKLlzMjzaTnZMybNo github.com/crewjam/httperr v0.2.0/go.mod h1:Jlz+Sg/XqBQhyMjdDiC+GNNRzZTD7x39Gu3pglZ5oH4= github.com/crewjam/saml v0.4.13 h1:TYHggH/hwP7eArqiXSJUvtOPNzQDyQ7vwmwEqlFWhMc= github.com/crewjam/saml v0.4.13/go.mod h1:igEejV+fihTIlHXYP8zOec3V5A8y3lws5bQBFsTm4gA= -github.com/cs3org/reva/v2 v2.16.0 h1:XBFoGhzKrcDqqRvYdicOpDOpQVIsRqALmEt8X0N+wm0= -github.com/cs3org/reva/v2 v2.16.0/go.mod h1:RvhuweTFqzezjUFU0SIdTXakrEx9vJlMvQ7znPXSP1g= +github.com/cs3org/reva/v2 v2.16.1-0.20230828111521-594d4e103741 h1:y3Tw/ZVGPSDRiCslFUESomgSUOa3SAguOJKpiSk9pls= +github.com/cs3org/reva/v2 v2.16.1-0.20230828111521-594d4e103741/go.mod h1:RvhuweTFqzezjUFU0SIdTXakrEx9vJlMvQ7znPXSP1g= github.com/cyberdelia/templates v0.0.0-20141128023046-ca7fffd4298c/go.mod h1:GyV+0YP4qX0UQ7r2MoYZ+AvYDp12OF5yg4q8rGnyNh4= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= diff --git a/vendor/github.com/cs3org/reva/v2/internal/grpc/services/sharesstorageprovider/sharesstorageprovider.go b/vendor/github.com/cs3org/reva/v2/internal/grpc/services/sharesstorageprovider/sharesstorageprovider.go index 4b1a12f8baf..3176bb0ae5c 100644 --- a/vendor/github.com/cs3org/reva/v2/internal/grpc/services/sharesstorageprovider/sharesstorageprovider.go +++ b/vendor/github.com/cs3org/reva/v2/internal/grpc/services/sharesstorageprovider/sharesstorageprovider.go @@ -1059,7 +1059,7 @@ func (s *service) resolveAcceptedShare(ctx context.Context, ref *provider.Refere if receivedShare.State != collaboration.ShareState_SHARE_STATE_ACCEPTED { continue } - if strings.HasPrefix(strings.TrimPrefix(ref.Path, "./"), receivedShare.MountPoint.Path) { + if isMountPointForPath(receivedShare.MountPoint.Path, ref.Path) { return receivedShare, lsRes.Status, nil } } @@ -1069,6 +1069,17 @@ func (s *service) resolveAcceptedShare(ctx context.Context, ref *provider.Refere return nil, status.NewNotFound(ctx, "sharesstorageprovider: not found "+ref.String()), nil } +func isMountPointForPath(mountpoint, path string) bool { + requiredSegments := strings.Split(strings.TrimPrefix(mountpoint, "./"), "/") + pathSegments := strings.Split(strings.TrimPrefix(path, "./"), "/") + for i := range requiredSegments { + if pathSegments[i] != requiredSegments[i] { + return false + } + } + return true +} + func (s *service) rejectReceivedShare(ctx context.Context, receivedShare *collaboration.ReceivedShare) error { receivedShare.State = collaboration.ShareState_SHARE_STATE_REJECTED receivedShare.MountPoint = nil diff --git a/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/locks.go b/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/locks.go index 54d69a1e21e..43ca6dde62f 100644 --- a/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/locks.go +++ b/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/locks.go @@ -42,6 +42,7 @@ import ( ctxpkg "github.com/cs3org/reva/v2/pkg/ctx" "github.com/cs3org/reva/v2/pkg/errtypes" "github.com/cs3org/reva/v2/pkg/rgrpc/todo/pool" + "github.com/cs3org/reva/v2/pkg/utils" "github.com/google/uuid" "go.opentelemetry.io/otel/attribute" ) @@ -190,11 +191,19 @@ func (cls *cs3LS) Create(ctx context.Context, now time.Time, details LockDetails // see: http://www.webdav.org/specs/rfc2518.html#n-lock-tokens token := uuid.New() + u := ctxpkg.ContextMustGetUser(ctx) + + // add metadata via opaque + // TODO: upate cs3api: https://github.com/cs3org/cs3apis/issues/213 + o := utils.AppendPlainToOpaque(nil, "lockownername", u.GetDisplayName()) + o = utils.AppendPlainToOpaque(o, "locktime", now.Format(time.RFC3339)) + r := &provider.SetLockRequest{ Ref: details.Root, Lock: &provider.Lock{ - Type: provider.LockType_LOCK_TYPE_EXCL, - User: details.UserID, // no way to set an app lock? TODO maybe via the ownerxml + Opaque: o, + Type: provider.LockType_LOCK_TYPE_EXCL, + User: details.UserID, // no way to set an app lock? TODO maybe via the ownerxml //AppName: , // TODO use a urn scheme? LockId: lockTokenPrefix + token.String(), // can be a token or a Coded-URL }, @@ -278,6 +287,10 @@ type LockDetails struct { // ZeroDepth is whether the lock has zero depth. If it does not have zero // depth, it has infinite depth. ZeroDepth bool + // OwnerName is the name of the lock owner + OwnerName string + // Locktime is the time the lock was created + Locktime time.Time } func readLockInfo(r io.Reader) (li lockInfo, status int, err error) { @@ -440,7 +453,8 @@ func (s *svc) lockReference(ctx context.Context, w http.ResponseWriter, r *http. } u := ctxpkg.ContextMustGetUser(ctx) - token, ld, now, created := "", LockDetails{UserID: u.Id, Root: ref, Duration: duration}, time.Now(), false + token, now, created := "", time.Now(), false + ld := LockDetails{UserID: u.Id, Root: ref, Duration: duration, OwnerName: u.GetDisplayName(), Locktime: now} if li == (lockInfo{}) { // An empty lockInfo means to refresh the lock. ih, ok := parseIfHeader(r.Header.Get(net.HeaderIf)) @@ -547,7 +561,7 @@ func writeLockInfo(w io.Writer, token string, ld LockDetails) (int, error) { lockdiscovery := strings.Builder{} lockdiscovery.WriteString(xml.Header) - lockdiscovery.WriteString("\n") + lockdiscovery.WriteString("\n") lockdiscovery.WriteString(" \n") lockdiscovery.WriteString(" \n") lockdiscovery.WriteString(fmt.Sprintf(" %s\n", depth)) @@ -566,6 +580,13 @@ func writeLockInfo(w io.Writer, token string, ld LockDetails) (int, error) { if href != "" { lockdiscovery.WriteString(fmt.Sprintf(" %s\n", prop.Escape(href))) } + if ld.OwnerName != "" { + lockdiscovery.WriteString(fmt.Sprintf(" %s\n", prop.Escape(ld.OwnerName))) + } + if !ld.Locktime.IsZero() { + lockdiscovery.WriteString(fmt.Sprintf(" %s\n", prop.Escape(ld.Locktime.Format(time.RFC3339)))) + } + lockdiscovery.WriteString("") return fmt.Fprint(w, lockdiscovery.String()) diff --git a/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/propfind/propfind.go b/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/propfind/propfind.go index 0600f1b14aa..ea0be352e07 100644 --- a/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/propfind/propfind.go +++ b/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/propfind/propfind.go @@ -1635,6 +1635,17 @@ func activeLocks(log *zerolog.Logger, lock *provider.Lock) string { } activelocks.WriteString("") } + + if un := utils.ReadPlainFromOpaque(lock.Opaque, "lockownername"); un != "" { + activelocks.WriteString("") + activelocks.WriteString(un) + activelocks.WriteString("") + } + if lt := utils.ReadPlainFromOpaque(lock.Opaque, "locktime"); lt != "" { + activelocks.WriteString("") + activelocks.WriteString(lt) + activelocks.WriteString("") + } activelocks.WriteString("") activelocks.WriteString(expiration) activelocks.WriteString("") diff --git a/vendor/github.com/cs3org/reva/v2/pkg/events/sse.go b/vendor/github.com/cs3org/reva/v2/pkg/events/sse.go new file mode 100644 index 00000000000..34841c81f37 --- /dev/null +++ b/vendor/github.com/cs3org/reva/v2/pkg/events/sse.go @@ -0,0 +1,19 @@ +package events + +import ( + "encoding/json" +) + +// SendSEE instructs the sse service to send a notification to a user +type SendSSE struct { + UserID string + Type string + Message []byte +} + +// Unmarshal to fulfill umarshaller interface +func (SendSSE) Unmarshal(v []byte) (interface{}, error) { + e := SendSSE{} + err := json.Unmarshal(v, &e) + return e, err +} diff --git a/vendor/modules.txt b/vendor/modules.txt index cac3f824bba..8c99b3dba4d 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -354,7 +354,7 @@ github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1 github.com/cs3org/go-cs3apis/cs3/storage/registry/v1beta1 github.com/cs3org/go-cs3apis/cs3/tx/v1beta1 github.com/cs3org/go-cs3apis/cs3/types/v1beta1 -# github.com/cs3org/reva/v2 v2.16.0 +# github.com/cs3org/reva/v2 v2.16.1-0.20230828111521-594d4e103741 ## explicit; go 1.20 github.com/cs3org/reva/v2/cmd/revad/internal/grace github.com/cs3org/reva/v2/cmd/revad/runtime