feat: bump go to 1.25
bump reva
This commit is contained in:
1 parent
145602769a
commit
68b4791fce
11 files changed
+72
-224
No files matched your search
+3
-3
@@ -19,7 +19,7 @@ OC_CI_BAZEL_BUILDIFIER = "owncloudci/bazel-buildifier:latest"
|
||||
OC_CI_CLAMAVD = "owncloudci/clamavd"
|
||||
OC_CI_DRONE_ANSIBLE = "owncloudci/drone-ansible:latest"
|
||||
OC_CI_DRONE_SKIP_PIPELINE = "owncloudci/drone-skip-pipeline"
|
||||
OC_CI_GOLANG = "owncloudci/golang:1.24"
|
||||
OC_CI_GOLANG = "owncloudci/golang:1.25"
|
||||
OC_CI_NODEJS = "owncloudci/nodejs:%s"
|
||||
OC_CI_PHP = "owncloudci/php:%s"
|
||||
OC_CI_WAIT_FOR = "owncloudci/wait-for:latest"
|
||||
@@ -3854,7 +3854,7 @@ def prepareOcisDeployment():
|
||||
|
||||
return [{
|
||||
"name": "prepare-ocis-deployment",
|
||||
"image": "owncloudci/golang:latest",
|
||||
"image": "owncloudci/golang:1.25",
|
||||
"commands": commands,
|
||||
"volumes": [
|
||||
{
|
||||
@@ -3886,7 +3886,7 @@ def setupOcisConfigMaps():
|
||||
def deployOcis():
|
||||
return [{
|
||||
"name": "deploy-ocis",
|
||||
"image": "owncloudci/golang:latest",
|
||||
"image": "owncloudci/golang:1.25",
|
||||
"commands": [
|
||||
"export KUBECONFIG=%s/kubeconfig-$${DRONE_BUILD_NUMBER}.yaml" % dirs["base"],
|
||||
"cd %s/ocis-charts" % dirs["base"],
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@ COPY --from=generate /ocis /ocis
|
||||
WORKDIR /ocis/ocis
|
||||
RUN make ci-go-generate build ENABLE_VIPS=true
|
||||
|
||||
FROM alpine:3.23
|
||||
FROM alpine:3.23.3
|
||||
|
||||
RUN apk add --no-cache attr ca-certificates curl mailcap tree vips && \
|
||||
echo 'hosts: files dns' >| /etc/nsswitch.conf
|
||||
|
||||
@@ -108,7 +108,7 @@ See the [Install Infinite Scale on a Server](https://doc.owncloud.com/ocis/next/
|
||||
|
||||
Use this method to build and run an instance with the latest code. This is only recommended for development purposes.
|
||||
|
||||
The minimum go version required is `1.24`.\
|
||||
The minimum go version required is `1.25`.\
|
||||
Note that you need a C compile environment installed as a prerequisite because some dependencies, like reva, have components that require C-Go libraries and toolchains. The command installing for debian based systems is: `sudo apt install build-essential`.
|
||||
|
||||
To build and run a local instance with demo users:
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
Enhancement: Update to go 1.25.6
|
||||
|
||||
We have updated go to version 1.25.6 and alpine to version 3.23.3
|
||||
|
||||
https://github.com/owncloud/ocis/pull/12004
|
||||
@@ -1,8 +1,6 @@
|
||||
module github.com/owncloud/ocis/v2
|
||||
|
||||
go 1.24.6
|
||||
|
||||
toolchain go1.24.9
|
||||
go 1.25.6
|
||||
|
||||
require (
|
||||
dario.cat/mergo v1.0.2
|
||||
@@ -66,7 +64,7 @@ require (
|
||||
github.com/open-policy-agent/opa v1.12.3
|
||||
github.com/orcaman/concurrent-map v1.0.0
|
||||
github.com/owncloud/libre-graph-api-go v1.0.5-0.20260116104114-10074a92be64
|
||||
github.com/owncloud/reva/v2 v2.0.0-20260123085534-22a1be2b211e
|
||||
github.com/owncloud/reva/v2 v2.0.0-20260209172723-6b94461c2a1a
|
||||
github.com/pkg/errors v0.9.1
|
||||
github.com/pkg/xattr v0.4.12
|
||||
github.com/prometheus/client_golang v1.23.2
|
||||
|
||||
@@ -742,8 +742,8 @@ github.com/orcaman/concurrent-map v1.0.0 h1:I/2A2XPCb4IuQWcQhBhSwGfiuybl/J0ev9HD
|
||||
github.com/orcaman/concurrent-map v1.0.0/go.mod h1:Lu3tH6HLW3feq74c2GC+jIMS/K2CFcDWnWD9XkenwhI=
|
||||
github.com/owncloud/libre-graph-api-go v1.0.5-0.20260116104114-10074a92be64 h1:z9djjzd+leAy6QZpi8dLy3OVjc/um+1XAGk1SJEvwE8=
|
||||
github.com/owncloud/libre-graph-api-go v1.0.5-0.20260116104114-10074a92be64/go.mod h1:z61VMGAJRtR1nbgXWiNoCkxUXP1B3Je9rMuJbnGd+Og=
|
||||
github.com/owncloud/reva/v2 v2.0.0-20260123085534-22a1be2b211e h1:SL7kqt9HyZpyeWjb0saiRm1COMPZhQ9w8lUoCHWgm2o=
|
||||
github.com/owncloud/reva/v2 v2.0.0-20260123085534-22a1be2b211e/go.mod h1:eHbT6pmVlcjdiBeVEYw7exlfJmemMzKBh4R+HFgx9Cc=
|
||||
github.com/owncloud/reva/v2 v2.0.0-20260209172723-6b94461c2a1a h1:ExIZgutPn8K1DbRrnUSyMlIXtxHwsEO6obqVOdJhTc4=
|
||||
github.com/owncloud/reva/v2 v2.0.0-20260209172723-6b94461c2a1a/go.mod h1:scEb/eOohP+x3m3indXyZNc+Mksim1XEBDZvHMOSjPA=
|
||||
github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c h1:rp5dCmg/yLR3mgFuSOe4oEnDDmGLROTvMragMUXpTQw=
|
||||
github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c/go.mod h1:X07ZCGwUbLaax7L0S3Tw4hpejzu63ZrrQiUe6W0hcy0=
|
||||
github.com/pablodz/inotifywaitgo v0.0.9 h1:njquRbBU7fuwIe5rEvtaniVBjwWzcpdUVptSgzFqZsw=
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FROM amd64/alpine:3.23
|
||||
FROM amd64/alpine:3.23.3
|
||||
|
||||
ARG VERSION=""
|
||||
ARG REVISION=""
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FROM arm64v8/alpine:3.23
|
||||
FROM arm64v8/alpine:3.23.3
|
||||
|
||||
ARG VERSION=""
|
||||
ARG REVISION=""
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
module ociswrapper
|
||||
|
||||
go 1.22
|
||||
go 1.25
|
||||
|
||||
require (
|
||||
github.com/creack/pty v1.1.24
|
||||
|
||||
+53
-208
@@ -22,7 +22,6 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
appprovider "github.com/cs3org/go-cs3apis/cs3/app/provider/v1beta1"
|
||||
appregistry "github.com/cs3org/go-cs3apis/cs3/app/registry/v1beta1"
|
||||
@@ -41,17 +40,11 @@ import (
|
||||
"github.com/owncloud/reva/v2/pkg/errtypes"
|
||||
statuspkg "github.com/owncloud/reva/v2/pkg/rgrpc/status"
|
||||
"github.com/owncloud/reva/v2/pkg/rgrpc/todo/pool"
|
||||
"github.com/owncloud/reva/v2/pkg/storagespace"
|
||||
"github.com/owncloud/reva/v2/pkg/token"
|
||||
"github.com/owncloud/reva/v2/pkg/utils"
|
||||
"google.golang.org/grpc/metadata"
|
||||
)
|
||||
|
||||
const (
|
||||
scopeDelimiter = "#"
|
||||
scopeCacheExpiration = 3600
|
||||
)
|
||||
|
||||
func expandAndVerifyScope(ctx context.Context, req interface{}, tokenScope map[string]*authpb.Scope, user *userpb.User, gatewayAddr string, mgr token.Manager) error {
|
||||
log := appctx.GetLogger(ctx)
|
||||
client, err := pool.GetGatewayServiceClient(gatewayAddr)
|
||||
@@ -80,10 +73,6 @@ func expandAndVerifyScope(ctx context.Context, req interface{}, tokenScope map[s
|
||||
return nil
|
||||
}
|
||||
|
||||
case strings.HasPrefix(k, "lightweight"):
|
||||
if err = resolveLightweightScope(ctx, ref, tokenScope[k], user, client, mgr); err == nil {
|
||||
return nil
|
||||
}
|
||||
case strings.HasPrefix(k, "ocmshare"):
|
||||
if err = resolveOCMShare(ctx, ref, tokenScope[k], client, mgr); err == nil {
|
||||
return nil
|
||||
@@ -91,72 +80,11 @@ func expandAndVerifyScope(ctx context.Context, req interface{}, tokenScope map[s
|
||||
}
|
||||
log.Err(err).Interface("ref", ref).Interface("scope", k).Msg("error resolving reference under scope")
|
||||
}
|
||||
|
||||
} else if ref, ok := extractShareRef(req); ok {
|
||||
// It's a share ref
|
||||
// The request might be coming from a share created for a lightweight account
|
||||
// after the token was minted.
|
||||
log.Info().Msgf("resolving share reference against received shares to verify token scope %+v", ref.String())
|
||||
for k := range tokenScope {
|
||||
if strings.HasPrefix(k, "lightweight") {
|
||||
// Check if this ID is cached
|
||||
key := "lw:" + user.Id.OpaqueId + scopeDelimiter + ref.GetId().OpaqueId
|
||||
if _, err := scopeExpansionCache.Get(key); err == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
shares, err := client.ListReceivedShares(ctx, &collaboration.ListReceivedSharesRequest{})
|
||||
if err != nil || shares.Status.Code != rpc.Code_CODE_OK {
|
||||
log.Warn().Err(err).Msg("error listing received shares")
|
||||
continue
|
||||
}
|
||||
for _, s := range shares.Shares {
|
||||
shareKey := "lw:" + user.Id.OpaqueId + scopeDelimiter + s.Share.Id.OpaqueId
|
||||
_ = scopeExpansionCache.SetWithExpire(shareKey, nil, scopeCacheExpiration*time.Second)
|
||||
|
||||
if ref.GetId() != nil && ref.GetId().OpaqueId == s.Share.Id.OpaqueId {
|
||||
return nil
|
||||
}
|
||||
if key := ref.GetKey(); key != nil && (utils.UserEqual(key.Owner, s.Share.Owner) || utils.UserEqual(key.Owner, s.Share.Creator)) &&
|
||||
utils.ResourceIDEqual(key.ResourceId, s.Share.ResourceId) && utils.GranteeEqual(key.Grantee, s.Share.Grantee) {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return errtypes.PermissionDenied(fmt.Sprintf("access to resource %+v not allowed within the assigned scope", req))
|
||||
}
|
||||
|
||||
func resolveLightweightScope(ctx context.Context, ref *provider.Reference, scope *authpb.Scope, user *userpb.User, client gateway.GatewayAPIClient, mgr token.Manager) error {
|
||||
// Check if this ref is cached
|
||||
key := "lw:" + user.Id.OpaqueId + scopeDelimiter + getRefKey(ref)
|
||||
if _, err := scopeExpansionCache.Get(key); err == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
shares, err := client.ListReceivedShares(ctx, &collaboration.ListReceivedSharesRequest{})
|
||||
if err != nil || shares.Status.Code != rpc.Code_CODE_OK {
|
||||
return errtypes.InternalError("error listing received shares")
|
||||
}
|
||||
|
||||
for _, share := range shares.Shares {
|
||||
shareKey := "lw:" + user.Id.OpaqueId + scopeDelimiter + storagespace.FormatResourceID(share.Share.ResourceId)
|
||||
_ = scopeExpansionCache.SetWithExpire(shareKey, nil, scopeCacheExpiration*time.Second)
|
||||
|
||||
if ref.ResourceId != nil && utils.ResourceIDEqual(share.Share.ResourceId, ref.ResourceId) {
|
||||
return nil
|
||||
}
|
||||
if ok, err := checkIfNestedResource(ctx, ref, share.Share.ResourceId, client, mgr); err == nil && ok {
|
||||
_ = scopeExpansionCache.SetWithExpire(key, nil, scopeCacheExpiration*time.Second)
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
return errtypes.PermissionDenied("request is not for a nested resource")
|
||||
}
|
||||
|
||||
func resolvePublicShare(ctx context.Context, ref *provider.Reference, scope *authpb.Scope, client gateway.GatewayAPIClient, mgr token.Manager) error {
|
||||
var share link.PublicShare
|
||||
err := utils.UnmarshalJSONToProtoV1(scope.Resource.Value, &share)
|
||||
@@ -164,13 +92,7 @@ func resolvePublicShare(ctx context.Context, ref *provider.Reference, scope *aut
|
||||
return err
|
||||
}
|
||||
|
||||
if err := checkCacheForNestedResource(ctx, ref, share.ResourceId, client, mgr); err == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Some services like wopi don't access the shared resource relative to the
|
||||
// share root but instead relative to the shared resources parent.
|
||||
return checkRelativeReference(ctx, ref, share.ResourceId, client)
|
||||
return checkIfNestedResource(ctx, ref, share.ResourceId, client, mgr)
|
||||
}
|
||||
|
||||
func resolveOCMShare(ctx context.Context, ref *provider.Reference, scope *authpb.Scope, client gateway.GatewayAPIClient, mgr token.Manager) error {
|
||||
@@ -184,54 +106,7 @@ func resolveOCMShare(ctx context.Context, ref *provider.Reference, scope *authpb
|
||||
ref.ResourceId = share.GetResourceId()
|
||||
}
|
||||
|
||||
if err := checkCacheForNestedResource(ctx, ref, share.ResourceId, client, mgr); err == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Some services like wopi don't access the shared resource relative to the
|
||||
// share root but instead relative to the shared resources parent.
|
||||
return checkRelativeReference(ctx, ref, share.ResourceId, client)
|
||||
}
|
||||
|
||||
// checkRelativeReference checks if the shared resource is being accessed via a relative reference
|
||||
// e.g.:
|
||||
// storage: abcd, space: efgh
|
||||
// /root (id: efgh)
|
||||
// - New file.txt (id: ijkl) <- shared resource
|
||||
//
|
||||
// If the requested reference looks like this:
|
||||
// Reference{ResourceId: {StorageId: "abcd", SpaceId: "efgh"}, Path: "./New file.txt"}
|
||||
// then the request is considered relative and this function would return true.
|
||||
// Only references which are relative to the immediate parent of a resource are considered valid.
|
||||
func checkRelativeReference(ctx context.Context, requested *provider.Reference, sharedResourceID *provider.ResourceId, client gateway.GatewayAPIClient) error {
|
||||
sRes, err := client.Stat(ctx, &provider.StatRequest{Ref: &provider.Reference{ResourceId: sharedResourceID}})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if sRes.Status.Code != rpc.Code_CODE_OK {
|
||||
return statuspkg.NewErrorFromCode(sRes.Status.Code, "auth interceptor")
|
||||
}
|
||||
|
||||
sharedResource := sRes.Info
|
||||
|
||||
// Is this a shared space
|
||||
if sharedResource.ParentId == nil {
|
||||
// Is the requested resource part of the shared space?
|
||||
if requested.ResourceId.StorageId != sharedResource.Id.StorageId || requested.ResourceId.SpaceId != sharedResource.Id.SpaceId {
|
||||
return errtypes.PermissionDenied("space access forbidden via public link")
|
||||
}
|
||||
} else {
|
||||
parentID := sharedResource.ParentId
|
||||
parentID.StorageId = sharedResource.Id.StorageId
|
||||
|
||||
if !utils.ResourceIDEqual(parentID, requested.ResourceId) && utils.MakeRelativePath(sharedResource.Path) != requested.Path {
|
||||
return errtypes.PermissionDenied("access forbidden via public link")
|
||||
}
|
||||
}
|
||||
|
||||
key := storagespace.FormatResourceID(sharedResourceID) + scopeDelimiter + getRefKey(requested)
|
||||
_ = scopeExpansionCache.SetWithExpire(key, nil, scopeCacheExpiration*time.Second)
|
||||
return nil
|
||||
return checkIfNestedResource(ctx, ref, share.ResourceId, client, mgr)
|
||||
}
|
||||
|
||||
func resolveUserShare(ctx context.Context, ref *provider.Reference, scope *authpb.Scope, client gateway.GatewayAPIClient, mgr token.Manager) error {
|
||||
@@ -241,105 +116,99 @@ func resolveUserShare(ctx context.Context, ref *provider.Reference, scope *authp
|
||||
return err
|
||||
}
|
||||
|
||||
return checkCacheForNestedResource(ctx, ref, share.ResourceId, client, mgr)
|
||||
return checkIfNestedResource(ctx, ref, share.ResourceId, client, mgr)
|
||||
}
|
||||
|
||||
func checkCacheForNestedResource(ctx context.Context, ref *provider.Reference, resource *provider.ResourceId, client gateway.GatewayAPIClient, mgr token.Manager) error {
|
||||
// Check if this ref is cached
|
||||
key := storagespace.FormatResourceID(resource) + scopeDelimiter + getRefKey(ref)
|
||||
if _, err := scopeExpansionCache.Get(key); err == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
if ok, err := checkIfNestedResource(ctx, ref, resource, client, mgr); err == nil && ok {
|
||||
_ = scopeExpansionCache.SetWithExpire(key, nil, scopeCacheExpiration*time.Second)
|
||||
return nil
|
||||
}
|
||||
|
||||
return errtypes.PermissionDenied("request is not for a nested resource")
|
||||
}
|
||||
|
||||
func checkIfNestedResource(ctx context.Context, ref *provider.Reference, parent *provider.ResourceId, client gateway.GatewayAPIClient, mgr token.Manager) (bool, error) {
|
||||
func checkIfNestedResource(ctx context.Context, ref *provider.Reference, shareRoot *provider.ResourceId, client gateway.GatewayAPIClient, mgr token.Manager) error {
|
||||
// Since the resource ID is obtained from the scope, the current token
|
||||
// has access to it.
|
||||
statResponse, err := client.Stat(ctx, &provider.StatRequest{Ref: &provider.Reference{ResourceId: parent}})
|
||||
rootStat, err := client.Stat(ctx, &provider.StatRequest{Ref: &provider.Reference{ResourceId: shareRoot}})
|
||||
if err != nil {
|
||||
return false, err
|
||||
return err
|
||||
}
|
||||
if statResponse.GetStatus().GetCode() != rpc.Code_CODE_OK {
|
||||
return false, statuspkg.NewErrorFromCode(statResponse.Status.Code, "auth interceptor")
|
||||
if rootStat.GetStatus().GetCode() != rpc.Code_CODE_OK {
|
||||
return statuspkg.NewErrorFromCode(rootStat.Status.Code, "auth interceptor")
|
||||
}
|
||||
|
||||
pathResp, err := client.GetPath(ctx, &provider.GetPathRequest{ResourceId: statResponse.GetInfo().GetId()})
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
if pathResp.Status.Code != rpc.Code_CODE_OK {
|
||||
return false, statuspkg.NewErrorFromCode(pathResp.Status.Code, "auth interceptor")
|
||||
}
|
||||
parentPath := pathResp.Path
|
||||
rootInfo := rootStat.GetInfo()
|
||||
|
||||
childPath := ref.GetPath()
|
||||
if childPath != "" && childPath != "." && strings.HasPrefix(childPath, parentPath) {
|
||||
// if the request is relative from the root, we can return directly
|
||||
return true, nil
|
||||
}
|
||||
|
||||
// The request is not relative to the root. We need to find out if the requested resource is child of the `parent` (coming from token scope)
|
||||
// We need to find out if the requested resource is a child of the `shareRoot` (coming from token scope)
|
||||
// We mint a token as the owner of the public share and try to stat the reference
|
||||
// TODO(ishank011): We need to find a better alternative to this
|
||||
// NOTE: did somebody say service accounts? ...
|
||||
|
||||
var user *userpb.User
|
||||
if statResponse.GetInfo().GetOwner().GetType() == userpb.UserType_USER_TYPE_SPACE_OWNER {
|
||||
if rootInfo.GetOwner().GetType() == userpb.UserType_USER_TYPE_SPACE_OWNER {
|
||||
// fake a space owner user
|
||||
user = &userpb.User{
|
||||
Id: statResponse.GetInfo().GetOwner(),
|
||||
Id: rootInfo.GetOwner(),
|
||||
}
|
||||
} else {
|
||||
userResp, err := client.GetUser(ctx, &userpb.GetUserRequest{UserId: statResponse.Info.Owner, SkipFetchingUserGroups: true})
|
||||
userResp, err := client.GetUser(ctx, &userpb.GetUserRequest{UserId: rootInfo.GetOwner(), SkipFetchingUserGroups: true})
|
||||
if err != nil || userResp.Status.Code != rpc.Code_CODE_OK {
|
||||
return false, err
|
||||
return err
|
||||
}
|
||||
user = userResp.User
|
||||
}
|
||||
|
||||
scope, err := scope.AddOwnerScope(map[string]*authpb.Scope{})
|
||||
if err != nil {
|
||||
return false, err
|
||||
return err
|
||||
}
|
||||
token, err := mgr.MintToken(ctx, user, scope)
|
||||
if err != nil {
|
||||
return false, err
|
||||
return err
|
||||
}
|
||||
ctx = metadata.AppendToOutgoingContext(context.Background(), ctxpkg.TokenHeader, token)
|
||||
|
||||
childStat, err := client.Stat(ctx, &provider.StatRequest{Ref: ref})
|
||||
resourceStat, err := client.Stat(ctx, &provider.StatRequest{Ref: ref})
|
||||
if err != nil {
|
||||
return false, err
|
||||
return err
|
||||
}
|
||||
if childStat.GetStatus().GetCode() == rpc.Code_CODE_NOT_FOUND && ref.GetPath() != "" && ref.GetPath() != "." {
|
||||
if resourceStat.GetStatus().GetCode() == rpc.Code_CODE_NOT_FOUND && ref.GetPath() != "" && ref.GetPath() != "." {
|
||||
// The resource does not seem to exist (yet?). We might be part of an initiate upload request.
|
||||
// Stat the parent to get its path and check that against the root path.
|
||||
childStat, err = client.Stat(ctx, &provider.StatRequest{Ref: &provider.Reference{ResourceId: ref.GetResourceId()}})
|
||||
resourceStat, err = client.Stat(ctx, &provider.StatRequest{Ref: &provider.Reference{ResourceId: ref.GetResourceId()}})
|
||||
if err != nil {
|
||||
return false, err
|
||||
return err
|
||||
}
|
||||
}
|
||||
if childStat.GetStatus().GetCode() != rpc.Code_CODE_OK {
|
||||
return false, statuspkg.NewErrorFromCode(childStat.Status.Code, "auth interceptor")
|
||||
if resourceStat.GetStatus().GetCode() != rpc.Code_CODE_OK {
|
||||
return statuspkg.NewErrorFromCode(resourceStat.Status.Code, "auth interceptor")
|
||||
}
|
||||
pathResp, err = client.GetPath(ctx, &provider.GetPathRequest{ResourceId: childStat.GetInfo().GetId()})
|
||||
|
||||
// Check if the resource and the share root are in the same storage space
|
||||
ci := resourceStat.GetInfo()
|
||||
if ci.GetId().GetStorageId() != rootInfo.GetId().GetStorageId() ||
|
||||
ci.GetId().GetSpaceId() != rootInfo.GetId().GetSpaceId() {
|
||||
return errtypes.PermissionDenied("invalid resource")
|
||||
}
|
||||
|
||||
// check if the resource path is subpath of the share root path
|
||||
rootPath, err := getPath(ctx, rootStat.GetInfo().GetId(), client)
|
||||
if err != nil {
|
||||
return false, err
|
||||
return err
|
||||
}
|
||||
if pathResp.GetStatus().GetCode() != rpc.Code_CODE_OK {
|
||||
return false, statuspkg.NewErrorFromCode(pathResp.Status.Code, "auth interceptor")
|
||||
|
||||
resourcePath, err := getPath(ctx, resourceStat.GetInfo().GetId(), client)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
childPath = pathResp.Path
|
||||
|
||||
return strings.HasPrefix(childPath, parentPath), nil
|
||||
if rootPath == "/" || resourcePath == rootPath || strings.HasPrefix(resourcePath, rootPath+"/") {
|
||||
return nil
|
||||
}
|
||||
|
||||
return errtypes.PermissionDenied("invalid resource")
|
||||
}
|
||||
|
||||
func getPath(ctx context.Context, resourceId *provider.ResourceId, client gateway.GatewayAPIClient) (string, error) {
|
||||
pathResp, err := client.GetPath(ctx, &provider.GetPathRequest{ResourceId: resourceId})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if pathResp.Status.Code != rpc.Code_CODE_OK {
|
||||
return "", statuspkg.NewErrorFromCode(pathResp.Status.Code, "auth interceptor")
|
||||
}
|
||||
return pathResp.Path, nil
|
||||
}
|
||||
|
||||
func extractRefFromListProvidersReq(v *registry.ListStorageProvidersRequest) (*provider.Reference, bool) {
|
||||
@@ -503,27 +372,3 @@ func extractRef(req interface{}, tokenScope map[string]*authpb.Scope) (*provider
|
||||
|
||||
return nil, false
|
||||
}
|
||||
|
||||
func extractShareRef(req interface{}) (*collaboration.ShareReference, bool) {
|
||||
switch v := req.(type) {
|
||||
case *collaboration.GetReceivedShareRequest:
|
||||
return v.GetRef(), true
|
||||
case *collaboration.UpdateReceivedShareRequest:
|
||||
return &collaboration.ShareReference{Spec: &collaboration.ShareReference_Id{Id: v.GetShare().GetShare().GetId()}}, true
|
||||
}
|
||||
return nil, false
|
||||
}
|
||||
|
||||
func getRefKey(ref *provider.Reference) string {
|
||||
if ref.GetPath() != "" {
|
||||
return ref.Path
|
||||
}
|
||||
|
||||
if ref.GetResourceId() != nil {
|
||||
return storagespace.FormatResourceID(ref.ResourceId)
|
||||
}
|
||||
|
||||
// on malicious request both path and rid could be empty
|
||||
// we still should not panic
|
||||
return ""
|
||||
}
|
||||
Vendored
+2
-2
@@ -1313,8 +1313,8 @@ github.com/orcaman/concurrent-map
|
||||
# github.com/owncloud/libre-graph-api-go v1.0.5-0.20260116104114-10074a92be64
|
||||
## explicit; go 1.18
|
||||
github.com/owncloud/libre-graph-api-go
|
||||
# github.com/owncloud/reva/v2 v2.0.0-20260123085534-22a1be2b211e
|
||||
## explicit; go 1.24.0
|
||||
# github.com/owncloud/reva/v2 v2.0.0-20260209172723-6b94461c2a1a
|
||||
## explicit; go 1.25
|
||||
github.com/owncloud/reva/v2/cmd/revad/internal/grace
|
||||
github.com/owncloud/reva/v2/cmd/revad/runtime
|
||||
github.com/owncloud/reva/v2/internal/grpc/interceptors/appctx
|
||||
|
||||
Reference in new issue
Block a user