From: yshah Date: Mon, 12 Aug 2024 09:13:28 +0000 (+0000) Subject: Fix encryption of VIM account credentials X-Git-Tag: release-v16.0-start~7 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=refs%2Fchanges%2F98%2F14498%2F1;p=osm%2FNBI.git Fix encryption of VIM account credentials Change-Id: I7f6e5250f29941898390a9a874a845dce5a2b37e Signed-off-by: yshah --- diff --git a/osm_nbi/admin_topics.py b/osm_nbi/admin_topics.py index 53f40e9..788ae3e 100644 --- a/osm_nbi/admin_topics.py +++ b/osm_nbi/admin_topics.py @@ -352,6 +352,24 @@ class CommonVimWimSdn(BaseTopic): schema_version=schema_version, salt=final_content["_id"], ) + if edit_content.get("config", {}).get("credentials"): + cloud_credentials = edit_content["config"]["credentials"] + if cloud_credentials.get("clientSecret"): + edit_content["config"]["credentials"][ + "clientSecret" + ] = self.db.encrypt( + edit_content["config"]["credentials"]["clientSecret"], + schema_version=schema_version, + salt=edit_content["_id"], + ) + elif cloud_credentials.get("SecretAccessKey"): + edit_content["config"]["credentials"][ + "SecretAccessKey" + ] = self.db.encrypt( + edit_content["config"]["credentials"]["SecretAccessKey"], + schema_version=schema_version, + salt=edit_content["_id"], + ) # create edit operation final_content["_admin"]["operations"].append(self._create_operation("edit")) @@ -388,6 +406,20 @@ class CommonVimWimSdn(BaseTopic): schema_version=schema_version, salt=content["_id"], ) + if content.get("config", {}).get("credentials"): + cloud_credentials = content["config"]["credentials"] + if cloud_credentials.get("clientSecret"): + content["config"]["credentials"]["clientSecret"] = self.db.encrypt( + content["config"]["credentials"]["clientSecret"], + schema_version=schema_version, + salt=content["_id"], + ) + elif cloud_credentials.get("SecretAccessKey"): + content["config"]["credentials"]["SecretAccessKey"] = self.db.encrypt( + content["config"]["credentials"]["SecretAccessKey"], + schema_version=schema_version, + salt=content["_id"], + ) content["_admin"]["operationalState"] = "PROCESSING"