Title: [163213] trunk/Tools
Revision
163213
Author
[email protected]
Date
2014-01-31 15:31:00 -0800 (Fri, 31 Jan 2014)

Log Message

WebKit Bot Watcher's Dashboard: Access restricted queue should only prompt for HTTP credentials once per page load
https://bugs.webkit.org/show_bug.cgi?id=127849

Reviewed by Alexey Proskuryakov.

Currently whenever the dashboard updates the status of a queue whose Buildbot requires authentication
it will cause a browser to prompt for credentials once per update until valid credentials are provided.
Instead we should keep track of Buildbots that respond with an HTTP 401 Unauthorized status code to avoid
subsequently querying them and hence cause a browser to prompt for credentials. Together with an optional
hint provided when instantiating a Buildbot object as to whether it requires authentication, we can make
the dashboard prompt for HTTP credentials exactly once per page load for each queue whose associated
Buildbot requires authentication.

Queues whose Buildbot wasn't authenticated will show in the dashboard as "unauthorized". Clicking on
this status message will cause the browser to prompt for credentials.

* BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/Buildbot.js:
(Buildbot): Initialize instance variable authenticationStatus to Buildbot.AuthenticationStatus.Unauthenticated.
(Buildbot.prototype.get needsAuthentication): Added.
(Buildbot.prototype.get authenticationStatus): Added.
(Buildbot.prototype.get isAuthenticated): Added.
(Buildbot.prototype.set isAuthenticated): Added.
(Buildbot.prototype.updateQueues): Added.
* BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/BuildbotBuilderQueueView.js:
(BuildbotBuilderQueueView.prototype.update.appendBuilderQueueStatus): Modified to call
BuildbotQueueView.prototype._appendUnauthorizedLineView() to update the view and show status of the queue as
"unauthorized" if the Buildbot associated with the queue is either unauthenticated or was given invalid credentials.
* BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/BuildbotQueue.js:
(BuildbotQueue.prototype.update): Return immediately if the associated Buildbot requires authentication.
Additionally, if the JSON load fails with an HTTP 401 Unauthorized access error (say, credentials were
invalidated) then update the authentication status of the Buildbot to avoid subsequently prompting a
person for credentials the next time the queue update timer fires.
* BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/BuildbotQueueView.js:
(BuildbotQueueView): Register as a listener for event BuildbotQueue.Event.UnauthorizedAccess on each queue
so that the view can be updated to show status "unauthorized".
(BuildbotQueueView.prototype._appendUnauthorizedLineView): Added.
* BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/BuildbotTesterQueueView.js:
(BuildbotTesterQueueView.prototype.update.appendBuilderQueueStatus):
* BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/StatusLineView.js: Added new status, StatusLineView.Status.Unauthorized.
* BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Styles/StatusLineView.css:
(.status-line.unauthorized .bubble): Added.
(.status-line.unauthorized .bubble.pictogram): Added.
(.status-line.unauthorized .message): Added.

Modified Paths

Diff

Modified: trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/Buildbot.js (163212 => 163213)


--- trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/Buildbot.js	2014-01-31 23:28:44 UTC (rev 163212)
+++ trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/Buildbot.js	2014-01-31 23:31:00 UTC (rev 163213)
@@ -32,14 +32,29 @@
 
     this.baseURL = baseURL;
     this.queues = {};
-    this.needsAuthentication = typeof options === "object" && options.needsAuthentication === true;
 
+    // We regard _needsAuthentication as a hint whether this Buildbot requires authentication so that we can show
+    // an appropriate initial status message (say, an "unauthorized" status if the Buildbot requires authentication)
+    // for its associated queues before we make the actual HTTP request for the status of each queue.
+    this._needsAuthentication = typeof options === "object" && options.needsAuthentication === true;
+    this._authenticationStatus = Buildbot.AuthenticationStatus.Unauthenticated;
+
     for (var id in queuesInfo)
         this.queues[id] = new BuildbotQueue(this, id, queuesInfo[id]);
 };
 
 BaseObject.addConstructorFunctions(Buildbot);
 
