aboutsummaryrefslogtreecommitdiffstats
path: root/moonv4
diff options
context:
space:
mode:
Diffstat (limited to 'moonv4')
-rw-r--r--moonv4/moon_db/moon_db/backends/sql.py6
-rw-r--r--moonv4/moon_manager/moon_manager/api/policies.py16
2 files changed, 19 insertions, 3 deletions
diff --git a/moonv4/moon_db/moon_db/backends/sql.py b/moonv4/moon_db/moon_db/backends/sql.py
index 69132116..5ab653a6 100644
--- a/moonv4/moon_db/moon_db/backends/sql.py
+++ b/moonv4/moon_db/moon_db/backends/sql.py
@@ -493,7 +493,7 @@ class PolicyConnector(BaseConnector, PolicyDriver):
if "policy_list" not in _value["value"] or type(_value["value"]["policy_list"]) is not list:
_value["value"]["policy_list"] = []
if policy_id and policy_id not in _value["value"]["policy_list"]:
- _value["value"]["policy_list"] = [policy_id, ]
+ _value["value"]["policy_list"].append(policy_id)
new_subject = Subject.from_dict(_value)
# setattr(_subject, "value", _value["value"])
setattr(_subject, "value", getattr(new_subject, "value"))
@@ -560,7 +560,7 @@ class PolicyConnector(BaseConnector, PolicyDriver):
if "policy_list" not in _value["value"] or type(_value["value"]["policy_list"]) is not list:
_value["value"]["policy_list"] = []
if policy_id and policy_id not in _value["value"]["policy_list"]:
- _value["value"]["policy_list"] = [policy_id, ]
+ _value["value"]["policy_list"].append(policy_id)
new_object = Object.from_dict(_value)
# setattr(_object, "value", _value["value"])
setattr(_object, "value", getattr(new_object, "value"))
@@ -627,7 +627,7 @@ class PolicyConnector(BaseConnector, PolicyDriver):
if "policy_list" not in _value["value"] or type(_value["value"]["policy_list"]) is not list:
_value["value"]["policy_list"] = []
if policy_id and policy_id not in _value["value"]["policy_list"]:
- _value["value"]["policy_list"] = [policy_id, ]
+ _value["value"]["policy_list"].append(policy_id)
new_action = Action.from_dict(_value)
# setattr(_action, "value", _value["value"])
setattr(_action, "value", getattr(new_action, "value"))
diff --git a/moonv4/moon_manager/moon_manager/api/policies.py b/moonv4/moon_manager/moon_manager/api/policies.py
index e2f332e2..8b242478 100644
--- a/moonv4/moon_manager/moon_manager/api/policies.py
+++ b/moonv4/moon_manager/moon_manager/api/policies.py
@@ -74,6 +74,12 @@ class Perimeter(object):
def set_subject(self, ctx, args):
try:
+ if not ctx["perimeter_id"]:
+ data = self.manager.get_subjects(user_id=ctx["user_id"], policy_id=None)
+ for data_id, data_value in data.items():
+ if data_value['name'] == args['name']:
+ ctx["perimeter_id"] = data_id
+ break
data = self.manager.add_subject(user_id=ctx["user_id"], policy_id=ctx["id"],
perimeter_id=ctx["perimeter_id"], value=args)
except Exception as e:
@@ -105,6 +111,11 @@ class Perimeter(object):
def set_object(self, ctx, args):
try:
+ data = self.manager.get_objects(user_id=ctx["user_id"], policy_id=None)
+ for data_id, data_value in data.items():
+ if data_value['name'] == args['name']:
+ ctx["perimeter_id"] = data_id
+ break
data = self.manager.add_object(user_id=ctx["user_id"], policy_id=ctx["id"],
perimeter_id=ctx["perimeter_id"], value=args)
except Exception as e:
@@ -136,6 +147,11 @@ class Perimeter(object):
def set_action(self, ctx, args):
try:
+ data = self.manager.get_actions(user_id=ctx["user_id"], policy_id=None)
+ for data_id, data_value in data.items():
+ if data_value['name'] == args['name']:
+ ctx["perimeter_id"] = data_id
+ break
data = self.manager.add_action(user_id=ctx["user_id"], policy_id=ctx["id"],
perimeter_id=ctx["perimeter_id"], value=args)
except Exception as e: