|  |  | @ -6,28 +6,30 @@ import ( | 
			
		
	
		
		
			
				
					
					|  |  |  | ) |  |  |  | ) | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | type Policy interface { |  |  |  | type Policy interface { | 
			
		
	
		
		
			
				
					
					|  |  |  |   Type() PolicyType |  |  |  |   Serializable[PolicyType] | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |   Serialize() ([]byte, error) |  |  |  |  | 
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |   Allows(context *StateContext, principal *Node, action string, node *Node) bool |  |  |  |   Allows(context *StateContext, principal *Node, action string, node *Node) bool | 
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | const ChildOfPolicyType = PolicyType("CHILD_OF") |  |  |  | const RequirementOfPolicyType = PolicyType("REQUIREMENT_OF") | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | type ChildOfPolicy struct { |  |  |  | type RequirementOfPolicy struct { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |   NodeActions map[NodeID][]string |  |  |  |   PerNodePolicy | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | func (policy *RequirementOfPolicy) Type() PolicyType { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   return RequirementOfPolicyType | 
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | func (policy *ChildOfPolicy) Type() PolicyType { |  |  |  | func NewRequirementOfPolicy(nodes NodeActions) RequirementOfPolicy { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |   return ChildOfPolicyType |  |  |  |   return RequirementOfPolicy{ | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     PerNodePolicy: NewPerNodePolicy(nodes), | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   } | 
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | func (policy *ChildOfPolicy) Serialize() ([]byte, error) { |  |  |  | const ChildOfPolicyType = PolicyType("CHILD_OF") | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |   node_actions := map[string][]string{} |  |  |  | type ChildOfPolicy struct { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |   for id, actions := range(policy.NodeActions) { |  |  |  |   PerNodePolicy | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |     node_actions[id.String()] = actions |  |  |  |  | 
			
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } | 
			
		
	
		
		
			
				
					
					|  |  |  |   return json.MarshalIndent(&ChildOfPolicyJSON{ |  |  |  | func (policy *ChildOfPolicy) Type() PolicyType { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |     NodeActions: node_actions, |  |  |  |   return ChildOfPolicyType | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |   }, "", "  ") |  |  |  |  | 
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | func (policy *ChildOfPolicy) Allows(context *StateContext, principal *Node, action string, node *Node) bool { |  |  |  | func (policy *ChildOfPolicy) Allows(context *StateContext, principal *Node, action string, node *Node) bool { | 
			
		
	
	
		
		
			
				
					|  |  | @ -53,18 +55,17 @@ func (policy *ChildOfPolicy) Allows(context *StateContext, principal *Node, acti | 
			
		
	
		
		
			
				
					
					|  |  |  |   return false |  |  |  |   return false | 
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | type ChildOfPolicyJSON struct { |  |  |  | type NodeActions map[NodeID][]string | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |   NodeActions map[string][]string `json:"node_actions"` |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  |  | 
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | func LoadChildOfPolicy(ctx *Context, data []byte) (Policy, error) { |  |  |  | func PerNodePolicyLoad(init_fn func(NodeActions)(Policy, error)) func(*Context, []byte)(Policy, error) { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |   var j ChildOfPolicyJSON |  |  |  |   return func(ctx *Context, data []byte)(Policy, error){ | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     var j PerNodePolicyJSON | 
			
		
	
		
		
			
				
					
					|  |  |  |     err := json.Unmarshal(data, &j) |  |  |  |     err := json.Unmarshal(data, &j) | 
			
		
	
		
		
			
				
					
					|  |  |  |     if err != nil { |  |  |  |     if err != nil { | 
			
		
	
		
		
			
				
					
					|  |  |  |       return nil, err |  |  |  |       return nil, err | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |   node_actions := map[NodeID][]string{} |  |  |  |     node_actions := NodeActions{} | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |     for id_str, actions := range(j.NodeActions) { |  |  |  |     for id_str, actions := range(j.NodeActions) { | 
			
		
	
		
		
			
				
					
					|  |  |  |       id, err := ParseID(id_str) |  |  |  |       id, err := ParseID(id_str) | 
			
		
	
		
		
			
				
					
					|  |  |  |       if err != nil { |  |  |  |       if err != nil { | 
			
		
	
	
		
		
			
				
					|  |  | @ -79,38 +80,24 @@ func LoadChildOfPolicy(ctx *Context, data []byte) (Policy, error) { | 
			
		
	
		
		
			
				
					
					|  |  |  |       node_actions[id] = actions |  |  |  |       node_actions[id] = actions | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |   return NewChildOfPolicy(node_actions), nil |  |  |  |     return init_fn(node_actions) | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |   } |  |  |  |   } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | func NewChildOfPolicy(node_actions map[NodeID][]string) *ChildOfPolicy { |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |   if node_actions == nil { |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     node_actions = map[NodeID][]string{} |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |   return &ChildOfPolicy{ |  |  |  | func NewChildOfPolicy(node_actions map[NodeID][]string) ChildOfPolicy { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |     NodeActions: node_actions, |  |  |  |   return ChildOfPolicy{ | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     PerNodePolicy: NewPerNodePolicy(node_actions), | 
			
		
	
		
		
			
				
					
					|  |  |  |   } |  |  |  |   } | 
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | const ParentOfPolicyType = PolicyType("PARENT_OF") |  |  |  | const ParentOfPolicyType = PolicyType("PARENT_OF") | 
			
		
	
		
		
			
				
					
					|  |  |  | type ParentOfPolicy struct { |  |  |  | type ParentOfPolicy struct { | 
			
		
	
		
		
			
				
					
					|  |  |  |   NodeActions map[NodeID][]string |  |  |  |   PerNodePolicy | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | func (policy *ParentOfPolicy) Type() PolicyType { |  |  |  | func (policy *ParentOfPolicy) Type() PolicyType { | 
			
		
	
		
		
			
				
					
					|  |  |  |   return ParentOfPolicyType |  |  |  |   return ParentOfPolicyType | 
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | func (policy *ParentOfPolicy) Serialize() ([]byte, error) { |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |   node_actions := map[string][]string{} |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |   for id, actions := range(policy.NodeActions) { |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     node_actions[id.String()] = actions |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |   } |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |   return json.MarshalIndent(&ParentOfPolicyJSON{ |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     NodeActions: node_actions, |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |   }, "", "  ") |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | func (policy *ParentOfPolicy) Allows(context *StateContext, principal *Node, action string, node *Node) bool { |  |  |  | func (policy *ParentOfPolicy) Allows(context *StateContext, principal *Node, action string, node *Node) bool { | 
			
		
	
		
		
			
				
					
					|  |  |  |   context.Graph.Log.Logf("policy", "PARENT_OF_POLICY: %+v", policy) |  |  |  |   context.Graph.Log.Logf("policy", "PARENT_OF_POLICY: %+v", policy) | 
			
		
	
		
		
			
				
					
					|  |  |  |   for id, actions := range(policy.NodeActions) { |  |  |  |   for id, actions := range(policy.NodeActions) { | 
			
		
	
	
		
		
			
				
					|  |  | @ -134,102 +121,36 @@ func (policy *ParentOfPolicy) Allows(context *StateContext, principal *Node, act | 
			
		
	
		
		
			
				
					
					|  |  |  |   return false |  |  |  |   return false | 
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | type ParentOfPolicyJSON struct { |  |  |  | func NewParentOfPolicy(node_actions map[NodeID][]string) ParentOfPolicy { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |   NodeActions map[string][]string `json:"node_actions"` |  |  |  |   return ParentOfPolicy{ | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     PerNodePolicy: NewPerNodePolicy(node_actions), | 
			
		
	
		
		
			
				
					
					|  |  |  |   } |  |  |  |   } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | func LoadParentOfPolicy(ctx *Context, data []byte) (Policy, error) { |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |   var j ParentOfPolicyJSON |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |   err := json.Unmarshal(data, &j) |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |   if err != nil { |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     return nil, err |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |   node_actions := map[NodeID][]string{} |  |  |  | func NewPerNodePolicy(node_actions NodeActions) PerNodePolicy { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |   for id_str, actions := range(j.NodeActions) { |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     id, err := ParseID(id_str) |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     if err != nil { |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |       return nil, err |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     _, err = LoadNode(ctx, id) |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     if err != nil { |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |       return nil, err |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     node_actions[id] = actions |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |   } |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |   return NewParentOfPolicy(node_actions), nil |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | func NewParentOfPolicy(node_actions map[NodeID][]string) *ParentOfPolicy { |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |   if node_actions == nil { |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     node_actions = map[NodeID][]string{} |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |   } |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |   return &ParentOfPolicy{ |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     NodeActions: node_actions, |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |   } |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | func LoadPerNodePolicy(ctx *Context, data []byte) (Policy, error) { |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |   var j PerNodePolicyJSON |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |   err := json.Unmarshal(data, &j) |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |   if err != nil { |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     return nil, err |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |   } |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |   node_actions := map[NodeID][]string{} |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |   for id_str, actions := range(j.NodeActions) { |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     id, err := ParseID(id_str) |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     if err != nil { |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |       return nil, err |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     _, err = LoadNode(ctx, id) |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     if err != nil { |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |       return nil, err |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     node_actions[id] = actions |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |   } |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |   return NewPerNodePolicy(node_actions, j.WildcardActions), nil |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | func NewPerNodePolicy(node_actions map[NodeID][]string, wildcard_actions []string) *PerNodePolicy { |  |  |  |  | 
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |   if node_actions == nil { |  |  |  |   if node_actions == nil { | 
			
		
	
		
		
			
				
					
					|  |  |  |     node_actions = map[NodeID][]string{} |  |  |  |     node_actions = map[NodeID][]string{} | 
			
		
	
		
		
			
				
					
					|  |  |  |   } |  |  |  |   } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |   if wildcard_actions == nil { |  |  |  |   return PerNodePolicy{ | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |     wildcard_actions = []string{} |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |   } |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |   return &PerNodePolicy{ |  |  |  |  | 
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |     NodeActions: node_actions, |  |  |  |     NodeActions: node_actions, | 
			
		
	
		
		
			
				
					
					|  |  |  |     WildcardActions: wildcard_actions, |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |   } |  |  |  |   } | 
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | type PerNodePolicy struct { |  |  |  | type PerNodePolicy struct { | 
			
		
	
		
		
			
				
					
					|  |  |  |   NodeActions map[NodeID][]string |  |  |  |   NodeActions map[NodeID][]string | 
			
		
	
		
		
			
				
					
					|  |  |  |   WildcardActions []string |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | type PerNodePolicyJSON struct { |  |  |  | type PerNodePolicyJSON struct { | 
			
		
	
		
		
			
				
					
					|  |  |  |   NodeActions map[string][]string `json:"node_actions"` |  |  |  |   NodeActions map[string][]string `json:"node_actions"` | 
			
		
	
		
		
			
				
					
					|  |  |  |   WildcardActions []string `json:"wildcard_actions"` |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | const PerNodePolicyType = PolicyType("PER_NODE") |  |  |  | const PerNodePolicyType = PolicyType("PER_NODE") | 
			
		
	
		
		
			
				
					
					|  |  |  | func (policy PerNodePolicy) Type() PolicyType { |  |  |  | func (policy *PerNodePolicy) Type() PolicyType { | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |   return PerNodePolicyType |  |  |  |   return PerNodePolicyType | 
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | func (policy PerNodePolicy) Serialize() ([]byte, error) { |  |  |  | func (policy *PerNodePolicy) Serialize() ([]byte, error) { | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |   node_actions := map[string][]string{} |  |  |  |   node_actions := map[string][]string{} | 
			
		
	
		
		
			
				
					
					|  |  |  |   for id, actions := range(policy.NodeActions) { |  |  |  |   for id, actions := range(policy.NodeActions) { | 
			
		
	
		
		
			
				
					
					|  |  |  |     node_actions[id.String()] = actions |  |  |  |     node_actions[id.String()] = actions | 
			
		
	
	
		
		
			
				
					|  |  | @ -237,17 +158,10 @@ func (policy PerNodePolicy) Serialize() ([]byte, error) { | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |   return json.MarshalIndent(&PerNodePolicyJSON{ |  |  |  |   return json.MarshalIndent(&PerNodePolicyJSON{ | 
			
		
	
		
		
			
				
					
					|  |  |  |     NodeActions: node_actions, |  |  |  |     NodeActions: node_actions, | 
			
		
	
		
		
			
				
					
					|  |  |  |     WildcardActions: policy.WildcardActions, |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |   }, "", "  ") |  |  |  |   }, "", "  ") | 
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | func (policy PerNodePolicy) Allows(context *StateContext, principal *Node, action string, node *Node) bool { |  |  |  | func (policy *PerNodePolicy) Allows(context *StateContext, principal *Node, action string, node *Node) bool { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |   for _, a := range(policy.WildcardActions) { |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     if a == action { |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |       return true |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |   } |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |   for id, actions := range(policy.NodeActions) { |  |  |  |   for id, actions := range(policy.NodeActions) { | 
			
		
	
		
		
			
				
					
					|  |  |  |     if id != principal.ID { |  |  |  |     if id != principal.ID { | 
			
		
	
		
		
			
				
					
					|  |  |  |       continue |  |  |  |       continue | 
			
		
	
	
		
		
			
				
					|  |  | @ -272,7 +186,7 @@ type ACLExt struct { | 
			
		
	
		
		
			
				
					
					|  |  |  |   Delegations NodeMap |  |  |  |   Delegations NodeMap | 
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | func (ext *ACLExt) Process(context *StateContext, node *Node, signal GraphSignal) error { |  |  |  | func (ext *ACLExt) Process(context *StateContext, node *Node, signal Signal) error { | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |   return nil |  |  |  |   return nil | 
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  |  | @ -347,13 +261,28 @@ func NewACLPolicyExtContext() *ACLPolicyExtContext { | 
			
		
	
		
		
			
				
					
					|  |  |  |   return &ACLPolicyExtContext{ |  |  |  |   return &ACLPolicyExtContext{ | 
			
		
	
		
		
			
				
					
					|  |  |  |     Types: map[PolicyType]PolicyInfo{ |  |  |  |     Types: map[PolicyType]PolicyInfo{ | 
			
		
	
		
		
			
				
					
					|  |  |  |       PerNodePolicyType: PolicyInfo{ |  |  |  |       PerNodePolicyType: PolicyInfo{ | 
			
		
	
		
		
			
				
					
					|  |  |  |         Load: LoadPerNodePolicy, |  |  |  |         Load: PerNodePolicyLoad(func(nodes NodeActions)(Policy,error){ | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |           policy := NewPerNodePolicy(nodes) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |           return &policy, nil | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         }), | 
			
		
	
		
		
			
				
					
					|  |  |  |       }, |  |  |  |       }, | 
			
		
	
		
		
			
				
					
					|  |  |  |       ParentOfPolicyType: PolicyInfo{ |  |  |  |       ParentOfPolicyType: PolicyInfo{ | 
			
		
	
		
		
			
				
					
					|  |  |  |         Load: LoadParentOfPolicy, |  |  |  |         Load: PerNodePolicyLoad(func(nodes NodeActions)(Policy,error){ | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |           policy := NewParentOfPolicy(nodes) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |           return &policy, nil | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         }), | 
			
		
	
		
		
			
				
					
					|  |  |  |       }, |  |  |  |       }, | 
			
		
	
		
		
			
				
					
					|  |  |  |       ChildOfPolicyType: PolicyInfo{ |  |  |  |       ChildOfPolicyType: PolicyInfo{ | 
			
		
	
		
		
			
				
					
					|  |  |  |         Load: LoadChildOfPolicy, |  |  |  |         Load: PerNodePolicyLoad(func(nodes NodeActions)(Policy,error){ | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |           policy := NewChildOfPolicy(nodes) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |           return &policy, nil | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         }), | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |       }, | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |       RequirementOfPolicyType: PolicyInfo{ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         Load: PerNodePolicyLoad(func(nodes NodeActions)(Policy,error){ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |           policy := NewRequirementOfPolicy(nodes) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |           return &policy, nil | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         }), | 
			
		
	
		
		
			
				
					
					|  |  |  |       }, |  |  |  |       }, | 
			
		
	
		
		
			
				
					
					|  |  |  |     }, |  |  |  |     }, | 
			
		
	
		
		
			
				
					
					|  |  |  |   } |  |  |  |   } | 
			
		
	
	
		
		
			
				
					|  |  | @ -376,7 +305,7 @@ func (ext *ACLPolicyExt) Serialize() ([]byte, error) { | 
			
		
	
		
		
			
				
					
					|  |  |  |   }, "", "  ") |  |  |  |   }, "", "  ") | 
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | func (ext *ACLPolicyExt) Process(context *StateContext, node *Node, signal GraphSignal) error { |  |  |  | func (ext *ACLPolicyExt) Process(context *StateContext, node *Node, signal Signal) error { | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |   return nil |  |  |  |   return nil | 
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  |  | 
 |