+Buildbot.AuthenticationStatus = {
+    Unauthenticated: "unauthenticated",
+    Authenticated: "authenticated",
+    InvalidCredentials: "invalid-credentials"
+};
+
+Buildbot.UpdateReason = {
+    Reauthenticate: "reauthenticate"
+};
+
 // Ordered importance.
 Buildbot.TestCategory = {
     WebKit2: "webkit-2",
@@ -57,6 +72,42 @@
     constructor: Buildbot,
     __proto__: BaseObject.prototype,
 
+    get needsAuthentication()
+    {
+        return this._needsAuthentication;
+    },
+
+    get authenticationStatus()
+    {
+        return this._authenticationStatus;
+    },
+
+    get isAuthenticated()
+    {
+        return this._authenticationStatus === Buildbot.AuthenticationStatus.Authenticated;
+    },
+
+    set isAuthenticated(value)
+    {
+        this._authenticationStatus = value ? Buildbot.AuthenticationStatus.Authenticated : Buildbot.AuthenticationStatus.InvalidCredentials;
+    },
+
+    updateQueues: function(updateReason)
+    {
+        var shouldReauthenticate = updateReason === Buildbot.UpdateReason.Reauthenticate;
+        if (shouldReauthenticate) {
+            var savedAuthenticationStatus = this._authenticationStatus;
+            this._authenticationStatus = Buildbot.AuthenticationStatus.Unauthenticated;
+        }
+        for (var id in this.queues)
+            this.queues[id].update();
+        if (shouldReauthenticate) {
+            // Assert status wasn't changed synchronously. Otherwise, we will override it (below).
+            console.assert(this._authenticationStatus === Buildbot.AuthenticationStatus.Unauthenticated);
+            this._authenticationStatus = savedAuthenticationStatus;
+        }
+    },
+
     buildPageURLForIteration: function(iteration)
     {
         return this.baseURL + "builders/" + encodeURIComponent(iteration.queue.id) + "/builds/" + iteration.id;

Modified: trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/BuildbotBuilderQueueView.js (163212 => 163213)


--- trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/BuildbotBuilderQueueView.js	2014-01-31 23:28:44 UTC (rev 163212)
+++ trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/BuildbotBuilderQueueView.js	2014-01-31 23:31:00 UTC (rev 163213)
@@ -60,6 +60,11 @@
 
         function appendBuilderQueueStatus(queue)
         {
+            if (queue.buildbot.needsAuthentication && !queue.buildbot.isAuthenticated) {
+                this._appendUnauthorizedLineView(queue);
+                return;
+            }
+
             this._appendPendingRevisionCount(queue);
 
             var firstRecentUnsuccessfulIteration = queue.firstRecentUnsuccessfulIteration;

Modified: trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/BuildbotQueue.js (163212 => 163213)


--- trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/BuildbotQueue.js	2014-01-31 23:28:44 UTC (rev 163212)
+++ trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/BuildbotQueue.js	2014-01-31 23:31:00 UTC (rev 163213)
@@ -52,7 +52,8 @@
 BuildbotQueue.MaximumQueuesToLoad = 10;
 
 BuildbotQueue.Event = {
-    IterationsAdded: "iterations-added"
+    IterationsAdded: "iterations-added",
+    UnauthorizedAccess: "unauthorized-access"
 };
 
 BuildbotQueue.prototype = {
@@ -119,7 +120,11 @@
 
     update: function(iterationsToLoad)
     {
+        if (this.buildbot.needsAuthentication && this.buildbot.authenticationStatus === Buildbot.AuthenticationStatus.InvalidCredentials)
+            return;
+
         JSON.load(this.baseURL, function(data) {
+            this.buildbot.isAuthenticated = true;
             if (!(data.cachedBuilds instanceof Array))
                 return;
 
@@ -154,6 +159,21 @@
             this.sortIterations();
 
             this.dispatchEventToListeners(BuildbotQueue.Event.IterationsAdded, {addedIterations: newIterations});
+        }.bind(this),
+        function(data) {
+            if (this.buildbot.isAuthenticated) {
+                // FIXME (128006): Safari/WebKit should coallesce authentication requests with the same origin and authentication realm.
+                // In absence of the fix, Safari presents additional authentication dialogs regardless of whether an earlier authentication
+                // dialog was dismissed. As a way to ameliorate the user experience where a person authenticated successfully using an
+                // earlier authentication dialog and cancelled the authentication dialog associated with the load for this queue, we call
+                // ourself so that we can schedule another load, which should complete successfully now that we have credentials.
+                this.update();
+                return;
+            }
+            if (data.errorType === JSON.LoadError && data.errorHTTPCode == 401) {
+                this.buildbot.isAuthenticated = false;
+                this.dispatchEventToListeners(BuildbotQueue.Event.UnauthorizedAccess, { });
+            }
         }.bind(this), {withCredentials: this.buildbot.needsAuthentication});
     },
 

Modified: trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/BuildbotQueueView.js (163212 => 163213)


--- trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/BuildbotQueueView.js	2014-01-31 23:28:44 UTC (rev 163212)
+++ trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/BuildbotQueueView.js	2014-01-31 23:31:00 UTC (rev 163213)
@@ -36,6 +36,7 @@
         else
             this.platform = queue.platform;
         queue.addEventListener(BuildbotQueue.Event.IterationsAdded, this._queueIterationsAdded, this);
+        queue.addEventListener(BuildbotQueue.Event.UnauthorizedAccess, this.updateSoon, this);
     }.bind(this));
 
     this.debugQueues.forEach(function(queue) {
@@ -44,6 +45,7 @@
         else
             this.platform = queue.platform;
         queue.addEventListener(BuildbotQueue.Event.IterationsAdded, this._queueIterationsAdded, this);
+        queue.addEventListener(BuildbotQueue.Event.UnauthorizedAccess, this.updateSoon, this);
     }.bind(this));
 
     webkitTrac.addEventListener(Trac.Event.NewCommitsRecorded, this._newCommitsRecorded, this);
@@ -69,6 +71,15 @@
         return queue.iterations[0].previousProductiveIteration;
     },
 
+    _appendUnauthorizedLineView: function(queue)
+    {
+        console.assert(queue.buildbot.needsAuthentication);
+        console.assert(!queue.buildbot.isAuthenticated);
+        var _javascript_URL = "_javascript_:buildbots[" + buildbots.indexOf(queue.buildbot) + "].updateQueues(Buildbot.UpdateReason.Reauthenticate)";
+        var status = new StatusLineView("unauthorized", StatusLineView.Status.Unauthorized, "", null, _javascript_URL);
+        this.element.appendChild(status.element);
+    },
+
     _appendPendingRevisionCount: function(queue)
     {
         var latestProductiveIteration = this._latestProductiveIteration(queue);

Modified: trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/BuildbotTesterQueueView.js (163212 => 163213)


--- trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/BuildbotTesterQueueView.js	2014-01-31 23:28:44 UTC (rev 163212)
+++ trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/BuildbotTesterQueueView.js	2014-01-31 23:31:00 UTC (rev 163213)
@@ -44,6 +44,11 @@
 
         function appendBuilderQueueStatus(queue)
         {
+            if (queue.buildbot.needsAuthentication && !queue.buildbot.isAuthenticated) {
+                this._appendUnauthorizedLineView(queue);
+                return;
+            }
+
             this._appendPendingRevisionCount(queue);
 
             var appendedStatus = false;

Modified: trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/StatusLineView.js (163212 => 163213)


--- trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/StatusLineView.js	2014-01-31 23:28:44 UTC (rev 163212)
+++ trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/StatusLineView.js	2014-01-31 23:31:00 UTC (rev 163213)
@@ -62,7 +62,8 @@
     Neutral: "neutral",
     Good: "good",
     Danger: "danger",
-    Bad: "bad"
+    Bad: "bad",
+    Unauthorized: "unauthorized"
 };
 
 BaseObject.addConstructorFunctions(StatusLineView);

Modified: trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Styles/StatusLineView.css (163212 => 163213)


--- trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Styles/StatusLineView.css	2014-01-31 23:28:44 UTC (rev 163212)
+++ trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Styles/StatusLineView.css	2014-01-31 23:31:00 UTC (rev 163213)
@@ -54,6 +54,10 @@
     background-color: rgb(76, 151, 61);
 }
 
+.status-line.unauthorized .bubble {
+    background-color: rgb(171, 61, 171);
+}
+
 .status-line .bubble.pictogram {
     padding: 0;
     max-width: 24px;
@@ -63,6 +67,10 @@
     background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><g transform="translate(20 30) rotate(-45 30 17)" shape-rendering="crispEdges" fill="white"><rect y="5" width="10" height="25"/><rect y="20" width="60" height="10"/></g></svg>');
 }
 
+.status-line.unauthorized .bubble.pictogram {
+    background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><clipPath id="top-semicircle"><rect x="0" y="0" width="100" height="37"/></clipPath><circle cx="50" cy="33" r="13" clip-path="url(#top-semicircle)" stroke="white" stroke-width="10" fill="none" /><rect x="24" y="38" width="52" height="39" fill="white"/></svg>');
+}
+
 .status-line.danger .bubble {
     background-color: rgb(230, 175, 44);
 }
@@ -136,6 +144,11 @@
     color: rgb(191, 67, 41);
 }
 
