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

Deny Access Correctly for Groups #3823

Merged
merged 1 commit into from
Apr 27, 2023
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/correctly-deny.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Bugfix: Deny correctlty in decomposedfs

Decomposedfs had problems denying resources for groups. This is now fixed

https://github.com/cs3org/reva/pull/3823
47 changes: 37 additions & 10 deletions pkg/storage/utils/decomposedfs/node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -1046,19 +1046,46 @@ func (n *Node) ReadUserPermissions(ctx context.Context, u *userpb.User) (ap prov

// IsDenied checks if the node was denied to that user
func (n *Node) IsDenied(ctx context.Context) bool {
u := ctxpkg.ContextMustGetUser(ctx)
userace := prefixes.GrantUserAcePrefix + u.Id.OpaqueId
g, err := n.ReadGrant(ctx, userace)
switch {
case err == nil:
// If all permissions are set to false we have a deny grant
return grants.PermissionsEqual(g.Permissions, &provider.ResourcePermissions{})
case metadata.IsAttrUnset(err):
return false
default:
gs, err := n.ListGrants(ctx)
if err != nil {
// be paranoid, resource is denied
return true
}

u := ctxpkg.ContextMustGetUser(ctx)
isExecutant := func(g *provider.Grantee) bool {
switch g.GetType() {
case provider.GranteeType_GRANTEE_TYPE_USER:
return g.GetUserId().GetOpaqueId() == u.GetId().GetOpaqueId()
case provider.GranteeType_GRANTEE_TYPE_GROUP:
// check gid
gid := g.GetGroupId().GetOpaqueId()
for _, group := range u.Groups {
if gid == group {
return true
}

}
return false
default:
return false
}

}

for _, g := range gs {
if !isExecutant(g.Grantee) {
continue
}

if grants.PermissionsEqual(g.Permissions, &provider.ResourcePermissions{}) {
// resource is denied
return true
}
}

// no deny grants
return false
}

// ListGrantees lists the grantees of the current node
Expand Down