From 03d21e342c9581a7216c950c0f79760101a4f37f Mon Sep 17 00:00:00 2001 From: Rahul Date: Tue, 5 Dec 2023 11:54:38 +0000 Subject: [PATCH] Fix 2299 - Unable to logout from GUI when NBI uses keystone as backend Change-Id: I4e8a3592e7ea66645b9a8f19de576b7ba29e9d9c Signed-off-by: Rahul --- osm_nbi/nbi.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/osm_nbi/nbi.py b/osm_nbi/nbi.py index 46fd8cc..07219bc 100644 --- a/osm_nbi/nbi.py +++ b/osm_nbi/nbi.py @@ -1091,9 +1091,13 @@ class Server(object): # for logging self._format_login(token_info) token_id = token_info["_id"] - token_details = self.engine.db.get_one("tokens", {"_id": token_id}) - current_user = token_details.get("username") - current_project = token_details.get("project_name") + if current_backend != "keystone": + token_details = self.engine.db.get_one("tokens", {"_id": token_id}) + current_user = token_details.get("username") + current_project = token_details.get("project_name") + else: + current_user = "keystone backend" + current_project = "keystone backend" outdata = self.authenticator.del_token(token_id) token_info = None cherrypy.session["Authorization"] = "logout" # pylint: disable=E1101 @@ -1928,6 +1932,7 @@ def _start_service(): global nbi_server global subscription_thread global cef_logger + global current_backend cherrypy.log.error("Starting osm_nbi") # update general cherrypy configuration update_dict = {} @@ -2042,6 +2047,7 @@ def _start_service(): # Do not capture except SubscriptionException backend = engine_config["authentication"]["backend"] + current_backend = backend cherrypy.log.error( "Starting OSM NBI Version '{} {}' with '{}' authentication backend".format( nbi_version, nbi_version_date, backend -- 2.25.1