Patch an issue preventing perms from properly being inherited
This commit is contained in:
parent
337f8bccd9
commit
9909ffe92c
@ -63,13 +63,13 @@ public enum PermissionGroup
|
|||||||
|
|
||||||
static
|
static
|
||||||
{
|
{
|
||||||
MutableGraph<PermissionGroup> _builder = GraphBuilder.directed().build();
|
MutableGraph<PermissionGroup> builder = GraphBuilder.directed().build();
|
||||||
|
|
||||||
// Add each group as a node, and add edges between parent (inherited) and child nodes
|
// Add each group as a node, and add edges between parent (inherited) and child nodes
|
||||||
Stream.of(PermissionGroup.values()).peek(_builder::addNode).forEach(group ->
|
Stream.of(PermissionGroup.values()).peek(builder::addNode).forEach(group ->
|
||||||
group._parentGroups.forEach(parent -> _builder.putEdge(parent, group)));
|
group._parentGroups.forEach(parent -> builder.putEdge(parent, group)));
|
||||||
|
|
||||||
_groupHierarchy = ImmutableGraph.copyOf(_builder);
|
_groupHierarchy = ImmutableGraph.copyOf(builder);
|
||||||
}
|
}
|
||||||
|
|
||||||
// We want a graph so we can walk the hierarchy downward and recalculate permissions when needed
|
// We want a graph so we can walk the hierarchy downward and recalculate permissions when needed
|
||||||
@ -144,25 +144,9 @@ public enum PermissionGroup
|
|||||||
|
|
||||||
private void bakePermissions()
|
private void bakePermissions()
|
||||||
{
|
{
|
||||||
// Calculate inherited permissions
|
_bakedPerms = calculateInheritable();
|
||||||
Map<Permission, Boolean> inherited = calculateInheritable();
|
_bakedPerms.putAll(_specificPerms);
|
||||||
|
_groupHierarchy.successors(this).forEach(PermissionGroup::bakePermissions);
|
||||||
// Now: walk down the group hierarchy and bake permissions
|
|
||||||
bakeForward(inherited);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void bakeForward(Map<Permission, Boolean> inherited)
|
|
||||||
{
|
|
||||||
_bakedPerms = new IdentityHashMap<>();
|
|
||||||
_bakedPerms.putAll(inherited);
|
|
||||||
_bakedPerms.putAll(_specificPerms); // Specific permissions override inheritable ones
|
|
||||||
|
|
||||||
_groupHierarchy.successors(this).forEach(successor ->
|
|
||||||
{
|
|
||||||
Map<Permission, Boolean> newInherited = new IdentityHashMap<>(inherited);
|
|
||||||
newInherited.putAll(successor._inheritablePerms);
|
|
||||||
successor.bakeForward(newInherited);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate inheritable permissions from parent nodes and this node
|
// Calculate inheritable permissions from parent nodes and this node
|
||||||
|
Loading…
Reference in New Issue
Block a user