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

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

Issue 22611008: Remove third party auth redirect URI domain check. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Deal better with malformed urls Created 7 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 /** 5 /**
6 * @fileoverview 6 * @fileoverview
7 * Third party authentication support for the remoting web-app. 7 * Third party authentication support for the remoting web-app.
8 * 8 *
9 * When third party authentication is being used, the client must request both a 9 * When third party authentication is being used, the client must request both a
10 * token and a shared secret from a third-party server. The server can then 10 * token and a shared secret from a third-party server. The server can then
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 /** 81 /**
82 * Parse the access token from the URL to which we were redirected. 82 * Parse the access token from the URL to which we were redirected.
83 * 83 *
84 * @param {string} responseUrl The URL to which we were redirected. 84 * @param {string} responseUrl The URL to which we were redirected.
85 * @private 85 * @private
86 */ 86 */
87 remoting.ThirdPartyTokenFetcher.prototype.parseRedirectUrl_ = 87 remoting.ThirdPartyTokenFetcher.prototype.parseRedirectUrl_ =
88 function(responseUrl) { 88 function(responseUrl) {
89 var token = ''; 89 var token = '';
90 var sharedSecret = ''; 90 var sharedSecret = '';
91 if (responseUrl && 91
92 responseUrl.search(this.redirectUri_ + '#') == 0) { 92 if (responseUrl && responseUrl.search('#') >= 0) {
93 var query = responseUrl.substring(this.redirectUri_.length + 1); 93 var query = responseUrl.substring(responseUrl.search('#') + 1);
94 var parts = query.split('&'); 94 var parts = query.split('&');
95 /** @type {Object.<string>} */ 95 /** @type {Object.<string>} */
96 var queryArgs = {}; 96 var queryArgs = {};
97 for (var i = 0; i < parts.length; i++) { 97 for (var i = 0; i < parts.length; i++) {
98 var pair = parts[i].split('='); 98 var pair = parts[i].split('=');
99 queryArgs[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]); 99 queryArgs[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]);
100 } 100 }
101 101
102 // Check that 'state' contains the same XSRF token we sent in the request. 102 // Check that 'state' contains the same XSRF token we sent in the request.
103 var xsrfToken = queryArgs['state']; 103 if ('state' in queryArgs && queryArgs['state'] == this.xsrfToken_ &&
104 if (xsrfToken == this.xsrfToken_ &&
105 'code' in queryArgs && 'access_token' in queryArgs) { 104 'code' in queryArgs && 'access_token' in queryArgs) {
106 // Terminology note: 105 // Terminology note:
107 // In the OAuth code/token exchange semantics, 'code' refers to the value 106 // In the OAuth code/token exchange semantics, 'code' refers to the value
108 // obtained when the *user* authenticates itself, while 'access_token' is 107 // obtained when the *user* authenticates itself, while 'access_token' is
109 // the value obtained when the *application* authenticates itself to the 108 // the value obtained when the *application* authenticates itself to the
110 // server ("implicitly", by receiving it directly in the URL fragment, or 109 // server ("implicitly", by receiving it directly in the URL fragment, or
111 // explicitly, by sending the 'code' and a 'client_secret' to the server). 110 // explicitly, by sending the 'code' and a 'client_secret' to the server).
112 // Internally, the piece of data obtained when the user authenticates 111 // Internally, the piece of data obtained when the user authenticates
113 // itself is called the 'token', and the one obtained when the host 112 // itself is called the 'token', and the one obtained when the host
114 // authenticates itself (using the 'token' received from the client and 113 // authenticates itself (using the 'token' received from the client and
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 * Fetch a token from a token server using the identity.launchWebAuthFlow API. 161 * Fetch a token from a token server using the identity.launchWebAuthFlow API.
163 * @private 162 * @private
164 */ 163 */
165 remoting.ThirdPartyTokenFetcher.prototype.fetchTokenIdentityApi_ = function() { 164 remoting.ThirdPartyTokenFetcher.prototype.fetchTokenIdentityApi_ = function() {
166 var fullTokenUrl = this.getFullTokenUrl_(); 165 var fullTokenUrl = this.getFullTokenUrl_();
167 // TODO(rmsousa): chrome.identity.launchWebAuthFlow is experimental. 166 // TODO(rmsousa): chrome.identity.launchWebAuthFlow is experimental.
168 chrome.experimental.identity.launchWebAuthFlow( 167 chrome.experimental.identity.launchWebAuthFlow(
169 {'url': fullTokenUrl, 'interactive': true}, 168 {'url': fullTokenUrl, 'interactive': true},
170 this.parseRedirectUrl_.bind(this)); 169 this.parseRedirectUrl_.bind(this));
171 }; 170 };
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698