+.status-line.unauthorized .label,
+.status-line.unauthorized .message {
+    color: rgb(171, 61, 171);
+}
+
 .status-line .bubble.popover-tracking:hover {
     text-shadow: 0px 0px 5px rgba(255, 255, 255, 0.7)
 }

Modified: trunk/Tools/ChangeLog (163212 => 163213)


--- trunk/Tools/ChangeLog	2014-01-31 23:28:44 UTC (rev 163212)
+++ trunk/Tools/ChangeLog	2014-01-31 23:31:00 UTC (rev 163213)
@@ -1,3 +1,49 @@
+2014-01-31  Daniel Bates  <[email protected]>
+
+        WebKit Bot Watcher's Dashboard: Access restricted queue should only prompt for HTTP credentials once per page load
+        https://bugs.webkit.org/show_bug.cgi?id=127849
+
+        Reviewed by Alexey Proskuryakov.
+
+        Currently whenever the dashboard updates the status of a queue whose Buildbot requires authentication
+        it will cause a browser to prompt for credentials once per update until valid credentials are provided.
+        Instead we should keep track of Buildbots that respond with an HTTP 401 Unauthorized status code to avoid
+        subsequently querying them and hence cause a browser to prompt for credentials. Together with an optional
+        hint provided when instantiating a Buildbot object as to whether it requires authentication, we can make
+        the dashboard prompt for HTTP credentials exactly once per page load for each queue whose associated
+        Buildbot requires authentication.
+
+        Queues whose Buildbot wasn't authenticated will show in the dashboard as "unauthorized". Clicking on
+        this status message will cause the browser to prompt for credentials.
+
+        * BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/Buildbot.js:
+        (Buildbot): Initialize instance variable authenticationStatus to Buildbot.AuthenticationStatus.Unauthenticated.
+        (Buildbot.prototype.get needsAuthentication): Added.
+        (Buildbot.prototype.get authenticationStatus): Added.
+        (Buildbot.prototype.get isAuthenticated): Added.
+        (Buildbot.prototype.set isAuthenticated): Added.
+        (Buildbot.prototype.updateQueues): Added.
+        * BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/BuildbotBuilderQueueView.js:
+        (BuildbotBuilderQueueView.prototype.update.appendBuilderQueueStatus): Modified to call
+        BuildbotQueueView.prototype._appendUnauthorizedLineView() to update the view and show status of the queue as
+        "unauthorized" if the Buildbot associated with the queue is either unauthenticated or was given invalid credentials.
+        * BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/BuildbotQueue.js:
+        (BuildbotQueue.prototype.update): Return immediately if the associated Buildbot requires authentication.
+        Additionally, if the JSON load fails with an HTTP 401 Unauthorized access error (say, credentials were
+        invalidated) then update the authentication status of the Buildbot to avoid subsequently prompting a
+        person for credentials the next time the queue update timer fires.
+        * BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/BuildbotQueueView.js:
+        (BuildbotQueueView): Register as a listener for event BuildbotQueue.Event.UnauthorizedAccess on each queue
+        so that the view can be updated to show status "unauthorized".
+        (BuildbotQueueView.prototype._appendUnauthorizedLineView): Added.
+        * BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/BuildbotTesterQueueView.js:
+        (BuildbotTesterQueueView.prototype.update.appendBuilderQueueStatus):
+        * BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/StatusLineView.js: Added new status, StatusLineView.Status.Unauthorized.
+        * BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Styles/StatusLineView.css:
+        (.status-line.unauthorized .bubble): Added.
+        (.status-line.unauthorized .bubble.pictogram): Added.
+        (.status-line.unauthorized .message): Added.
+
 2014-01-31  Filip Pizlo  <[email protected]>
 
         Unreviewed, really make --copy-libraries a no-able option.
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to