| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <include src="saml_handler.js"> | 5 <include src="saml_handler.js"> |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * @fileoverview An UI component to authenciate to Chrome. The component hosts | 8 * @fileoverview An UI component to authenciate to Chrome. The component hosts |
| 9 * IdP web pages in a webview. A client who is interested in monitoring | 9 * IdP web pages in a webview. A client who is interested in monitoring |
| 10 * authentication events should pass a listener object of type | 10 * authentication events should pass a listener object of type |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 * @param {Object} data Parameters for the authorization flow. | 168 * @param {Object} data Parameters for the authorization flow. |
| 169 */ | 169 */ |
| 170 Authenticator.prototype.load = function(authMode, data) { | 170 Authenticator.prototype.load = function(authMode, data) { |
| 171 this.clearCredentials_(); | 171 this.clearCredentials_(); |
| 172 this.idpOrigin_ = data.gaiaUrl || IDP_ORIGIN; | 172 this.idpOrigin_ = data.gaiaUrl || IDP_ORIGIN; |
| 173 this.continueUrl_ = data.continueUrl || CONTINUE_URL; | 173 this.continueUrl_ = data.continueUrl || CONTINUE_URL; |
| 174 this.continueUrlWithoutParams_ = | 174 this.continueUrlWithoutParams_ = |
| 175 this.continueUrl_.substring(0, this.continueUrl_.indexOf('?')) || | 175 this.continueUrl_.substring(0, this.continueUrl_.indexOf('?')) || |
| 176 this.continueUrl_; | 176 this.continueUrl_; |
| 177 this.isConstrainedWindow_ = data.constrained == '1'; | 177 this.isConstrainedWindow_ = data.constrained == '1'; |
| 178 this.isMinuteMaidChromeOS = data.isMinuteMaidChromeOS; | 178 this.isNewGaiaFlowChromeOS = data.isNewGaiaFlowChromeOS; |
| 179 | 179 |
| 180 this.initialFrameUrl_ = this.constructInitialFrameUrl_(data); | 180 this.initialFrameUrl_ = this.constructInitialFrameUrl_(data); |
| 181 this.reloadUrl_ = data.frameUrl || this.initialFrameUrl_; | 181 this.reloadUrl_ = data.frameUrl || this.initialFrameUrl_; |
| 182 // Don't block insecure content for desktop flow because it lands on | 182 // Don't block insecure content for desktop flow because it lands on |
| 183 // http. Otherwise, block insecure content as long as gaia is https. | 183 // http. Otherwise, block insecure content as long as gaia is https. |
| 184 this.samlHandler_.blockInsecureContent = authMode != AuthMode.DESKTOP && | 184 this.samlHandler_.blockInsecureContent = authMode != AuthMode.DESKTOP && |
| 185 this.idpOrigin_.indexOf('https://') == 0; | 185 this.idpOrigin_.indexOf('https://') == 0; |
| 186 | 186 |
| 187 this.webview_.src = this.reloadUrl_; | 187 this.webview_.src = this.reloadUrl_; |
| 188 }; | 188 }; |
| 189 | 189 |
| 190 /** | 190 /** |
| 191 * Reloads the authenticator component. | 191 * Reloads the authenticator component. |
| 192 */ | 192 */ |
| 193 Authenticator.prototype.reload = function() { | 193 Authenticator.prototype.reload = function() { |
| 194 this.clearCredentials_(); | 194 this.clearCredentials_(); |
| 195 this.webview_.src = this.reloadUrl_; | 195 this.webview_.src = this.reloadUrl_; |
| 196 }; | 196 }; |
| 197 | 197 |
| 198 Authenticator.prototype.constructInitialFrameUrl_ = function(data) { | 198 Authenticator.prototype.constructInitialFrameUrl_ = function(data) { |
| 199 var url = this.idpOrigin_ + (data.gaiaPath || IDP_PATH); | 199 var url = this.idpOrigin_ + (data.gaiaPath || IDP_PATH); |
| 200 | 200 |
| 201 if (this.isMinuteMaidChromeOS) { | 201 if (this.isNewGaiaFlowChromeOS) { |
| 202 if (data.chromeType) | 202 if (data.chromeType) |
| 203 url = appendParam(url, 'chrometype', data.chromeType); | 203 url = appendParam(url, 'chrometype', data.chromeType); |
| 204 if (data.clientId) | 204 if (data.clientId) |
| 205 url = appendParam(url, 'client_id', data.clientId); | 205 url = appendParam(url, 'client_id', data.clientId); |
| 206 if (data.enterpriseDomain) | 206 if (data.enterpriseDomain) |
| 207 url = appendParam(url, 'managedomain', data.enterpriseDomain); | 207 url = appendParam(url, 'managedomain', data.enterpriseDomain); |
| 208 } else { | 208 } else { |
| 209 url = appendParam(url, 'continue', this.continueUrl_); | 209 url = appendParam(url, 'continue', this.continueUrl_); |
| 210 url = appendParam(url, 'service', data.service || SERVICE_ID); | 210 url = appendParam(url, 'service', data.service || SERVICE_ID); |
| 211 } | 211 } |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 }); | 314 }); |
| 315 // Removes "" around. | 315 // Removes "" around. |
| 316 this.email_ = signinDetails['email'].slice(1, -1); | 316 this.email_ = signinDetails['email'].slice(1, -1); |
| 317 this.gaiaId_ = signinDetails['obfuscatedid'].slice(1, -1); | 317 this.gaiaId_ = signinDetails['obfuscatedid'].slice(1, -1); |
| 318 this.sessionIndex_ = signinDetails['sessionindex']; | 318 this.sessionIndex_ = signinDetails['sessionindex']; |
| 319 } else if (headerName == LOCATION_HEADER) { | 319 } else if (headerName == LOCATION_HEADER) { |
| 320 // If the "choose what to sync" checkbox was clicked, then the continue | 320 // If the "choose what to sync" checkbox was clicked, then the continue |
| 321 // URL will contain a source=3 field. | 321 // URL will contain a source=3 field. |
| 322 var location = decodeURIComponent(header.value); | 322 var location = decodeURIComponent(header.value); |
| 323 this.chooseWhatToSync_ = !!location.match(/(\?|&)source=3($|&)/); | 323 this.chooseWhatToSync_ = !!location.match(/(\?|&)source=3($|&)/); |
| 324 } else if (this.isMinuteMaidChromeOS && headerName == SET_COOKIE_HEADER) { | 324 } else if ( |
| 325 this.isNewGaiaFlowChromeOS && headerName == SET_COOKIE_HEADER) { |
| 325 var headerValue = header.value; | 326 var headerValue = header.value; |
| 326 if (headerValue.indexOf(OAUTH_CODE_COOKIE + '=', 0) == 0) { | 327 if (headerValue.indexOf(OAUTH_CODE_COOKIE + '=', 0) == 0) { |
| 327 this.oauth_code_ = | 328 this.oauth_code_ = |
| 328 headerValue.substring(OAUTH_CODE_COOKIE.length + 1).split(';')[0]; | 329 headerValue.substring(OAUTH_CODE_COOKIE.length + 1).split(';')[0]; |
| 329 } | 330 } |
| 330 } | 331 } |
| 331 } | 332 } |
| 332 }; | 333 }; |
| 333 | 334 |
| 334 /** | 335 /** |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 541 Authenticator.AuthFlow = AuthFlow; | 542 Authenticator.AuthFlow = AuthFlow; |
| 542 Authenticator.AuthMode = AuthMode; | 543 Authenticator.AuthMode = AuthMode; |
| 543 Authenticator.SUPPORTED_PARAMS = SUPPORTED_PARAMS; | 544 Authenticator.SUPPORTED_PARAMS = SUPPORTED_PARAMS; |
| 544 | 545 |
| 545 return { | 546 return { |
| 546 // TODO(guohui, xiyuan): Rename GaiaAuthHost to Authenticator once the old | 547 // TODO(guohui, xiyuan): Rename GaiaAuthHost to Authenticator once the old |
| 547 // iframe-based flow is deprecated. | 548 // iframe-based flow is deprecated. |
| 548 GaiaAuthHost: Authenticator | 549 GaiaAuthHost: Authenticator |
| 549 }; | 550 }; |
| 550 }); | 551 }); |
| OLD | NEW |