Skip to content

Commit

Permalink
fix the returned permissions for webdav uploads (#2179)
Browse files Browse the repository at this point in the history
  • Loading branch information
wkloucek authored Oct 19, 2021
1 parent 284ce0f commit 2fcbe16
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
7 changes: 7 additions & 0 deletions changelog/unreleased/fix-webdav-upload-permissions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Bugfix: Fix the returned permissions for webdav uploads

We've fixed the returned permissions for webdav uploads. It did not consider
shares and public links for the permission calculation, but does so now.

https://github.com/cs3org/reva/pull/2179
https://github.com/cs3org/reva/pull/2151
15 changes: 13 additions & 2 deletions internal/http/services/owncloud/ocdav/tus.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@ package ocdav

import (
"context"
"encoding/json"
"net/http"
"path"
"strconv"
"strings"
"time"

rpc "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"
typespb "github.com/cs3org/go-cs3apis/cs3/types/v1beta1"
"github.com/cs3org/reva/internal/http/services/owncloud/ocs/conversions"
Expand Down Expand Up @@ -297,12 +299,21 @@ func (s *svc) handleTusPost(ctx context.Context, w http.ResponseWriter, r *http.
}

// get WebDav permissions for file
isPublic := false
if info.Opaque != nil && info.Opaque.Map != nil {
if info.Opaque.Map["link-share"] != nil && info.Opaque.Map["link-share"].Decoder == "json" {
ls := &link.PublicShare{}
_ = json.Unmarshal(info.Opaque.Map["link-share"].Value, ls)
isPublic = ls != nil
}
}
isShared := !isCurrentUserOwner(ctx, info.Owner)
role := conversions.RoleFromResourcePermissions(info.PermissionSet)
permissions := role.WebDAVPermissions(
info.Type == provider.ResourceType_RESOURCE_TYPE_CONTAINER,
isShared,
false,
false,
false,
isPublic,
)

w.Header().Set(HeaderContentType, info.MimeType)
Expand Down

0 comments on commit 2fcbe16

Please sign in to comment.