X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2FNBI.git;a=blobdiff_plain;f=osm_nbi%2Fauth.py;h=bb65738cf4a3688b05540cbf246da173d44df1ad;hp=fcebad4b8cd05732f85bd4709c7e5a4b4b735ed4;hb=f269fa5cd7c46515aab49ad8af6da7e918afa592;hpb=65ca36d13f895d0a361d59a5962029d6e3ef7a99 diff --git a/osm_nbi/auth.py b/osm_nbi/auth.py index fcebad4..bb65738 100644 --- a/osm_nbi/auth.py +++ b/osm_nbi/auth.py @@ -156,7 +156,7 @@ class Authenticator: # Note: it is faster to rewrite the value than to check if it is already there or not if self.config["authentication"]["backend"] == "internal": return - + operations = [] with open(self.resources_to_operations_file, "r") as stream: resources_to_operations_yaml = yaml.load(stream) @@ -231,7 +231,12 @@ class Authenticator: if self.config["authentication"]["backend"] != "internal" and \ role_with_operations["role"] != "anonymous": - keystone_id = self.backend.create_role(role_with_operations["role"]) + keystone_id = [role for role in self.backend.get_role_list() + if role["name"] == role_with_operations["role"]] + if keystone_id: + keystone_id = keystone_id[0] + else: + keystone_id = self.backend.create_role(role_with_operations["role"]) operation_to_roles_item["_id"] = keystone_id["_id"] self.db.create("roles_operations", operation_to_roles_item)