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

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: add jsdoc 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
« no previous file with comments | « remoting/host/win/elevated_controller.cc ('k') | remoting/webapp/session_connector_impl.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/webapp/host_controller.js
diff --git a/remoting/webapp/host_controller.js b/remoting/webapp/host_controller.js
index 34278ac73b44788a03b17a99de7f3ffe3754346b..4a9d22139acb966f235442d32f674bdb1d8cc49d 100644
--- a/remoting/webapp/host_controller.js
+++ b/remoting/webapp/host_controller.js
@@ -171,10 +171,11 @@ remoting.HostController.prototype.start = function(hostPin, consent, onDone,
* @param {string} privateKey
* @param {string} xmppLogin
* @param {string} refreshToken
+ * @param {string} clientBaseJid
* @param {string} hostSecretHash
*/
- function startHostWithHash(hostName, publicKey, privateKey,
- xmppLogin, refreshToken, hostSecretHash) {
+ function startHostWithHash(hostName, publicKey, privateKey, xmppLogin,
+ refreshToken, clientBaseJid, hostSecretHash) {
var hostConfig = {
xmpp_login: xmppLogin,
oauth_refresh_token: refreshToken,
@@ -183,9 +184,13 @@ remoting.HostController.prototype.start = function(hostPin, consent, onDone,
host_secret_hash: hostSecretHash,
private_key: privateKey
};
- var hostOwner = remoting.identity.getCachedEmail();
+ var hostOwner = clientBaseJid;
+ 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),
@@ -198,13 +203,14 @@ remoting.HostController.prototype.start = function(hostPin, consent, onDone,
* @param {string} privateKey
* @param {string} email
* @param {string} refreshToken
+ * @param {string} clientBaseJid
*/
- 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 +218,21 @@ 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) {
+ that.getClientBaseJid_(
+ onClientBaseJid.bind(
+ null, hostName, publicKey, privateKey, email, refreshToken),
+ onStartError);
+ }
+
+ /**
+ * @param {string} hostName
+ * @param {string} publicKey
+ * @param {string} privateKey
* @param {XMLHttpRequest} xhr
*/
function onRegistered(
@@ -499,5 +520,56 @@ remoting.HostController.prototype.clearPairedClients = function(
this.hostDaemonFacade_.clearPairedClients(onDone, onError);
};
+/**
+ * Gets the host owner's base JID, used by the host for client authorization.
+ * In most cases this is the same as the owner's email address, but for
+ * non-Gmail accounts, it may be different.
+ *
+ * @private
+ * @param {function(string): void} onSuccess
+ * @param {function(remoting.Error): void} onError
+ */
+remoting.HostController.prototype.getClientBaseJid_ = function(
+ onSuccess, onError) {
+ var signalStrategy = null;
+
+ var onState = function(state) {
+ switch (state) {
+ case remoting.SignalStrategy.State.CONNECTED:
+ var jid = signalStrategy.getJid().split('/')[0].toLowerCase();
+ base.dispose(signalStrategy);
+ signalStrategy = null;
+ onSuccess(jid);
+ break;
+
+ case remoting.SignalStrategy.State.FAILED:
+ var error = signalStrategy.getError();
+ base.dispose(signalStrategy);
+ signalStrategy = null;
+ onError(error);
+ break;
+ }
+ };
+
+ signalStrategy = remoting.SignalStrategy.create(onState);
+
+ /** @param {string} token */
+ function connectSignalingWithToken(token) {
+ remoting.identity.getEmail(
+ connectSignalingWithTokenAndEmail.bind(null, token), onError);
+ }
+
+ /**
+ * @param {string} token
+ * @param {string} email
+ */
+ function connectSignalingWithTokenAndEmail(token, email) {
+ signalStrategy.connect(
+ remoting.settings.XMPP_SERVER_ADDRESS, email, token);
+ }
+
+ remoting.identity.callWithToken(connectSignalingWithToken, onError);
+};
+
/** @type {remoting.HostController} */
remoting.hostController = null;
« 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