Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(201)

Side by Side Diff: remoting/webapp/host_controller.js

Issue 595063005: Save the client base JID for authentication in case it differs from the email (for accounts non-Goo… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review comments Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « remoting/host/win/elevated_controller.cc ('k') | remoting/webapp/session_connector_impl.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 'use strict'; 5 'use strict';
6 6
7 /** @suppress {duplicate} */ 7 /** @suppress {duplicate} */
8 var remoting = remoting || {}; 8 var remoting = remoting || {};
9 9
10 /** @constructor */ 10 /** @constructor */
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 } 166 }
167 167
168 /** 168 /**
169 * @param {string} hostName 169 * @param {string} hostName
170 * @param {string} publicKey 170 * @param {string} publicKey
171 * @param {string} privateKey 171 * @param {string} privateKey
172 * @param {string} xmppLogin 172 * @param {string} xmppLogin
173 * @param {string} refreshToken 173 * @param {string} refreshToken
174 * @param {string} hostSecretHash 174 * @param {string} hostSecretHash
175 */ 175 */
176 function startHostWithHash(hostName, publicKey, privateKey, 176 function startHostWithHash(hostName, publicKey, privateKey, xmppLogin,
177 xmppLogin, refreshToken, hostSecretHash) { 177 refreshToken, clientJid, hostSecretHash) {
178 var hostConfig = { 178 var hostConfig = {
179 xmpp_login: xmppLogin, 179 xmpp_login: xmppLogin,
180 oauth_refresh_token: refreshToken, 180 oauth_refresh_token: refreshToken,
181 host_id: newHostId, 181 host_id: newHostId,
182 host_name: hostName, 182 host_name: hostName,
183 host_secret_hash: hostSecretHash, 183 host_secret_hash: hostSecretHash,
184 private_key: privateKey 184 private_key: privateKey
185 }; 185 };
186 var hostOwner = remoting.identity.getCachedEmail(); 186 var hostOwner = clientJid;
187 var hostOwnerEmail = remoting.identity.getCachedEmail();
187 if (hostOwner != xmppLogin) { 188 if (hostOwner != xmppLogin) {
188 hostConfig['host_owner'] = hostOwner; 189 hostConfig['host_owner'] = hostOwner;
190 if (hostOwnerEmail != hostOwner) {
191 hostConfig['host_owner_email'] = hostOwnerEmail;
192 }
189 } 193 }
190 that.hostDaemonFacade_.startDaemon( 194 that.hostDaemonFacade_.startDaemon(
191 hostConfig, consent, onStarted.bind(null, hostName, publicKey), 195 hostConfig, consent, onStarted.bind(null, hostName, publicKey),
192 onStartError); 196 onStartError);
193 } 197 }
194 198
195 /** 199 /**
196 * @param {string} hostName 200 * @param {string} hostName
197 * @param {string} publicKey 201 * @param {string} publicKey
198 * @param {string} privateKey 202 * @param {string} privateKey
199 * @param {string} email 203 * @param {string} email
200 * @param {string} refreshToken 204 * @param {string} refreshToken
201 */ 205 */
202 function onServiceAccountCredentials( 206 function onClientBaseJid(
203 hostName, publicKey, privateKey, email, refreshToken) { 207 hostName, publicKey, privateKey, email, refreshToken, clientBaseJid) {
204 that.hostDaemonFacade_.getPinHash( 208 that.hostDaemonFacade_.getPinHash(
205 newHostId, hostPin, 209 newHostId, hostPin,
206 startHostWithHash.bind( 210 startHostWithHash.bind(null, hostName, publicKey, privateKey,
207 null, hostName, publicKey, privateKey, email, refreshToken), 211 email, refreshToken, clientBaseJid),
208 onError); 212 onError);
209 } 213 }
210 214
211 /** 215 /**
212 * @param {string} hostName 216 * @param {string} hostName
213 * @param {string} publicKey 217 * @param {string} publicKey
214 * @param {string} privateKey 218 * @param {string} privateKey
219 * @param {string} email
220 * @param {string} refreshToken
221 */
222 function onServiceAccountCredentials(
223 hostName, publicKey, privateKey, email, refreshToken) {
224 that.getClientBaseJid_(
225 onClientBaseJid.bind(
226 null, hostName, publicKey, privateKey, email, refreshToken),
227 onStartError);
228 }
229
230 /**
231 * @param {string} hostName
232 * @param {string} publicKey
233 * @param {string} privateKey
215 * @param {XMLHttpRequest} xhr 234 * @param {XMLHttpRequest} xhr
216 */ 235 */
217 function onRegistered( 236 function onRegistered(
218 hostName, publicKey, privateKey, xhr) { 237 hostName, publicKey, privateKey, xhr) {
219 var success = (xhr.status == 200); 238 var success = (xhr.status == 200);
220 239
221 if (success) { 240 if (success) {
222 var result = jsonParseSafe(xhr.responseText); 241 var result = jsonParseSafe(xhr.responseText);
223 if ('data' in result && 'authorizationCode' in result['data']) { 242 if ('data' in result && 'authorizationCode' in result['data']) {
224 that.hostDaemonFacade_.getCredentialsFromAuthCode( 243 that.hostDaemonFacade_.getCredentialsFromAuthCode(
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 * 511 *
493 * @param {function():void} onDone Completion callback. 512 * @param {function():void} onDone Completion callback.
494 * @param {function(remoting.Error):void} onError Error callback. 513 * @param {function(remoting.Error):void} onError Error callback.
495 * @return {void} 514 * @return {void}
496 */ 515 */
497 remoting.HostController.prototype.clearPairedClients = function( 516 remoting.HostController.prototype.clearPairedClients = function(
498 onDone, onError) { 517 onDone, onError) {
499 this.hostDaemonFacade_.clearPairedClients(onDone, onError); 518 this.hostDaemonFacade_.clearPairedClients(onDone, onError);
500 }; 519 };
501 520
521 /**
522 * @private
Sergey Ulanov 2014/09/27 01:46:02 add comment here to explain what it is used for.
523 * @param {function(string): void} onSuccess
524 * @param {function(remoting.Error): void} onError
525 */
526 remoting.HostController.prototype.getClientBaseJid_ = function(
527 onSuccess, onError) {
528 // Find out the client JID that should be allowed to connect to this host.
529 var signalStrategy = null;
530
531 var onState = function(state) {
532 switch (state) {
533 case remoting.SignalStrategy.State.CONNECTED:
534 var jid = signalStrategy.getJid().split('/')[0].toLowerCase();
535 base.dispose(signalStrategy);
536 signalStrategy = null;
537 onSuccess(jid);
538 break;
539
540 case remoting.SignalStrategy.State.FAILED:
541 var error = signalStrategy.getError();
542 base.dispose(signalStrategy);
543 signalStrategy = null;
544 onError(error);
545 break;
546 }
547 };
548
549 signalStrategy = remoting.SignalStrategy.create(onState);
550
551 /** @param {string} token */
552 function connectSignalingWithToken(token) {
553 remoting.identity.getEmail(
554 connectSignalingWithTokenAndEmail.bind(null, token), onError);
555 }
556
557 /**
558 * @param {string} token
559 * @param {string} email
560 */
561 function connectSignalingWithTokenAndEmail(token, email) {
562 signalStrategy.connect(
563 remoting.settings.XMPP_SERVER_ADDRESS, email, token);
564 }
565
566 remoting.identity.callWithToken(connectSignalingWithToken, onError);
567 }
568
502 /** @type {remoting.HostController} */ 569 /** @type {remoting.HostController} */
503 remoting.hostController = null; 570 remoting.hostController = null;
OLDNEW
« no previous file with comments | « remoting/host/win/elevated_controller.cc ('k') | remoting/webapp/session_connector_impl.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698