Skip to content

Commit

Permalink
Give all permissions to the resource owner
Browse files Browse the repository at this point in the history
  • Loading branch information
ishank011 committed Feb 2, 2021
1 parent 685a597 commit 886df41
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions pkg/storage/utils/eosfs/eosfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -1311,14 +1311,38 @@ func (fs *eosfs) convertToFileReference(ctx context.Context, eosFileInfo *eoscli
}

// permissionSet returns the permission set for the current user
func (fs *eosfs) permissionSet(ctx context.Context, eosFileInfo *eosclient.FileInfo) *provider.ResourcePermissions {
func (fs *eosfs) permissionSet(ctx context.Context, eosFileInfo *eosclient.FileInfo, owner *userpb.UserId) *provider.ResourcePermissions {
u, ok := user.ContextGetUserID(ctx)
if !ok {
return &provider.ResourcePermissions{
// no permissions
}
}

if u.OpaqueId == owner.OpaqueId && u.Idp == owner.Idp {
return &provider.ResourcePermissions{
// owner has all permissions
AddGrant: true,
CreateContainer: true,
Delete: true,
GetPath: true,
GetQuota: true,
InitiateFileDownload: true,
InitiateFileUpload: true,
ListContainer: true,
ListFileVersions: true,
ListGrants: true,
ListRecycle: true,
Move: true,
PurgeRecycle: true,
RemoveGrant: true,
RestoreFileVersion: true,
RestoreRecycleItem: true,
Stat: true,
UpdateGrant: true,
}
}

var perm string
var rp *provider.ResourcePermissions
for _, e := range eosFileInfo.SysACL.Entries {
Expand Down Expand Up @@ -1395,7 +1419,7 @@ func (fs *eosfs) convert(ctx context.Context, eosFileInfo *eosclient.FileInfo) (
Etag: fmt.Sprintf("\"%s\"", strings.Trim(eosFileInfo.ETag, "\"")),
MimeType: mime.Detect(eosFileInfo.IsDir, path),
Size: size,
PermissionSet: fs.permissionSet(ctx, eosFileInfo),
PermissionSet: fs.permissionSet(ctx, eosFileInfo, owner),
Mtime: &types.Timestamp{
Seconds: eosFileInfo.MTimeSec,
Nanos: eosFileInfo.MTimeNanos,
Expand Down

0 comments on commit 886df41

Please sign in to comment.