summaryrefslogtreecommitdiffstats
path: root/remoting/webapp
diff options
context:
space:
mode:
authorpsj@chromium.org <psj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-24 02:33:35 +0000
committerpsj@chromium.org <psj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-24 02:33:35 +0000
commitf66432db0ee32950f0dd04ce8bf3895daae7370e (patch)
tree1b269337e54deae960100fe1e5e8b5c8cb59256b /remoting/webapp
parentc091d360da97bdeb6f7d025245991b34ac28c273 (diff)
downloadchromium_src-f66432db0ee32950f0dd04ce8bf3895daae7370e.zip
chromium_src-f66432db0ee32950f0dd04ce8bf3895daae7370e.tar.gz
chromium_src-f66432db0ee32950f0dd04ce8bf3895daae7370e.tar.bz2
Do minimal processing of gnubby data. Add request timeouts and send error
responses as necessary. Requires gnubbyd 0.8.37 or later. BUG=134250 Review URL: https://codereview.chromium.org/205493005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@258844 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/webapp')
-rw-r--r--remoting/webapp/gnubby_auth_handler.js31
1 files changed, 21 insertions, 10 deletions
diff --git a/remoting/webapp/gnubby_auth_handler.js b/remoting/webapp/gnubby_auth_handler.js
index 848ab1e..52fd495 100644
--- a/remoting/webapp/gnubby_auth_handler.js
+++ b/remoting/webapp/gnubby_auth_handler.js
@@ -30,9 +30,10 @@ remoting.GnubbyAuthHandler.prototype.onMessage = function(data) {
var message = getJsonObjectFromString(data);
var messageType = getStringAttr(message, 'type');
if (messageType == 'data') {
- this.sendMessageToGnubbyd_(
- getJsonObjectFromString(getStringAttr(message, 'jsonMessage')),
- this.callback_.bind(this, getNumberAttr(message, 'connectionId')));
+ this.sendMessageToGnubbyd_({
+ 'type': 'auth-agent@openssh.com',
+ 'data': getArrayAttr(message, 'data')
+ }, this.callback_.bind(this, getNumberAttr(message, 'connectionId')));
} else {
console.error('Invalid gnubby-auth message: ' + messageType);
}
@@ -41,15 +42,25 @@ remoting.GnubbyAuthHandler.prototype.onMessage = function(data) {
/**
* Callback invoked with data to be returned to the host.
* @param {number} connectionId The connection id.
- * @param {Object} data The JSON object to send to the host.
+ * @param {Object} response The JSON response with the data to send to the host.
* @private
*/
remoting.GnubbyAuthHandler.prototype.callback_ =
- function(connectionId, data) {
- var json_data = JSON.stringify(data);
- this.clientSession_.sendGnubbyAuthMessage({'type': 'data',
- 'connectionId': connectionId,
- 'jsonMessage': json_data});
+ function(connectionId, response) {
+ try {
+ this.clientSession_.sendGnubbyAuthMessage({
+ 'type': 'data',
+ 'connectionId': connectionId,
+ 'data': getArrayAttr(response, 'data')
+ });
+ } catch (err) {
+ console.error('gnubby callback failed: ', /** @type {*} */ (err));
+ this.clientSession_.sendGnubbyAuthMessage({
+ 'type': 'error',
+ 'connectionId': connectionId
+ });
+ return;
+ }
};
/**
@@ -86,4 +97,4 @@ function onGnubbydDevReply_(jsonObject, callback, reply) {
} else {
chrome.runtime.sendMessage(kGnubbydStableExtensionId, jsonObject, callback);
}
-};
+}