OLD | NEW |
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 26 matching lines...) Expand all Loading... |
37 remoting.ThirdPartyTokenFetcher = function( | 37 remoting.ThirdPartyTokenFetcher = function( |
38 tokenUrl, hostPublicKey, scope, tokenUrlPatterns, | 38 tokenUrl, hostPublicKey, scope, tokenUrlPatterns, |
39 onThirdPartyTokenFetched) { | 39 onThirdPartyTokenFetched) { |
40 this.tokenUrl_ = tokenUrl; | 40 this.tokenUrl_ = tokenUrl; |
41 this.tokenScope_ = scope; | 41 this.tokenScope_ = scope; |
42 this.onThirdPartyTokenFetched_ = onThirdPartyTokenFetched; | 42 this.onThirdPartyTokenFetched_ = onThirdPartyTokenFetched; |
43 this.failFetchToken_ = function() { onThirdPartyTokenFetched('', ''); }; | 43 this.failFetchToken_ = function() { onThirdPartyTokenFetched('', ''); }; |
44 this.xsrfToken_ = remoting.generateXsrfToken(); | 44 this.xsrfToken_ = remoting.generateXsrfToken(); |
45 this.tokenUrlPatterns_ = tokenUrlPatterns; | 45 this.tokenUrlPatterns_ = tokenUrlPatterns; |
46 this.hostPublicKey_ = hostPublicKey; | 46 this.hostPublicKey_ = hostPublicKey; |
47 if (chrome.experimental && chrome.experimental.identity) { | 47 if (chrome.identity) { |
48 /** @type {function():void} | 48 /** @type {function():void} |
49 * @private */ | 49 * @private */ |
50 this.fetchTokenInternal_ = this.fetchTokenIdentityApi_.bind(this); | 50 this.fetchTokenInternal_ = this.fetchTokenIdentityApi_.bind(this); |
51 this.redirectUri_ = 'https://' + window.location.hostname + | 51 this.redirectUri_ = 'https://' + window.location.hostname + |
52 '.chromiumapp.org/ThirdPartyAuth'; | 52 '.chromiumapp.org/ThirdPartyAuth'; |
53 } else { | 53 } else { |
54 this.fetchTokenInternal_ = this.fetchTokenWindowOpen_.bind(this); | 54 this.fetchTokenInternal_ = this.fetchTokenWindowOpen_.bind(this); |
55 this.redirectUri_ = remoting.settings.THIRD_PARTY_AUTH_REDIRECT_URI; | 55 this.redirectUri_ = remoting.settings.THIRD_PARTY_AUTH_REDIRECT_URI; |
56 } | 56 } |
57 }; | 57 }; |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 chrome.extension.onMessage.addListener(tokenMessageListener); | 157 chrome.extension.onMessage.addListener(tokenMessageListener); |
158 window.open(fullTokenUrl, '_blank', 'location=yes,toolbar=no,menubar=no'); | 158 window.open(fullTokenUrl, '_blank', 'location=yes,toolbar=no,menubar=no'); |
159 }; | 159 }; |
160 | 160 |
161 /** | 161 /** |
162 * Fetch a token from a token server using the identity.launchWebAuthFlow API. | 162 * Fetch a token from a token server using the identity.launchWebAuthFlow API. |
163 * @private | 163 * @private |
164 */ | 164 */ |
165 remoting.ThirdPartyTokenFetcher.prototype.fetchTokenIdentityApi_ = function() { | 165 remoting.ThirdPartyTokenFetcher.prototype.fetchTokenIdentityApi_ = function() { |
166 var fullTokenUrl = this.getFullTokenUrl_(); | 166 var fullTokenUrl = this.getFullTokenUrl_(); |
167 // TODO(rmsousa): chrome.identity.launchWebAuthFlow is experimental. | 167 chrome.identity.launchWebAuthFlow( |
168 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 }; |
OLD | NEW |