From 93377d96c0c79b6bc9097870a0b128cf6bcb704c Mon Sep 17 00:00:00 2001 From: Roman Perekhod <2403905@gmail.com> Date: Mon, 20 Apr 2026 12:01:32 +0200 Subject: [PATCH 1/2] fix: fixed the internal links access control --- .drone.env | 2 +- changelog/unreleased/fix-internal-links.md | 5 ++ .../http/services/ocmd/notifications.go | 62 ++++++++++++++++++- .../v2/internal/http/services/ocmd/ocm.go | 2 + .../auth/manager/publicshares/publicshares.go | 8 +++ .../utils/decomposedfs/upload/upload.go | 2 +- 6 files changed, 76 insertions(+), 5 deletions(-) create mode 100644 changelog/unreleased/fix-internal-links.md diff --git a/.drone.env b/.drone.env index 2cd4b1b7284..15e2e004970 100644 --- a/.drone.env +++ b/.drone.env @@ -1,3 +1,3 @@ # The test runner source for UI tests WEB_COMMITID=6165b4e47a47e3a216107e96f90825190f10632e -WEB_BRANCH=stable-12.3 +WEB_BRANCH=stable-12.3 \ No newline at end of file diff --git a/changelog/unreleased/fix-internal-links.md b/changelog/unreleased/fix-internal-links.md new file mode 100644 index 00000000000..ebe22fcc9c6 --- /dev/null +++ b/changelog/unreleased/fix-internal-links.md @@ -0,0 +1,5 @@ +Bugfix: Fix the internal links + +We fixed the internal links access control + +https://github.com/owncloud/ocis/pull/12231 diff --git a/vendor/github.com/owncloud/reva/v2/internal/http/services/ocmd/notifications.go b/vendor/github.com/owncloud/reva/v2/internal/http/services/ocmd/notifications.go index 37fa1b709d5..86f1ec1c059 100644 --- a/vendor/github.com/owncloud/reva/v2/internal/http/services/ocmd/notifications.go +++ b/vendor/github.com/owncloud/reva/v2/internal/http/services/ocmd/notifications.go @@ -28,6 +28,7 @@ import ( gateway "github.com/cs3org/go-cs3apis/cs3/gateway/v1beta1" ocmcore "github.com/cs3org/go-cs3apis/cs3/ocm/core/v1beta1" rpc "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1" + ocm "github.com/cs3org/go-cs3apis/cs3/sharing/ocm/v1beta1" typesv1beta1 "github.com/cs3org/go-cs3apis/cs3/types/v1beta1" "github.com/go-chi/render" "github.com/owncloud/reva/v2/pkg/appctx" @@ -43,7 +44,9 @@ const ( // var validate = validator.New() type notifHandler struct { - gatewaySelector *pool.Selector[gateway.GatewayAPIClient] + gatewaySelector *pool.Selector[gateway.GatewayAPIClient] + serviceAccountID string + serviceAccountSecret string } func (h *notifHandler) init(c *config) error { @@ -52,6 +55,8 @@ func (h *notifHandler) init(c *config) error { return err } h.gatewaySelector = gatewaySelector + h.serviceAccountID = c.ServiceAccountID + h.serviceAccountSecret = c.ServiceAccountSecret return nil } @@ -161,6 +166,7 @@ func (h *notifHandler) handleShareUnshared(ctx context.Context, req *notificatio return res.GetStatus(), nil } +// Current implementation supports only WebDAV protocol permissions update func (h *notifHandler) handleShareChangePermission(ctx context.Context, req *notificationRequest) (*rpc.Status, error) { gatewayClient, err := h.gatewaySelector.Next() if err != nil { @@ -171,17 +177,67 @@ func (h *notifHandler) handleShareChangePermission(ctx context.Context, req *not return nil, fmt.Errorf("error getting protocols from notification") } + // get the grantee user ID object + granteeUser, err := getUserIDFromOCMUser(req.Notification.Grantee) + if err != nil { + return nil, fmt.Errorf("error getting grantee user id: %w", err) + } + + // authenticate as a service account + authCtx, err := utils.GetServiceUserContextWithContext(ctx, gatewayClient, h.serviceAccountID, h.serviceAccountSecret) + if err != nil { + return nil, fmt.Errorf("error authenticating as service account: %w", err) + } + ctx = authCtx + o := &typesv1beta1.Opaque{} utils.AppendPlainToOpaque(o, "grantee", req.Notification.Grantee) utils.AppendPlainToOpaque(o, "resourceType", req.ResourceType) + getRes, err := gatewayClient.GetReceivedOCMShare(ctx, &ocm.GetReceivedOCMShareRequest{ + Opaque: utils.AppendJSONToOpaque(nil, "userid", granteeUser), + Ref: &ocm.ShareReference{ + Spec: &ocm.ShareReference_Id{ + Id: &ocm.ShareId{ + OpaqueId: req.ProviderId, + }, + }, + }, + }) + if err != nil { + return nil, fmt.Errorf("error getting received ocm share: %w", err) + } + if getRes.Status.Code != rpc.Code_CODE_OK { + return getRes.Status, nil + } + + share := getRes.Share + newProtocols := getProtocols(req.Notification.Protocols, o) + + var newWebdav *ocm.WebDAVProtocol + for _, p := range newProtocols { + if wd := p.GetWebdavOptions(); wd != nil { + newWebdav = wd + break + } + } + + if newWebdav != nil && newWebdav.Permissions != nil { + for _, p := range share.Protocols { + if wd := p.GetWebdavOptions(); wd != nil { + wd.Permissions = newWebdav.Permissions + break + } + } + } + res, err := gatewayClient.UpdateOCMCoreShare(ctx, &ocmcore.UpdateOCMCoreShareRequest{ OcmShareId: req.ProviderId, - Protocols: getProtocols(req.Notification.Protocols, o), + Protocols: share.Protocols, Opaque: o, }) if err != nil { - return nil, fmt.Errorf("error calling DeleteOCMCoreShare: %w", err) + return nil, fmt.Errorf("error calling UpdateOCMCoreShare: %w", err) } return res.GetStatus(), nil } diff --git a/vendor/github.com/owncloud/reva/v2/internal/http/services/ocmd/ocm.go b/vendor/github.com/owncloud/reva/v2/internal/http/services/ocmd/ocm.go index 2b849e02793..dc55ec90ce1 100644 --- a/vendor/github.com/owncloud/reva/v2/internal/http/services/ocmd/ocm.go +++ b/vendor/github.com/owncloud/reva/v2/internal/http/services/ocmd/ocm.go @@ -37,6 +37,8 @@ type config struct { Prefix string `mapstructure:"prefix"` GatewaySvc string `mapstructure:"gatewaysvc" validate:"required"` ExposeRecipientDisplayName bool `mapstructure:"expose_recipient_display_name"` + ServiceAccountID string `mapstructure:"service_account_id"` + ServiceAccountSecret string `mapstructure:"service_account_secret"` } func (c *config) ApplyDefaults() { diff --git a/vendor/github.com/owncloud/reva/v2/pkg/auth/manager/publicshares/publicshares.go b/vendor/github.com/owncloud/reva/v2/pkg/auth/manager/publicshares/publicshares.go index e28fc869ff3..5c56275d78f 100644 --- a/vendor/github.com/owncloud/reva/v2/pkg/auth/manager/publicshares/publicshares.go +++ b/vendor/github.com/owncloud/reva/v2/pkg/auth/manager/publicshares/publicshares.go @@ -27,6 +27,7 @@ import ( user "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1" rpcv1beta1 "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1" link "github.com/cs3org/go-cs3apis/cs3/sharing/link/v1beta1" + provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1" types "github.com/cs3org/go-cs3apis/cs3/types/v1beta1" "github.com/mitchellh/mapstructure" "github.com/owncloud/reva/v2/pkg/auth" @@ -34,6 +35,7 @@ import ( "github.com/owncloud/reva/v2/pkg/auth/scope" "github.com/owncloud/reva/v2/pkg/errtypes" "github.com/owncloud/reva/v2/pkg/rgrpc/todo/pool" + "github.com/owncloud/reva/v2/pkg/storage/utils/grants" "github.com/owncloud/reva/v2/pkg/store" "github.com/owncloud/reva/v2/pkg/utils" "github.com/pkg/errors" @@ -162,6 +164,12 @@ func (m *manager) Authenticate(ctx context.Context, token, secret string) (*user return nil, nil, errtypes.InternalError(publicShareResponse.Status.Message) } + // Reject internal links — they require authentication and cannot be accessed anonymously. + // An internal link has no effective permissions. + if grants.PermissionsEqual(publicShareResponse.GetShare().GetPermissions().GetPermissions(), &provider.ResourcePermissions{}) { + return nil, nil, errtypes.PermissionDenied("internal links require authentication and cannot be accessed anonymously") + } + var owner *user.User // FIXME use new user type SPACE_OWNER if publicShareResponse.GetShare().GetOwner().GetType() == 8 { diff --git a/vendor/github.com/owncloud/reva/v2/pkg/storage/utils/decomposedfs/upload/upload.go b/vendor/github.com/owncloud/reva/v2/pkg/storage/utils/decomposedfs/upload/upload.go index 97b506d855c..2880fa999c0 100644 --- a/vendor/github.com/owncloud/reva/v2/pkg/storage/utils/decomposedfs/upload/upload.go +++ b/vendor/github.com/owncloud/reva/v2/pkg/storage/utils/decomposedfs/upload/upload.go @@ -238,7 +238,7 @@ func (session *OcisSession) FinishUploadDecomposed(ctx context.Context) error { if !session.store.async || session.info.Size == 0 { // handle postprocessing synchronously err = session.Finalize(ctx) - session.Cleanup(err != nil, true, true, true) + session.Cleanup(err != nil, err == nil, true, true) if err != nil { log.Error().Err(err).Msg("failed to upload") return err From 30827044c03d3fb0aece1c86154e29108e17cc25 Mon Sep 17 00:00:00 2001 From: Roman Perekhod <2403905@gmail.com> Date: Fri, 24 Apr 2026 11:50:42 +0200 Subject: [PATCH 2/2] use the web stable-12.3 latest --- .drone.env | 4 +- go.sum | 4 -- .../http/services/ocmd/notifications.go | 62 +------------------ .../v2/internal/http/services/ocmd/ocm.go | 2 - .../auth/manager/publicshares/publicshares.go | 8 --- .../utils/decomposedfs/upload/upload.go | 2 +- 6 files changed, 6 insertions(+), 76 deletions(-) diff --git a/.drone.env b/.drone.env index 15e2e004970..c6456cf0cd9 100644 --- a/.drone.env +++ b/.drone.env @@ -1,3 +1,3 @@ # The test runner source for UI tests -WEB_COMMITID=6165b4e47a47e3a216107e96f90825190f10632e -WEB_BRANCH=stable-12.3 \ No newline at end of file +WEB_COMMITID=1943bc0002d551291baaff12060d424d1f65ef45 +WEB_BRANCH=stable-12.3 diff --git a/go.sum b/go.sum index 7ab50aa6e36..3602269c45d 100644 --- a/go.sum +++ b/go.sum @@ -742,10 +742,6 @@ 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-20260305165853-c9204c730c66 h1:Krzzphe3EkE09Enxy6s5eIFPNF6Kodw/H8EcHo+jT+E= -github.com/owncloud/reva/v2 v2.0.0-20260305165853-c9204c730c66/go.mod h1:eHbT6pmVlcjdiBeVEYw7exlfJmemMzKBh4R+HFgx9Cc= -github.com/owncloud/reva/v2 v2.0.0-20260422074541-76ccb5a8a681 h1:OQggVr2fg23feOlcm/qgAUAgZjNDkYnJT7CKNwKyet8= -github.com/owncloud/reva/v2 v2.0.0-20260422074541-76ccb5a8a681/go.mod h1:eHbT6pmVlcjdiBeVEYw7exlfJmemMzKBh4R+HFgx9Cc= github.com/owncloud/reva/v2 v2.0.0-20260422094911-a697030257f5 h1:G0klmj4V7z7U1nYm0GzgEN+G4C/g5yajnG5FQdsF6ec= github.com/owncloud/reva/v2 v2.0.0-20260422094911-a697030257f5/go.mod h1:eHbT6pmVlcjdiBeVEYw7exlfJmemMzKBh4R+HFgx9Cc= github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c h1:rp5dCmg/yLR3mgFuSOe4oEnDDmGLROTvMragMUXpTQw= diff --git a/vendor/github.com/owncloud/reva/v2/internal/http/services/ocmd/notifications.go b/vendor/github.com/owncloud/reva/v2/internal/http/services/ocmd/notifications.go index 86f1ec1c059..37fa1b709d5 100644 --- a/vendor/github.com/owncloud/reva/v2/internal/http/services/ocmd/notifications.go +++ b/vendor/github.com/owncloud/reva/v2/internal/http/services/ocmd/notifications.go @@ -28,7 +28,6 @@ import ( gateway "github.com/cs3org/go-cs3apis/cs3/gateway/v1beta1" ocmcore "github.com/cs3org/go-cs3apis/cs3/ocm/core/v1beta1" rpc "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1" - ocm "github.com/cs3org/go-cs3apis/cs3/sharing/ocm/v1beta1" typesv1beta1 "github.com/cs3org/go-cs3apis/cs3/types/v1beta1" "github.com/go-chi/render" "github.com/owncloud/reva/v2/pkg/appctx" @@ -44,9 +43,7 @@ const ( // var validate = validator.New() type notifHandler struct { - gatewaySelector *pool.Selector[gateway.GatewayAPIClient] - serviceAccountID string - serviceAccountSecret string + gatewaySelector *pool.Selector[gateway.GatewayAPIClient] } func (h *notifHandler) init(c *config) error { @@ -55,8 +52,6 @@ func (h *notifHandler) init(c *config) error { return err } h.gatewaySelector = gatewaySelector - h.serviceAccountID = c.ServiceAccountID - h.serviceAccountSecret = c.ServiceAccountSecret return nil } @@ -166,7 +161,6 @@ func (h *notifHandler) handleShareUnshared(ctx context.Context, req *notificatio return res.GetStatus(), nil } -// Current implementation supports only WebDAV protocol permissions update func (h *notifHandler) handleShareChangePermission(ctx context.Context, req *notificationRequest) (*rpc.Status, error) { gatewayClient, err := h.gatewaySelector.Next() if err != nil { @@ -177,67 +171,17 @@ func (h *notifHandler) handleShareChangePermission(ctx context.Context, req *not return nil, fmt.Errorf("error getting protocols from notification") } - // get the grantee user ID object - granteeUser, err := getUserIDFromOCMUser(req.Notification.Grantee) - if err != nil { - return nil, fmt.Errorf("error getting grantee user id: %w", err) - } - - // authenticate as a service account - authCtx, err := utils.GetServiceUserContextWithContext(ctx, gatewayClient, h.serviceAccountID, h.serviceAccountSecret) - if err != nil { - return nil, fmt.Errorf("error authenticating as service account: %w", err) - } - ctx = authCtx - o := &typesv1beta1.Opaque{} utils.AppendPlainToOpaque(o, "grantee", req.Notification.Grantee) utils.AppendPlainToOpaque(o, "resourceType", req.ResourceType) - getRes, err := gatewayClient.GetReceivedOCMShare(ctx, &ocm.GetReceivedOCMShareRequest{ - Opaque: utils.AppendJSONToOpaque(nil, "userid", granteeUser), - Ref: &ocm.ShareReference{ - Spec: &ocm.ShareReference_Id{ - Id: &ocm.ShareId{ - OpaqueId: req.ProviderId, - }, - }, - }, - }) - if err != nil { - return nil, fmt.Errorf("error getting received ocm share: %w", err) - } - if getRes.Status.Code != rpc.Code_CODE_OK { - return getRes.Status, nil - } - - share := getRes.Share - newProtocols := getProtocols(req.Notification.Protocols, o) - - var newWebdav *ocm.WebDAVProtocol - for _, p := range newProtocols { - if wd := p.GetWebdavOptions(); wd != nil { - newWebdav = wd - break - } - } - - if newWebdav != nil && newWebdav.Permissions != nil { - for _, p := range share.Protocols { - if wd := p.GetWebdavOptions(); wd != nil { - wd.Permissions = newWebdav.Permissions - break - } - } - } - res, err := gatewayClient.UpdateOCMCoreShare(ctx, &ocmcore.UpdateOCMCoreShareRequest{ OcmShareId: req.ProviderId, - Protocols: share.Protocols, + Protocols: getProtocols(req.Notification.Protocols, o), Opaque: o, }) if err != nil { - return nil, fmt.Errorf("error calling UpdateOCMCoreShare: %w", err) + return nil, fmt.Errorf("error calling DeleteOCMCoreShare: %w", err) } return res.GetStatus(), nil } diff --git a/vendor/github.com/owncloud/reva/v2/internal/http/services/ocmd/ocm.go b/vendor/github.com/owncloud/reva/v2/internal/http/services/ocmd/ocm.go index dc55ec90ce1..2b849e02793 100644 --- a/vendor/github.com/owncloud/reva/v2/internal/http/services/ocmd/ocm.go +++ b/vendor/github.com/owncloud/reva/v2/internal/http/services/ocmd/ocm.go @@ -37,8 +37,6 @@ type config struct { Prefix string `mapstructure:"prefix"` GatewaySvc string `mapstructure:"gatewaysvc" validate:"required"` ExposeRecipientDisplayName bool `mapstructure:"expose_recipient_display_name"` - ServiceAccountID string `mapstructure:"service_account_id"` - ServiceAccountSecret string `mapstructure:"service_account_secret"` } func (c *config) ApplyDefaults() { diff --git a/vendor/github.com/owncloud/reva/v2/pkg/auth/manager/publicshares/publicshares.go b/vendor/github.com/owncloud/reva/v2/pkg/auth/manager/publicshares/publicshares.go index 5c56275d78f..e28fc869ff3 100644 --- a/vendor/github.com/owncloud/reva/v2/pkg/auth/manager/publicshares/publicshares.go +++ b/vendor/github.com/owncloud/reva/v2/pkg/auth/manager/publicshares/publicshares.go @@ -27,7 +27,6 @@ import ( user "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1" rpcv1beta1 "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1" link "github.com/cs3org/go-cs3apis/cs3/sharing/link/v1beta1" - provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1" types "github.com/cs3org/go-cs3apis/cs3/types/v1beta1" "github.com/mitchellh/mapstructure" "github.com/owncloud/reva/v2/pkg/auth" @@ -35,7 +34,6 @@ import ( "github.com/owncloud/reva/v2/pkg/auth/scope" "github.com/owncloud/reva/v2/pkg/errtypes" "github.com/owncloud/reva/v2/pkg/rgrpc/todo/pool" - "github.com/owncloud/reva/v2/pkg/storage/utils/grants" "github.com/owncloud/reva/v2/pkg/store" "github.com/owncloud/reva/v2/pkg/utils" "github.com/pkg/errors" @@ -164,12 +162,6 @@ func (m *manager) Authenticate(ctx context.Context, token, secret string) (*user return nil, nil, errtypes.InternalError(publicShareResponse.Status.Message) } - // Reject internal links — they require authentication and cannot be accessed anonymously. - // An internal link has no effective permissions. - if grants.PermissionsEqual(publicShareResponse.GetShare().GetPermissions().GetPermissions(), &provider.ResourcePermissions{}) { - return nil, nil, errtypes.PermissionDenied("internal links require authentication and cannot be accessed anonymously") - } - var owner *user.User // FIXME use new user type SPACE_OWNER if publicShareResponse.GetShare().GetOwner().GetType() == 8 { diff --git a/vendor/github.com/owncloud/reva/v2/pkg/storage/utils/decomposedfs/upload/upload.go b/vendor/github.com/owncloud/reva/v2/pkg/storage/utils/decomposedfs/upload/upload.go index 2880fa999c0..97b506d855c 100644 --- a/vendor/github.com/owncloud/reva/v2/pkg/storage/utils/decomposedfs/upload/upload.go +++ b/vendor/github.com/owncloud/reva/v2/pkg/storage/utils/decomposedfs/upload/upload.go @@ -238,7 +238,7 @@ func (session *OcisSession) FinishUploadDecomposed(ctx context.Context) error { if !session.store.async || session.info.Size == 0 { // handle postprocessing synchronously err = session.Finalize(ctx) - session.Cleanup(err != nil, err == nil, true, true) + session.Cleanup(err != nil, true, true, true) if err != nil { log.Error().Err(err).Msg("failed to upload") return err