From: delacruzramo Date: Thu, 26 Dec 2019 10:09:04 +0000 (+0000) Subject: Fix Bug 870: Getting unauthorized when using keystone as back-end for NBI X-Git-Tag: v7.0.1rc2~3 X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2FNBI.git;a=commitdiff_plain;h=15ec70643bdaa3ba84eccefbed73ab525bfd31fc Fix Bug 870: Getting unauthorized when using keystone as back-end for NBI Change-Id: I085be0f780388aed0d269c298c17ceb960fa14cc Signed-off-by: delacruzramo --- diff --git a/osm_nbi/auth.py b/osm_nbi/auth.py index dc3d386..023d286 100644 --- a/osm_nbi/auth.py +++ b/osm_nbi/auth.py @@ -282,8 +282,8 @@ class Authenticator: self.backend.update_user({"_id": user_admin_id, "add_project_role_mappings": [{"project": pid, "role": role_id}]}) self.logger.info("Added role system admin to user='{}' project=admin".format(user_admin_id)) - except Exception: - pass + except Exception as e: + self.logger.error("Error in Authorization DataBase initialization: {}: {}".format(type(e).__name__, e)) self.load_operation_to_allowed_roles() diff --git a/osm_nbi/authconn_keystone.py b/osm_nbi/authconn_keystone.py index f32cfe9..ebd7654 100644 --- a/osm_nbi/authconn_keystone.py +++ b/osm_nbi/authconn_keystone.py @@ -251,8 +251,9 @@ class AuthconnKeystone(Authconn): user_id = user_obj.id if user_info.get("password") or user_info.get("username") \ or user_info.get("add_project_role_mappings") or user_info.get("remove_project_role_mappings"): + ctime = user_obj._admin.get("created", 0) if hasattr(user_obj, "_admin") else 0 self.keystone.users.update(user_id, password=user_info.get("password"), name=user_info.get("username"), - _admin={"created": user_obj._admin["created"], "modified": time.time()}) + _admin={"created": ctime, "modified": time.time()}) for mapping in user_info.get("remove_project_role_mappings", []): self.remove_role_from_user(user_id, mapping["project"], mapping["role"]) for mapping in user_info.get("add_project_role_mappings", []):