Skip to content

Commit

Permalink
Fix get user share as grantee in json backend (#1650)
Browse files Browse the repository at this point in the history
Signed-off-by: Jörn Friedrich Dreyer <[email protected]>
  • Loading branch information
butonic authored Apr 21, 2021
1 parent d2ee39b commit 9f6ab8e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
5 changes: 5 additions & 0 deletions changelog/unreleased/fix-get-user-share-as-grantee.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Bugfix: Allow fetching shares as the grantee

The json backend now allows a grantee to fetch a share by id.

https://github.com/cs3org/reva/pull/1650
11 changes: 11 additions & 0 deletions pkg/share/manager/json/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,17 @@ func (m *mgr) get(ctx context.Context, ref *collaboration.ShareReference) (s *co
return s, nil
}

// or the grantee
if s.Grantee.Type == provider.GranteeType_GRANTEE_TYPE_USER && utils.UserEqual(user.Id, s.Grantee.GetUserId()) {
return s, nil
} else if s.Grantee.Type == provider.GranteeType_GRANTEE_TYPE_GROUP {
// check if all user groups match this share; TODO(labkode): filter shares created by us.
for _, g := range user.Groups {
if g == s.Grantee.GetGroupId().OpaqueId {
return s, nil
}
}
}
// we return not found to not disclose information
return nil, errtypes.NotFound(ref.String())
}
Expand Down

0 comments on commit 9f6ab8e

Please sign in to comment.