Skip to content

Commit

Permalink
Merge branch 'edge' into release-2.19.2
Browse files Browse the repository at this point in the history
  • Loading branch information
2403905 authored Mar 13, 2024
2 parents e1931d8 + 04c0a31 commit 7c4d4ce
Show file tree
Hide file tree
Showing 27 changed files with 120 additions and 189 deletions.
5 changes: 5 additions & 0 deletions changelog/unreleased/context-for-utils.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Enhancement: Allow tracing requests by giving util functions a context

We deprecated GetServiceUserContext with GetServiceUserContextWithContext and GetUser with GetUserWithContext to allow passing in a trace context.

https://github.com/cs3org/reva/pull/4556
5 changes: 5 additions & 0 deletions changelog/unreleased/extend-service-account-permissions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Enhancement: Extend service account permissions

Adds CreateContainer permisson and improves cs3 storage pkg

https://github.com/cs3org/reva/pull/4545
5 changes: 5 additions & 0 deletions changelog/unreleased/file-unlocked-events.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Enhancement: Send file locked/unlocked events

Emit an event when a file is locked or unlocked

https://github.com/cs3org/reva/pull/4564
3 changes: 3 additions & 0 deletions changelog/unreleased/fix-authprovider-error-message.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Bugfix: Fix error message in authprovider if user is not found

https://github.com/cs3org/reva/pull/4567
3 changes: 3 additions & 0 deletions changelog/unreleased/fix-ceph-build.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Bugfix: Fix ceph build

https://github.com/cs3org/reva/pull/4557
6 changes: 6 additions & 0 deletions changelog/unreleased/fix-graph-invite-virtual.md
Original file line number Diff line number Diff line change
@@ -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/cs3org/reva/pull/4568
https://github.com/owncloud/ocis/issues/8495
6 changes: 6 additions & 0 deletions changelog/unreleased/fix-graph-invite.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Bugfix: Fix graph drive invite

We fixed the issue when sharing of personal drive is allowed via graph

https://github.com/cs3org/reva/pull/4559
https://github.com/owncloud/ocis/issues/8494
6 changes: 6 additions & 0 deletions changelog/unreleased/fix-public-link-lock.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Bugfix: Fix an error when lock/unlock a file

We fixed a bug when anonymous user with viewer role in public link of a folder can lock/unlock a file inside it

https://github.com/cs3org/reva/pull/4518
https://github.com/owncloud/ocis/issues/7785
5 changes: 5 additions & 0 deletions changelog/unreleased/fix-publiclink-previews.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Bugfix: Fix public link previews

Fixes previews for public links

https://github.com/cs3org/reva/pull/4566
8 changes: 8 additions & 0 deletions changelog/unreleased/fix-stat-recreated-share.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Bugfix: Fix Stat() by Path on re-created resource

We fixed bug that caused Stat Requests using a Path reference to a mount point
in the sharejail to not resolve correctly, when a share using the same
mount point to an already deleted resource was still existing.

https://github.com/cs3org/reva/pull/4561
https://github.com/owncloud/ocis/issues/7895
5 changes: 5 additions & 0 deletions changelog/unreleased/kill-service-spanning-stat-cache.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Change: Drop unused service spanning stat cache

We removed the stat cache shared between gateway and storage providers. It is constantly invalidated and needs a different approach.

