|
|
@ -69,7 +69,7 @@ type Node interface {
|
|
|
|
ID() NodeID
|
|
|
|
ID() NodeID
|
|
|
|
Type() NodeType
|
|
|
|
Type() NodeType
|
|
|
|
|
|
|
|
|
|
|
|
Allowed(action string, resource string, principal NodeID) error
|
|
|
|
Allowed(action string, resource string, principal Node) error
|
|
|
|
AddPolicy(Policy) error
|
|
|
|
AddPolicy(Policy) error
|
|
|
|
RemovePolicy(Policy) error
|
|
|
|
RemovePolicy(Policy) error
|
|
|
|
|
|
|
|
|
|
|
@ -100,13 +100,13 @@ func (node * GraphNode) Serialize() ([]byte, error) {
|
|
|
|
return json.MarshalIndent(&node_json, "", " ")
|
|
|
|
return json.MarshalIndent(&node_json, "", " ")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (node *GraphNode) Allowed(action string, resource string, principal NodeID) error {
|
|
|
|
func (node *GraphNode) Allowed(action string, resource string, principal Node) error {
|
|
|
|
for _, policy := range(node.policies) {
|
|
|
|
for _, policy := range(node.policies) {
|
|
|
|
if policy.Allows(action, resource, principal) == true {
|
|
|
|
if policy.Allows(action, resource, principal) == true {
|
|
|
|
return nil
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return fmt.Errorf("%s is not allowed to perform %s.%s on %s", principal.String(), resource, action, node.ID().String())
|
|
|
|
return fmt.Errorf("%s is not allowed to perform %s.%s on %s", principal.ID().String(), resource, action, node.ID().String())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (node *GraphNode) AddPolicy(policy Policy) error {
|
|
|
|
func (node *GraphNode) AddPolicy(policy Policy) error {
|
|
|
|