Skip to content

Commit

Permalink
Fix nested resource check for publicly shared space root
Browse files Browse the repository at this point in the history
The space root's path is always set to ".", which makes the simple
'HasPrefix' check for whether a file a ancestor fail.

Co-Authored-By: Christian Richter <crichter@owncloud.com>
  • Loading branch information
rhafer and dragonchaser committed Apr 16, 2024
1 parent ea8ee61 commit abe3c32
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
7 changes: 7 additions & 0 deletions changelog/unreleased/fix_public_share_space_root.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Bugfix: Fix access to files withing a public link targetting a space root

We fixed an issue that prevented users from opening documents within a public share
that targets a space root.

https://github.com/cs3org/reva/pull/4632/
https://github.com/owncloud/ocis/issues/8691
5 changes: 5 additions & 0 deletions internal/grpc/interceptors/auth/scope.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,11 @@ func checkIfNestedResource(ctx context.Context, ref *provider.Reference, parent
return false, statuspkg.NewErrorFromCode(statResponse.Status.Code, "auth interceptor")
}
parentPath := statResponse.Info.Path
if utils.IsSpaceRoot(statResponse.Info) && parentPath == "." {
// The space root's path is always ".". We explicitly set it to "/" here to
// make the HasPrefix check further down work correctly.
parentPath = "/"
}

childPath := ref.GetPath()
if childPath != "" && childPath != "." && strings.HasPrefix(childPath, parentPath) {
Expand Down

0 comments on commit abe3c32

Please sign in to comment.