https://github.com/cs3org/reva/pull/4542
30 changes: 9 additions & 21 deletions internal/grpc/services/authprovider/authprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
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")
if err != nil {
log.Debug().Str("client_id", username).Err(err).Msg("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
}
12 changes: 0 additions & 12 deletions internal/grpc/services/gateway/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ type config struct {
DataTransfersFolder string `mapstructure:"data_transfers_folder"`
TokenManagers map[string]map[string]interface{} `mapstructure:"token_managers"`
AllowedUserAgents map[string][]string `mapstructure:"allowed_user_agents"` // map[path][]user-agent
StatCacheConfig cache.Config `mapstructure:"stat_cache_config"`
CreatePersonalSpaceCacheConfig cache.Config `mapstructure:"create_personal_space_cache_config"`
ProviderCacheConfig cache.Config `mapstructure:"provider_cache_config"`
UseCommonSpaceRootShareLogic bool `mapstructure:"use_common_space_root_share_logic"`
Expand Down Expand Up @@ -123,14 +122,6 @@ func (c *config) init() {
}

// caching needs to be explicitly enabled
if c.StatCacheConfig.Store == "" {
c.StatCacheConfig.Store = "noop"
}

if c.StatCacheConfig.Database == "" {
c.StatCacheConfig.Database = "reva"
}

if c.ProviderCacheConfig.Store == "" {
c.ProviderCacheConfig.Store = "noop"
}
Expand All @@ -152,7 +143,6 @@ type svc struct {
c *config
dataGatewayURL url.URL
tokenmgr token.Manager
statCache cache.StatCache
providerCache cache.ProviderCache
createPersonalSpaceCache cache.CreatePersonalSpaceCache
}
Expand Down Expand Up @@ -183,7 +173,6 @@ func New(m map[string]interface{}, _ *grpc.Server) (rgrpc.Service, error) {
c: c,
dataGatewayURL: *u,
tokenmgr: tokenManager,
statCache: cache.GetStatCache(c.StatCacheConfig),
providerCache: cache.GetProviderCache(c.ProviderCacheConfig),
createPersonalSpaceCache: cache.GetCreatePersonalSpaceCache(c.CreatePersonalSpaceCacheConfig),
}
Expand All @@ -196,7 +185,6 @@ func (s *svc) Register(ss *grpc.Server) {
}

func (s *svc) Close() error {
s.statCache.Close()
s.providerCache.Close()
s.createPersonalSpaceCache.Close()
return nil
Expand Down
14 changes: 5 additions & 9 deletions internal/grpc/services/gateway/ocmshareprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,21 +52,17 @@ func (s *svc) CreateOCMShare(ctx context.Context, req *ocm.CreateOCMShareRequest
}

status, err := s.addGrant(ctx, req.ResourceId, req.Grantee, req.AccessMethods[0].GetWebdavOptions().Permissions, req.Expiration, nil)
if err != nil {
switch {
case err != nil:
appctx.GetLogger(ctx).Debug().Interface("status", status).Interface("req", req).Msg(err.Error())
return nil, errors.Wrap(err, "gateway: error adding grant to storage")
}

switch status.Code {
case rpc.Code_CODE_OK:
s.statCache.RemoveStatContext(ctx, ctxpkg.ContextMustGetUser(ctx).GetId(), req.ResourceId)
case rpc.Code_CODE_UNIMPLEMENTED:
case status.Code == rpc.Code_CODE_UNIMPLEMENTED:
appctx.GetLogger(ctx).Debug().Interface("status", status).Interface("req", req).Msg("storing grants not supported, ignoring")
default:
case status.Code != rpc.Code_CODE_OK:
appctx.GetLogger(ctx).Debug().Interface("status", status).Interface("req", req).Msg("storing grants is not successful")
return &ocm.CreateOCMShareResponse{
Status: status,
}, err
}, nil
}

return res, nil
Expand Down
34 changes: 3 additions & 31 deletions internal/grpc/services/gateway/publicshareprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,9 @@ package gateway
import (
"context"

userprovider "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1"
rpc "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1"
link "github.com/cs3org/go-cs3apis/cs3/sharing/link/v1beta1"
"github.com/cs3org/reva/v2/pkg/appctx"
ctxpkg "github.com/cs3org/reva/v2/pkg/ctx"
"github.com/cs3org/reva/v2/pkg/rgrpc/todo/pool"
"github.com/pkg/errors"
)
Expand All @@ -39,15 +37,7 @@ func (s *svc) CreatePublicShare(ctx context.Context, req *link.CreatePublicShare
return nil, err
}

res, err := c.CreatePublicShare(ctx, req)
if err != nil {
return nil, err
}

if res.GetShare() != nil {
s.statCache.RemoveStatContext(ctx, ctxpkg.ContextMustGetUser(ctx).GetId(), res.Share.ResourceId)
}
return res, nil
return c.CreatePublicShare(ctx, req)
}

func (s *svc) RemovePublicShare(ctx context.Context, req *link.RemovePublicShareRequest) (*link.RemovePublicShareResponse, error) {
Expand All @@ -58,13 +48,7 @@ func (s *svc) RemovePublicShare(ctx context.Context, req *link.RemovePublicShare
if err != nil {
return nil, err
}
res, err := driver.RemovePublicShare(ctx, req)
if err != nil {
return nil, err
}
// TODO: How to find out the resourceId? -> get public share first, then delete
s.statCache.RemoveStatContext(ctx, ctxpkg.ContextMustGetUser(ctx).GetId(), nil)
return res, nil
return driver.RemovePublicShare(ctx, req)
}

func (s *svc) GetPublicShareByToken(ctx context.Context, req *link.GetPublicShareByTokenRequest) (*link.GetPublicShareByTokenResponse, error) {
Expand Down Expand Up @@ -137,17 +121,5 @@ func (s *svc) UpdatePublicShare(ctx context.Context, req *link.UpdatePublicShare
}, nil
}

res, err := pClient.UpdatePublicShare(ctx, req)
if err != nil {
return nil, errors.Wrap(err, "error updating share")
}
if res.GetShare() != nil {
s.statCache.RemoveStatContext(ctx,
&userprovider.UserId{
OpaqueId: res.Share.Owner.GetOpaqueId(),
},
res.Share.ResourceId,
)
}
return res, nil
return pClient.UpdatePublicShare(ctx, req)
}
17 changes: 0 additions & 17 deletions internal/grpc/services/gateway/storageprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,6 @@ func (s *svc) UpdateStorageSpace(ctx context.Context, req *provider.UpdateStorag

if res.Status.Code == rpc.Code_CODE_OK {
id := res.StorageSpace.Root
s.statCache.RemoveStatContext(ctx, ctxpkg.ContextMustGetUser(ctx).GetId(), id)
s.providerCache.RemoveListStorageProviders(id)
}
return res, nil
Expand Down Expand Up @@ -363,7 +362,6 @@ func (s *svc) DeleteStorageSpace(ctx context.Context, req *provider.DeleteStorag
}

id := &provider.ResourceId{OpaqueId: req.Id.OpaqueId}
s.statCache.RemoveStatContext(ctx, ctxpkg.ContextMustGetUser(ctx).GetId(), id)
s.providerCache.RemoveListStorageProviders(id)

if dsRes.Status.Code != rpc.Code_CODE_OK {
Expand Down Expand Up @@ -608,7 +606,6 @@ func (s *svc) InitiateFileUpload(ctx context.Context, req *provider.InitiateFile
}
}

s.statCache.RemoveStatContext(ctx, ctxpkg.ContextMustGetUser(ctx).GetId(), req.Ref.ResourceId)
return &gateway.InitiateFileUploadResponse{
Opaque: storageRes.Opaque,
Status: storageRes.Status,
Expand Down Expand Up @@ -645,7 +642,6 @@ func (s *svc) CreateContainer(ctx context.Context, req *provider.CreateContainer
}, nil
}

s.statCache.RemoveStatContext(ctx, ctxpkg.ContextMustGetUser(ctx).GetId(), req.Ref.ResourceId)
return res, nil
}

Expand Down Expand Up @@ -688,7 +684,6 @@ func (s *svc) Delete(ctx context.Context, req *provider.DeleteRequest) (*provide
}, nil
}

s.statCache.RemoveStatContext(ctx, ctxpkg.ContextMustGetUser(ctx).GetId(), req.Ref.ResourceId)
return res, nil
}

