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

Unified 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: Created 6 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: remoting/webapp/host_controller.js
diff --git a/remoting/webapp/host_controller.js b/remoting/webapp/host_controller.js
index 34278ac73b44788a03b17a99de7f3ffe3754346b..fe54eb0f90a8052b59bfc8fb2159fa3d27fa28bd 100644
--- a/remoting/webapp/host_controller.js
+++ b/remoting/webapp/host_controller.js
@@ -173,8 +173,8 @@ remoting.HostController.prototype.start = function(hostPin, consent, onDone,
* @param {string} refreshToken
* @param {string} hostSecretHash
*/
- function startHostWithHash(hostName, publicKey, privateKey,
- xmppLogin, refreshToken, hostSecretHash) {
+ function startHostWithHash(hostName, publicKey, privateKey, xmppLogin,
+ refreshToken, clientJid, hostSecretHash) {
var hostConfig = {
xmpp_login: xmppLogin,
oauth_refresh_token: refreshToken,
@@ -183,9 +183,13 @@ remoting.HostController.prototype.start = function(hostPin, consent, onDone,
host_secret_hash: hostSecretHash,
private_key: privateKey
};
- var hostOwner = remoting.identity.getCachedEmail();
+ var hostOwner = clientJid;
+ var hostOwnerEmail = remoting.identity.getCachedEmail();
if (hostOwner != xmppLogin) {
hostConfig['host_owner'] = hostOwner;
+ if (hostOwnerEmail != hostOwner) {
+ hostConfig['host_owner_email'] = hostOwnerEmail;
+ }
}
that.hostDaemonFacade_.startDaemon(
hostConfig, consent, onStarted.bind(null, hostName, publicKey),
@@ -199,12 +203,12 @@ remoting.HostController.prototype.start = function(hostPin, consent, onDone,
* @param {string} email
* @param {string} refreshToken
*/
- function onServiceAccountCredentials(
- hostName, publicKey, privateKey, email, refreshToken) {
+ function onClientBaseJid(
+ hostName, publicKey, privateKey, email, refreshToken, clientBaseJid) {
that.hostDaemonFacade_.getPinHash(
newHostId, hostPin,
- startHostWithHash.bind(
- null, hostName, publicKey, privateKey, email, refreshToken),
+ startHostWithHash.bind(null, hostName, publicKey, privateKey,
+ email, refreshToken, clientBaseJid),
onError);
}
@@ -212,6 +216,58 @@ remoting.HostController.prototype.start = function(hostPin, consent, onDone,
* @param {string} hostName
* @param {string} publicKey
* @param {string} privateKey
+ * @param {string} email
+ * @param {string} refreshToken
+ */
+ function onServiceAccountCredentials(
+ hostName, publicKey, privateKey, email, refreshToken) {
+
+ // Find out the client JID that should be allowed to connect to this host.
+ var signalStrategy = null;
+
+ var onState = function(state) {
Sergey Ulanov 2014/09/25 02:28:46 HostController.start() is hard to parse already an
rmsousa 2014/09/27 01:42:17 I agree about HostController.start(), but I'm not
Sergey Ulanov 2014/09/27 01:46:02 Yes. Thank you!
+ switch (state) {
+ case remoting.SignalStrategy.State.CONNECTED:
+ var jid = signalStrategy.getJid().split('/')[0].toLowerCase();
+ base.dispose(signalStrategy);
+ signalStrategy = null;
+ onClientBaseJid(
+ hostName, publicKey, privateKey, email, refreshToken, jid);
+ break;
+
+ case remoting.SignalStrategy.State.FAILED:
+ var error = signalStrategy.getError();
+ base.dispose(signalStrategy);
+ signalStrategy = null;
+ onStartError(error);
+ break;
+ }
+ };
+
+ signalStrategy = remoting.SignalStrategy.create(onState);
+
+ /** @param {string} token */
+ function connectSignalingWithToken(token) {
+ remoting.identity.getEmail(
+ connectSignalingWithTokenAndEmail.bind(null, token), onStartError);
+ }
+
+ /**
+ * @param {string} token
+ * @param {string} email
+ */
+ function connectSignalingWithTokenAndEmail(token, email) {
+ signalStrategy.connect(
+ remoting.settings.XMPP_SERVER_ADDRESS, email, token);
+ }
+
+ remoting.identity.callWithToken(connectSignalingWithToken, onStartError);
+ }
+
+ /**
+ * @param {string} hostName
+ * @param {string} publicKey
+ * @param {string} privateKey
* @param {XMLHttpRequest} xhr
*/
function onRegistered(

Powered by Google App Engine
This is Rietveld 408576698