Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix get user share as grantee in json backend #1650

Merged
merged 1 commit into from
Apr 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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