Expand All @@ -715,8 +710,6 @@ func (s *svc) Move(ctx context.Context, req *provider.MoveRequest) (*provider.Mo

req.Source = sref
req.Destination = dref
s.statCache.RemoveStatContext(ctx, ctxpkg.ContextMustGetUser(ctx).GetId(), req.Source.ResourceId)
s.statCache.RemoveStatContext(ctx, ctxpkg.ContextMustGetUser(ctx).GetId(), req.Destination.ResourceId)
return c.Move(ctx, req)
}

Expand All @@ -739,7 +732,6 @@ func (s *svc) SetArbitraryMetadata(ctx context.Context, req *provider.SetArbitra
return nil, errors.Wrap(err, "gateway: error calling SetArbitraryMetadata")
}

s.statCache.RemoveStatContext(ctx, ctxpkg.ContextMustGetUser(ctx).GetId(), req.Ref.ResourceId)
return res, nil
}

Expand All @@ -761,7 +753,6 @@ func (s *svc) UnsetArbitraryMetadata(ctx context.Context, req *provider.UnsetArb
}
return nil, errors.Wrap(err, "gateway: error calling UnsetArbitraryMetadata")
}
s.statCache.RemoveStatContext(ctx, ctxpkg.ContextMustGetUser(ctx).GetId(), req.Ref.ResourceId)

