From cc02e9ae712026b0c07389f66304fc9c1fde86e1 Mon Sep 17 00:00:00 2001 From: Eduardo Sousa Date: Wed, 20 Mar 2019 17:32:36 +0000 Subject: [PATCH] Fixing key error in Keystone authentication Change-Id: I107d8f67e468b80f8feec7c6f9ec7c09922467cd Signed-off-by: Eduardo Sousa --- osm_nbi/auth.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/osm_nbi/auth.py b/osm_nbi/auth.py index 44eaa94..18986a3 100644 --- a/osm_nbi/auth.py +++ b/osm_nbi/auth.py @@ -174,7 +174,7 @@ class Authenticator: .format(role_with_operations["role"])) continue - operations = {} + role_ops = {} root = None if not role_with_operations["operations"]: @@ -195,8 +195,8 @@ class Authenticator: continue operation_key = operation.replace(".", ":") - if operation_key not in operations.keys(): - operations[operation_key] = is_allowed + if operation_key not in role_ops.keys(): + role_ops[operation_key] = is_allowed else: self.logger.info("In role {0}, the operation {1} with the value {2} was discarded due to " "repetition.".format(role_with_operations["role"], operation, is_allowed)) @@ -217,7 +217,7 @@ class Authenticator: "root": root } - for operation, value in operations.items(): + for operation, value in role_ops.items(): operation_to_roles_item[operation] = value self.db.create("roles_operations", operation_to_roles_item) @@ -426,7 +426,9 @@ class Authenticator: tmp_keys = [] for tmp_key in filtered_keys: splitted = tmp_key.split()[1].split("/") - if "<" in splitted[idx] and ">" in splitted[idx]: + if idx >= len(splitted): + continue + elif "<" in splitted[idx] and ">" in splitted[idx]: if splitted[idx] == "": tmp_keys.append(tmp_key) continue -- 2.17.1