policy.vd
// Define folder ancestry across any nesting depth
is_ancestor(folder, item) if
parent(item, folder);
is_ancestor(ancestor, item) if
parent(item, folder) and
is_ancestor(ancestor, folder);
// Roles assigned on any ancestor folder carry down to everything inside it
has_role(user, role, item) if
is_ancestor(folder, item) and
has_role(user, role, folder);
// Map inherited or direct roles to file and folder permissions
has_permission(user, "read", item) if
has_role(user, "viewer", item) or
has_role(user, "editor", item);
has_permission(user, "edit", item) if
has_role(user, "editor", item);