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 23 matching lines...) Expand all Loading... |
34 * domain, received from the directory server. | 34 * domain, received from the directory server. |
35 * @param {function(string, string):void} onThirdPartyTokenFetched Callback. | 35 * @param {function(string, string):void} onThirdPartyTokenFetched Callback. |
36 */ | 36 */ |
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_ = base.generateXsrfToken(); |
45 this.tokenUrlPatterns_ = tokenUrlPatterns; | 45 this.tokenUrlPatterns_ = tokenUrlPatterns; |
46 this.hostPublicKey_ = hostPublicKey; | 46 this.hostPublicKey_ = hostPublicKey; |
47 if (chrome.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); |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 /** | 165 /** |
166 * Fetch a token from a token server using the identity.launchWebAuthFlow API. | 166 * Fetch a token from a token server using the identity.launchWebAuthFlow API. |
167 * @private | 167 * @private |
168 */ | 168 */ |
169 remoting.ThirdPartyTokenFetcher.prototype.fetchTokenIdentityApi_ = function() { | 169 remoting.ThirdPartyTokenFetcher.prototype.fetchTokenIdentityApi_ = function() { |
170 var fullTokenUrl = this.getFullTokenUrl_(); | 170 var fullTokenUrl = this.getFullTokenUrl_(); |
171 chrome.identity.launchWebAuthFlow( | 171 chrome.identity.launchWebAuthFlow( |
172 {'url': fullTokenUrl, 'interactive': true}, | 172 {'url': fullTokenUrl, 'interactive': true}, |
173 this.parseRedirectUrl_.bind(this)); | 173 this.parseRedirectUrl_.bind(this)); |
174 }; | 174 }; |
OLD | NEW |