return res, nil
}
Expand All @@ -785,7 +776,6 @@ func (s *svc) SetLock(ctx context.Context, req *provider.SetLockRequest) (*provi
return nil, errors.Wrap(err, "gateway: error calling SetLock")
}

s.statCache.RemoveStatContext(ctx, ctxpkg.ContextMustGetUser(ctx).GetId(), req.Ref.ResourceId)
return res, nil
}

Expand Down Expand Up @@ -826,7 +816,6 @@ func (s *svc) RefreshLock(ctx context.Context, req *provider.RefreshLockRequest)
return nil, errors.Wrap(err, "gateway: error calling RefreshLock")
}

s.statCache.RemoveStatContext(ctx, ctxpkg.ContextMustGetUser(ctx).GetId(), req.Ref.ResourceId)
return res, nil
}

Expand All @@ -847,12 +836,10 @@ func (s *svc) Unlock(ctx context.Context, req *provider.UnlockRequest) (*provide
return nil, errors.Wrap(err, "gateway: error calling Unlock")
}

s.statCache.RemoveStatContext(ctx, ctxpkg.ContextMustGetUser(ctx).GetId(), req.Ref.ResourceId)
return res, nil
}

// Stat returns the Resoure info for a given resource by forwarding the request to the responsible provider.
// TODO cache info
func (s *svc) Stat(ctx context.Context, req *provider.StatRequest) (*provider.StatResponse, error) {
c, _, ref, err := s.findAndUnwrapUnique(ctx, req.Ref)
if err != nil {
Expand Down Expand Up @@ -927,7 +914,6 @@ func (s *svc) RestoreFileVersion(ctx context.Context, req *provider.RestoreFileV
}, nil
}

s.statCache.RemoveStatContext(ctx, ctxpkg.ContextMustGetUser(ctx).GetId(), req.Ref.ResourceId)
return res, nil
}

Expand Down Expand Up @@ -983,7 +969,6 @@ func (s *svc) RestoreRecycleItem(ctx context.Context, req *provider.RestoreRecyc
}, nil
}

s.statCache.RemoveStatContext(ctx, ctxpkg.ContextMustGetUser(ctx).GetId(), req.Ref.ResourceId)
return res, nil
}

Expand All @@ -1006,7 +991,6 @@ func (s *svc) PurgeRecycle(ctx context.Context, req *provider.PurgeRecycleReques
}, nil
}

s.statCache.RemoveStatContext(ctx, ctxpkg.ContextMustGetUser(ctx).GetId(), req.Ref.ResourceId)
return res, nil
}

Expand Down Expand Up @@ -1106,7 +1090,6 @@ func (s *svc) getStorageProviderClient(_ context.Context, p *registry.ProviderIn

return &cachedAPIClient{
c: c,
statCache: s.statCache,
createPersonalSpaceCache: s.createPersonalSpaceCache,
}, nil
}
Expand Down
Loading

0 comments on commit 7c4d4ce

Please sign in to comment.