From c798c0d493f29c486f53163d9cac8107042efea8 Mon Sep 17 00:00:00 2001 From: Tyler Smith Date: Thu, 7 Feb 2019 11:08:29 -0500 Subject: [PATCH] Fix horizon VM launch Moving the cookie customization to the platform horizon, and manually setting the new cookie to be used by our angularJS FM client. The change is not needed by the sysinv client since we are able to embed the csrf token in the django template, which isn't possible with the pure angular FM panels. Change-Id: Iceebf7028325256b6793deb296d32e9a9f5fba21 Signed-off-by: Tyler Smith Closes-Bug: 1813661 --- starlingx-dashboard/centos/build_srpm.data | 2 +- .../local/local_settings.d/_30_stx_local_settings.py | 8 ++++++++ .../static/app/core/fault_management/fm.service.js | 5 +---- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/starlingx-dashboard/centos/build_srpm.data b/starlingx-dashboard/centos/build_srpm.data index 546a7e79..9f297da0 100644 --- a/starlingx-dashboard/centos/build_srpm.data +++ b/starlingx-dashboard/centos/build_srpm.data @@ -1,2 +1,2 @@ SRC_DIR="starlingx-dashboard" -TIS_PATCH_VER=27 +TIS_PATCH_VER=28 diff --git a/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/local/local_settings.d/_30_stx_local_settings.py b/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/local/local_settings.d/_30_stx_local_settings.py index 0eb23693..ca4cd103 100644 --- a/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/local/local_settings.d/_30_stx_local_settings.py +++ b/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/local/local_settings.d/_30_stx_local_settings.py @@ -60,6 +60,14 @@ try: except Exception: pass +# Change session and CSRF cookie names to prevent login conflict with +# containerized horizon. +# NOTE: These settings break upstream angularJS forms such as the launch +# instance wizard. If this plugin is to be used in a standard horizon +# deployment these settings must be overwritten to their default values. +CSRF_COOKIE_NAME = 'platformcsrftoken' +SESSION_COOKIE_NAME = 'platformsessionid' + # check if it is in distributed cloud DC_MODE = False if distributed_cloud_role and distributed_cloud_role in ['systemcontroller', diff --git a/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/static/app/core/fault_management/fm.service.js b/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/static/app/core/fault_management/fm.service.js index c9fb68bc..c3eaa07e 100644 --- a/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/static/app/core/fault_management/fm.service.js +++ b/starlingx-dashboard/starlingx-dashboard/starlingx_dashboard/static/app/core/fault_management/fm.service.js @@ -30,10 +30,7 @@ updateEventSuppression: updateEventSuppression }; - var csrf_token = $('input[name=csrfmiddlewaretoken]').val(); - $http.defaults.headers.post['X-CSRFToken'] = csrf_token; - $http.defaults.headers.common['X-CSRFToken'] = csrf_token; - $http.defaults.headers.put['X-CSRFToken'] = csrf_token; + $http.defaults.xsrfCookieName = 'platformcsrftoken'; return service;