From e5ba9a630f670d7a58d6bb2eb4225b148c4170a9 Mon Sep 17 00:00:00 2001 From: Roman Perekhod Date: Tue, 12 Mar 2024 14:29:18 +0100 Subject: [PATCH] fix sharing invite on virtual drive --- .../unreleased/fix-graph-invite-virtual.md | 6 ++++ go.mod | 2 +- go.sum | 4 +-- .../services/authprovider/authprovider.go | 30 ++++++------------- .../internal/grpc/services/gateway/gateway.go | 1 + .../services/gateway/usershareprovider.go | 4 +-- .../cs3org/reva/v2/pkg/errtypes/errtypes.go | 14 ++++----- .../cs3org/reva/v2/pkg/rgrpc/status/status.go | 4 +++ vendor/modules.txt | 2 +- 9 files changed, 33 insertions(+), 34 deletions(-) create mode 100644 changelog/unreleased/fix-graph-invite-virtual.md diff --git a/changelog/unreleased/fix-graph-invite-virtual.md b/changelog/unreleased/fix-graph-invite-virtual.md new file mode 100644 index 0000000000..52e42c8dc8 --- /dev/null +++ b/changelog/unreleased/fix-graph-invite-virtual.md @@ -0,0 +1,6 @@ +Bugfix: Fix sharing invite on virtual drive + +We fixed the issue when sharing of virtual drive with other users was allowed + +https://github.com/owncloud/ocis/pull/8609 +https://github.com/owncloud/ocis/issues/8495 diff --git a/go.mod b/go.mod index 86cffe64d6..ce627b2077 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,7 @@ require ( github.com/cenkalti/backoff v2.2.1+incompatible github.com/coreos/go-oidc/v3 v3.9.0 github.com/cs3org/go-cs3apis v0.0.0-20231023073225-7748710e0781 - github.com/cs3org/reva/v2 v2.19.2-0.20240308123626-fc2867f59d92 + github.com/cs3org/reva/v2 v2.19.2-0.20240312150024-04c0a3136ac9 github.com/dhowden/tag v0.0.0-20230630033851-978a0926ee25 github.com/disintegration/imaging v1.6.2 github.com/dutchcoders/go-clamd v0.0.0-20170520113014-b970184f4d9e diff --git a/go.sum b/go.sum index 6c203390c9..6ef2f365d2 100644 --- a/go.sum +++ b/go.sum @@ -1019,8 +1019,8 @@ github.com/crewjam/saml v0.4.14 h1:g9FBNx62osKusnFzs3QTN5L9CVA/Egfgm+stJShzw/c= github.com/crewjam/saml v0.4.14/go.mod h1:UVSZCf18jJkk6GpWNVqcyQJMD5HsRugBPf4I1nl2mME= github.com/cs3org/go-cs3apis v0.0.0-20231023073225-7748710e0781 h1:BUdwkIlf8IS2FasrrPg8gGPHQPOrQ18MS1Oew2tmGtY= github.com/cs3org/go-cs3apis v0.0.0-20231023073225-7748710e0781/go.mod h1:UXha4TguuB52H14EMoSsCqDj7k8a/t7g4gVP+bgY5LY= -github.com/cs3org/reva/v2 v2.19.2-0.20240308123626-fc2867f59d92 h1:+dM3XWjA+P6/jfKkjCIrLGhfvg64KL0UZ7bTR7wYAEk= -github.com/cs3org/reva/v2 v2.19.2-0.20240308123626-fc2867f59d92/go.mod h1:GRUrOp5HbFVwZTgR9bVrMZ/MvVy+Jhxw1PdMmhhKP9E= +github.com/cs3org/reva/v2 v2.19.2-0.20240312150024-04c0a3136ac9 h1:7DdURTnE38PoSLxsYjZ8ZXyknc53PgD4M1KQT24eX88= +github.com/cs3org/reva/v2 v2.19.2-0.20240312150024-04c0a3136ac9/go.mod h1:GRUrOp5HbFVwZTgR9bVrMZ/MvVy+Jhxw1PdMmhhKP9E= github.com/cyberdelia/templates v0.0.0-20141128023046-ca7fffd4298c/go.mod h1:GyV+0YP4qX0UQ7r2MoYZ+AvYDp12OF5yg4q8rGnyNh4= github.com/cyphar/filepath-securejoin v0.2.4 h1:Ugdm7cg7i6ZK6x3xDF1oEu1nfkyfH53EtKeQYTC3kyg= github.com/cyphar/filepath-securejoin v0.2.4/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxGGx79pTxQpKOJNYHHl4= diff --git a/vendor/github.com/cs3org/reva/v2/internal/grpc/services/authprovider/authprovider.go b/vendor/github.com/cs3org/reva/v2/internal/grpc/services/authprovider/authprovider.go index 29acbbe629..ec2ca9dc66 100644 --- a/vendor/github.com/cs3org/reva/v2/internal/grpc/services/authprovider/authprovider.go +++ b/vendor/github.com/cs3org/reva/v2/internal/grpc/services/authprovider/authprovider.go @@ -136,28 +136,16 @@ func (s *service) Authenticate(ctx context.Context, req *provider.AuthenticateRe password := req.ClientSecret u, scope, err := s.authmgr.Authenticate(ctx, username, password) - switch v := err.(type) { - case nil: - log.Info().Msgf("user %s authenticated", u.Id) + if err != nil { + log.Debug().Str("client_id", username).Err(err).Msg("authsvc: error in Authenticate") return &provider.AuthenticateResponse{ - Status: status.NewOK(ctx), - User: u, - TokenScope: scope, - }, nil - case errtypes.InvalidCredentials: - return &provider.AuthenticateResponse{ - Status: status.NewPermissionDenied(ctx, v, "wrong password"), - }, nil - case errtypes.NotFound: - log.Debug().Str("client_id", username).Msg("unknown client id") - return &provider.AuthenticateResponse{ - Status: status.NewNotFound(ctx, "unknown client id"), - }, nil - default: - err = errors.Wrap(err, "authsvc: error in Authenticate") - return &provider.AuthenticateResponse{ - Status: status.NewUnauthenticated(ctx, err, "error authenticating user"), + Status: status.NewStatusFromErrType(ctx, "authsvc: error in Authenticate", err), }, nil } - + log.Info().Msgf("user %s authenticated", u.Id) + return &provider.AuthenticateResponse{ + Status: status.NewOK(ctx), + User: u, + TokenScope: scope, + }, nil } diff --git a/vendor/github.com/cs3org/reva/v2/internal/grpc/services/gateway/gateway.go b/vendor/github.com/cs3org/reva/v2/internal/grpc/services/gateway/gateway.go index c3a30e12ca..55a5ea8a7a 100644 --- a/vendor/github.com/cs3org/reva/v2/internal/grpc/services/gateway/gateway.go +++ b/vendor/github.com/cs3org/reva/v2/internal/grpc/services/gateway/gateway.go @@ -38,6 +38,7 @@ import ( const ( _spaceTypePersonal = "personal" _spaceTypeProject = "project" + _spaceTypeVirtual = "virtual" ) func init() { diff --git a/vendor/github.com/cs3org/reva/v2/internal/grpc/services/gateway/usershareprovider.go b/vendor/github.com/cs3org/reva/v2/internal/grpc/services/gateway/usershareprovider.go index 910375d470..02587d2f99 100644 --- a/vendor/github.com/cs3org/reva/v2/internal/grpc/services/gateway/usershareprovider.go +++ b/vendor/github.com/cs3org/reva/v2/internal/grpc/services/gateway/usershareprovider.go @@ -583,8 +583,8 @@ func (s *svc) addShare(ctx context.Context, req *collaboration.CreateShareReques func (s *svc) addSpaceShare(ctx context.Context, req *collaboration.CreateShareRequest) (*collaboration.CreateShareResponse, error) { if refIsSpaceRoot(req.GetResourceInfo().GetId()) && - req.GetResourceInfo().GetSpace().GetSpaceType() == _spaceTypePersonal { - return nil, errors.New("gateway: space type is not eligible for sharing") + (req.GetResourceInfo().GetSpace().GetSpaceType() == _spaceTypePersonal || req.GetResourceInfo().GetSpace().GetSpaceType() == _spaceTypeVirtual) { + return &collaboration.CreateShareResponse{Status: status.NewInvalid(ctx, "space type is not eligible for sharing")}, nil } // If the share is a denial we call denyGrant instead. var st *rpc.Status diff --git a/vendor/github.com/cs3org/reva/v2/pkg/errtypes/errtypes.go b/vendor/github.com/cs3org/reva/v2/pkg/errtypes/errtypes.go index 07266f1184..363211ac5a 100644 --- a/vendor/github.com/cs3org/reva/v2/pkg/errtypes/errtypes.go +++ b/vendor/github.com/cs3org/reva/v2/pkg/errtypes/errtypes.go @@ -144,7 +144,7 @@ func (e BadRequest) Error() string { return "error: bad request: " + string(e) } // IsBadRequest implements the IsBadRequest interface. func (e BadRequest) IsBadRequest() {} -// ChecksumMismatch is the error to use when the sent hash does not match the calculated hash. +// ChecksumMismatch is the error to use when the transmitted hash does not match the calculated hash. type ChecksumMismatch string func (e ChecksumMismatch) Error() string { return "error: checksum mismatch: " + string(e) } @@ -178,7 +178,7 @@ type NotModified string func (e NotModified) Error() string { return "error: not modified: " + string(e) } -// NotModified implements the IsNotModified interface. +// IsNotModified implements the IsNotModified interface. func (e NotModified) IsNotModified() {} // StatusCode returns StatusInsufficientStorage, this implementation is needed to allow TUS to cast the correct http errors. @@ -196,7 +196,7 @@ func (e InsufficientStorage) Body() []byte { const StatusInsufficientStorage = 507 // IsNotFound is the interface to implement -// to specify that an a resource is not found. +// to specify that a resource is not found. type IsNotFound interface { IsNotFound() } @@ -238,7 +238,7 @@ type IsPermissionDenied interface { } // IsLocked is the interface to implement -// to specify that an resource is locked. +// to specify that a resource is locked. type IsLocked interface { IsLocked() } @@ -279,7 +279,7 @@ type IsInsufficientStorage interface { IsInsufficientStorage() } -// NewErrtypeFromStatus maps an rpc status to an errtype +// NewErrtypeFromStatus maps a rpc status to an errtype func NewErrtypeFromStatus(status *rpc.Status) error { switch status.Code { case rpc.Code_CODE_OK: @@ -318,7 +318,7 @@ func NewErrtypeFromStatus(status *rpc.Status) error { } } -// NewErrtypeFromHTTPStatusCode maps an http status to an errtype +// NewErrtypeFromHTTPStatusCode maps a http status to an errtype func NewErrtypeFromHTTPStatusCode(code int, message string) error { switch code { case http.StatusOK: @@ -352,7 +352,7 @@ func NewErrtypeFromHTTPStatusCode(code int, message string) error { } } -// NewHTTPStatusCodeFromErrtype maps an errtype to an http status +// NewHTTPStatusCodeFromErrtype maps an errtype to a http status func NewHTTPStatusCodeFromErrtype(err error) int { switch err.(type) { case NotFound: diff --git a/vendor/github.com/cs3org/reva/v2/pkg/rgrpc/status/status.go b/vendor/github.com/cs3org/reva/v2/pkg/rgrpc/status/status.go index 56b635a4b1..4055cff4d9 100644 --- a/vendor/github.com/cs3org/reva/v2/pkg/rgrpc/status/status.go +++ b/vendor/github.com/cs3org/reva/v2/pkg/rgrpc/status/status.go @@ -166,10 +166,14 @@ func NewStatusFromErrType(ctx context.Context, msg string, err error) *rpc.Statu switch e := err.(type) { case nil: return NewOK(ctx) + case errtypes.NotFound: + return NewNotFound(ctx, msg+": "+err.Error()) case errtypes.IsNotFound: return NewNotFound(ctx, msg+": "+err.Error()) case errtypes.AlreadyExists: return NewAlreadyExists(ctx, err, msg+": "+err.Error()) + case errtypes.InvalidCredentials: + return NewPermissionDenied(ctx, e, msg+": "+err.Error()) case errtypes.IsInvalidCredentials: // TODO this maps badly return NewUnauthenticated(ctx, err, msg+": "+err.Error()) diff --git a/vendor/modules.txt b/vendor/modules.txt index cfae524bd2..b7dc0ac272 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -359,7 +359,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.19.2-0.20240308123626-fc2867f59d92 +# github.com/cs3org/reva/v2 v2.19.2-0.20240312150024-04c0a3136ac9 ## explicit; go 1.21 github.com/cs3org/reva/v2/cmd/revad/internal/grace github.com/cs3org/reva/v2/cmd/revad/runtime