X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2FNBI.git;a=blobdiff_plain;f=osm_nbi%2Fauth.py;h=18986a3ab4d7e64a00280519a495fb37d510ea40;hp=7d586ad13ad2460e0abb50814c5a9705b462218d;hb=cc02e9ae712026b0c07389f66304fc9c1fde86e1;hpb=29933fc257389f16f9c798f52a43e43800475a4a diff --git a/osm_nbi/auth.py b/osm_nbi/auth.py index 7d586ad..18986a3 100644 --- a/osm_nbi/auth.py +++ b/osm_nbi/auth.py @@ -1,17 +1,23 @@ # -*- coding: utf-8 -*- -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Copyright 2018 Whitestack, LLC +# Copyright 2018 Telefonica S.A. # -# http://www.apache.org/licenses/LICENSE-2.0 +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or -# implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +# For those usages not covered by the Apache License, Version 2.0 please +# contact: esousa@whitestack.com or alfonso.tiernosepulveda@telefonica.com +## """ @@ -168,7 +174,7 @@ class Authenticator: .format(role_with_operations["role"])) continue - operations = {} + role_ops = {} root = None if not role_with_operations["operations"]: @@ -189,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)) @@ -211,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) @@ -420,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