areguera / rpms / cockpit

Forked from rpms/cockpit 5 years ago
Clone
Blob Blame History Raw
From 96d64114ecedbb1203199339d443aba8f79f2417 Mon Sep 17 00:00:00 2001
From: petervo <petervo@redhat.com>
Date: Thu, 10 Nov 2016 12:21:28 -0800
Subject: [5/7] Fix registry console Windows IE and Edge login

https://bugzilla.redhat.com/show_bug.cgi?id=1378810
https://bugzilla.redhat.com/show_bug.cgi?id=1393740

Upstream commits:
b403d66ff9b2a74c58dc296236491af2aae33601
    ws: Explictly set no-cache on all login responses
80a239cf53d0eb44fef5da3e3b31d67bb065e336
    ws: Extract baseURI from tag for some IEs

Closes #5363
Signed-off-by: Stef Walter <stefw@redhat.com>
 * Signing off inclusion in the rhel-7.3.1 branch
---
 src/ws/cockpithandlers.c |  2 ++
 src/ws/login.html        | 13 ++++++++++++-
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/src/ws/cockpithandlers.c b/src/ws/cockpithandlers.c
index f96354e..1611fdd 100644
--- a/src/ws/cockpithandlers.c
+++ b/src/ws/cockpithandlers.c
@@ -408,6 +408,8 @@ on_login_complete (GObject *object,
   headers = cockpit_web_server_new_table ();
   response_data = cockpit_auth_login_finish (COCKPIT_AUTH (object), result, flags, headers, &error);
 
+  /* Never cache a login response */
+  cockpit_web_response_set_cache_type (response, COCKPIT_WEB_RESPONSE_NO_CACHE);
   if (error)
     {
       if (response_data)
diff --git a/src/ws/login.html b/src/ws/login.html
index 3eb30f5..d114cc0 100644
--- a/src/ws/login.html
+++ b/src/ws/login.html
@@ -133,8 +133,19 @@
             /* Sets values for application, url_root and login_path */
             function setup_path_globals (path) {
                 var parser = document.createElement('a');
+                var base = document.baseURI;
+                var base_tags;
+                /* Some IEs don't support baseURI */
+                if (!base) {
+                    base_tags = document.getElementsByTagName ("base");
+                    if (base_tags.length > 0)
+                        base = base_tags[0].href;
+                    else
+                        base = "/";
+                }
+
                 path = path || "/";
-                parser.href = document.baseURI;
+                parser.href = base;
                 if (parser.pathname != "/") {
                     url_root = parser.pathname.replace(/^\/+|\/+$/g, '');
                     window.localStorage.setItem('url-root', url_root);
-- 
2.5.5