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

Side by Side Diff: chrome/browser/resources/chromeos/login/screen_gaia_signin.js

Issue 2519823006: Chromad: Add authentication flow (Closed)
Patch Set: Created 4 years 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 Oobe signin screen implementation. 6 * @fileoverview Oobe signin screen implementation.
7 */ 7 */
8 8
9 login.createScreen('GaiaSigninScreen', 'gaia-signin', function() { 9 login.createScreen('GaiaSigninScreen', 'gaia-signin', function() {
10 // GAIA animation guard timer. Started when GAIA page is loaded 10 // GAIA animation guard timer. Started when GAIA page is loaded
(...skipping 21 matching lines...) Expand all
32 // it will not be extended by user activity. 32 // it will not be extended by user activity.
33 /** @const */ var VIDEO_LOGIN_TIMEOUT = 90 * 1000; 33 /** @const */ var VIDEO_LOGIN_TIMEOUT = 90 * 1000;
34 34
35 /** 35 /**
36 * The modes this screen can be in. 36 * The modes this screen can be in.
37 * @enum {integer} 37 * @enum {integer}
38 */ 38 */
39 var ScreenMode = { 39 var ScreenMode = {
40 DEFAULT: 0, // Default GAIA login flow. 40 DEFAULT: 0, // Default GAIA login flow.
41 OFFLINE: 1, // GAIA offline login. 41 OFFLINE: 1, // GAIA offline login.
42 SAML_INTERSTITIAL: 2 // Interstitial page before SAML redirection. 42 SAML_INTERSTITIAL: 2, // Interstitial page before SAML redirection.
43 AD_AUTH: 3 // Offline Active Directory login flow.
43 }; 44 };
44 45
45 return { 46 return {
46 EXTERNAL_API: [ 47 EXTERNAL_API: [
47 'loadAuthExtension', 48 'loadAuthExtension',
48 'doReload', 49 'doReload',
49 'monitorOfflineIdle', 50 'monitorOfflineIdle',
50 'updateControlsState', 51 'updateControlsState',
51 'showWhitelistCheckFailedError', 52 'showWhitelistCheckFailedError',
52 ], 53 ],
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 187
187 /** @override */ 188 /** @override */
188 decorate: function() { 189 decorate: function() {
189 this.navigation_ = $('gaia-navigation'); 190 this.navigation_ = $('gaia-navigation');
190 191
191 this.gaiaAuthHost_ = new cr.login.GaiaAuthHost($('signin-frame')); 192 this.gaiaAuthHost_ = new cr.login.GaiaAuthHost($('signin-frame'));
192 this.gaiaAuthHost_.addEventListener( 193 this.gaiaAuthHost_.addEventListener(
193 'ready', this.onAuthReady_.bind(this)); 194 'ready', this.onAuthReady_.bind(this));
194 195
195 var that = this; 196 var that = this;
196 [this.gaiaAuthHost_, $('offline-gaia')].forEach(function(frame) { 197 [this.gaiaAuthHost_, $('offline-gaia'), $('offline-ad-auth')].
198 forEach(function(frame) {
197 // Ignore events from currently inactive frame. 199 // Ignore events from currently inactive frame.
198 var frameFilter = function(callback) { 200 var frameFilter = function(callback) {
199 return function(e) { 201 return function(e) {
200 var isEventOffline = frame === $('offline-gaia'); 202 if (frame === that.getSigninFrame_())
201 if (isEventOffline === that.isOffline())
202 callback.call(that, e); 203 callback.call(that, e);
203 }; 204 };
204 }; 205 };
205 206
206 frame.addEventListener('authCompleted', 207 frame.addEventListener('authCompleted',
207 frameFilter(that.onAuthCompletedMessage_)); 208 frameFilter(that.onAuthCompletedMessage_));
208 frame.addEventListener('backButton', frameFilter(that.onBackButton_)); 209 frame.addEventListener('backButton', frameFilter(that.onBackButton_));
209 frame.addEventListener('dialogShown', frameFilter(that.onDialogShown_)); 210 frame.addEventListener('dialogShown', frameFilter(that.onDialogShown_));
210 frame.addEventListener('dialogHidden', 211 frame.addEventListener('dialogHidden',
211 frameFilter(that.onDialogHidden_)); 212 frameFilter(that.onDialogHidden_));
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 * accordingly. 308 * accordingly.
308 * @param {integer} value The screen mode. 309 * @param {integer} value The screen mode.
309 */ 310 */
310 set screenMode(value) { 311 set screenMode(value) {
311 this.screenMode_ = value; 312 this.screenMode_ = value;
312 switch (this.screenMode_) { 313 switch (this.screenMode_) {
313 case ScreenMode.DEFAULT: 314 case ScreenMode.DEFAULT:
314 $('signin-frame').hidden = false; 315 $('signin-frame').hidden = false;
315 $('offline-gaia').hidden = true; 316 $('offline-gaia').hidden = true;
316 $('saml-interstitial').hidden = true; 317 $('saml-interstitial').hidden = true;
318 $('offline-ad-auth').hidden = true;
317 break; 319 break;
318 case ScreenMode.OFFLINE: 320 case ScreenMode.OFFLINE:
319 $('signin-frame').hidden = true; 321 $('signin-frame').hidden = true;
320 $('offline-gaia').hidden = false; 322 $('offline-gaia').hidden = false;
321 $('saml-interstitial').hidden = true; 323 $('saml-interstitial').hidden = true;
324 $('offline-ad-auth').hidden = true;
325 break;
326 case ScreenMode.AD_AUTH:
327 $('signin-frame').hidden = true;
328 $('offline-gaia').hidden = true;
329 $('saml-interstitial').hidden = true;
330 $('offline-ad-auth').hidden = false;
322 break; 331 break;
323 case ScreenMode.SAML_INTERSTITIAL: 332 case ScreenMode.SAML_INTERSTITIAL:
324 $('signin-frame').hidden = true; 333 $('signin-frame').hidden = true;
325 $('offline-gaia').hidden = true; 334 $('offline-gaia').hidden = true;
326 $('saml-interstitial').hidden = false; 335 $('saml-interstitial').hidden = false;
336 $('offline-ad-auth').hidden = true;
327 break; 337 break;
328 } 338 }
329 339
330 chrome.send('updateOfflineLogin', [this.isOffline()]); 340 chrome.send('updateOfflineLogin', [this.isOffline()]);
331 this.updateControlsState(); 341 this.updateControlsState();
332 }, 342 },
333 343
334 /** 344 /**
335 * This enables or disables trying to go back to the online login page 345 * This enables or disables trying to go back to the online login page
336 * after the user is idle for a few minutes, assuming that we're currently 346 * after the user is idle for a few minutes, assuming that we're currently
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
524 this.lastBackMessageValue_ = false; 534 this.lastBackMessageValue_ = false;
525 this.updateControlsState(); 535 this.updateControlsState();
526 }, 536 },
527 537
528 getSigninFrame_: function() { 538 getSigninFrame_: function() {
529 switch (this.screenMode_) { 539 switch (this.screenMode_) {
530 case ScreenMode.DEFAULT: 540 case ScreenMode.DEFAULT:
531 return $('signin-frame'); 541 return $('signin-frame');
532 case ScreenMode.OFFLINE: 542 case ScreenMode.OFFLINE:
533 return $('offline-gaia'); 543 return $('offline-gaia');
544 case ScreenMode.AD_AUTH:
545 return $('offline-ad-auth');
534 case ScreenMode.SAML_INTERSTITIAL: 546 case ScreenMode.SAML_INTERSTITIAL:
535 return $('saml-interstitial'); 547 return $('saml-interstitial');
536 } 548 }
537 }, 549 },
538 550
539 focusSigninFrame: function() { 551 focusSigninFrame: function() {
540 this.getSigninFrame_().focus(); 552 this.getSigninFrame_().focus();
541 }, 553 },
542 554
543 onAfterShow: function() { 555 onAfterShow: function() {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 this.gaiaAuthParams_ = params; 611 this.gaiaAuthParams_ = params;
600 switch (this.screenMode_) { 612 switch (this.screenMode_) {
601 case ScreenMode.DEFAULT: 613 case ScreenMode.DEFAULT:
602 this.loadGaiaAuthHost_(false /* doSamlRedirect */); 614 this.loadGaiaAuthHost_(false /* doSamlRedirect */);
603 break; 615 break;
604 616
605 case ScreenMode.OFFLINE: 617 case ScreenMode.OFFLINE:
606 this.loadOffline(params); 618 this.loadOffline(params);
607 break; 619 break;
608 620
621 case ScreenMode.AD_AUTH:
622 this.loadAdAuth(params);
623 break;
624
609 case ScreenMode.SAML_INTERSTITIAL: 625 case ScreenMode.SAML_INTERSTITIAL:
610 $('saml-interstitial').domain = data.enterpriseDomain; 626 $('saml-interstitial').domain = data.enterpriseDomain;
611 if (this.loading) 627 if (this.loading)
612 this.loading = false; 628 this.loading = false;
613 // This event is for the browser tests. 629 // This event is for the browser tests.
614 $('saml-interstitial').fire('samlInterstitialPageReady'); 630 $('saml-interstitial').fire('samlInterstitialPageReady');
615 break; 631 break;
616 } 632 }
617 this.updateControlsState(); 633 this.updateControlsState();
618 chrome.send('authExtensionLoaded'); 634 chrome.send('authExtensionLoaded');
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
865 samlApiUsed_: function() { 881 samlApiUsed_: function() {
866 chrome.send('usingSAMLAPI'); 882 chrome.send('usingSAMLAPI');
867 }, 883 },
868 884
869 /** 885 /**
870 * Invoked when auth is completed successfully. 886 * Invoked when auth is completed successfully.
871 * @param {!Object} credentials Credentials of the completed authentication. 887 * @param {!Object} credentials Credentials of the completed authentication.
872 * @private 888 * @private
873 */ 889 */
874 onAuthCompleted_: function(credentials) { 890 onAuthCompleted_: function(credentials) {
875 if (credentials.useOffline) { 891 if (this.screenMode_ == ScreenMode.AD_AUTH) {
892 this.email = credentials.username;
893 chrome.send('completeAdAuthentication',
894 [credentials.username,
895 credentials.password]);
896 } else if (credentials.useOffline) {
876 this.email = credentials.email; 897 this.email = credentials.email;
877 chrome.send('authenticateUser', 898 chrome.send('authenticateUser',
878 [credentials.email, 899 [credentials.email,
879 credentials.password, 900 credentials.password,
880 false]); 901 false]);
881 } else if (credentials.authCode) { 902 } else if (credentials.authCode) {
882 if (credentials.hasOwnProperty('authCodeOnly') && 903 if (credentials.hasOwnProperty('authCodeOnly') &&
883 credentials.authCodeOnly) { 904 credentials.authCodeOnly) {
884 chrome.send('completeAuthenticationAuthCodeOnly', 905 chrome.send('completeAuthenticationAuthCodeOnly',
885 [credentials.authCode]); 906 [credentials.authCode]);
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
1041 this.startLoadingTimer_(); 1062 this.startLoadingTimer_();
1042 var offlineLogin = $('offline-gaia'); 1063 var offlineLogin = $('offline-gaia');
1043 if ('enterpriseDomain' in params) 1064 if ('enterpriseDomain' in params)
1044 offlineLogin.domain = params['enterpriseDomain']; 1065 offlineLogin.domain = params['enterpriseDomain'];
1045 if ('emailDomain' in params) 1066 if ('emailDomain' in params)
1046 offlineLogin.emailDomain = '@' + params['emailDomain']; 1067 offlineLogin.emailDomain = '@' + params['emailDomain'];
1047 offlineLogin.setEmail(params.email); 1068 offlineLogin.setEmail(params.email);
1048 this.onAuthReady_(); 1069 this.onAuthReady_();
1049 }, 1070 },
1050 1071
1072 loadAdAuth: function(params) {
1073 this.loading = true;
1074 this.startLoadingTimer_();
1075 var ADAuthUI = this.getSigninFrame_();
1076 if ('realm' in params) {
1077 ADAuthUI.realm = params['realm'];
1078 ADAuthUI.userRealm = '@' + params['realm'];
1079 }
1080 this.onAuthReady_();
1081 },
1082
1051 /** 1083 /**
1052 * Show/Hide error when user is not in whitelist. When UI is hidden 1084 * Show/Hide error when user is not in whitelist. When UI is hidden
1053 * GAIA is reloaded. 1085 * GAIA is reloaded.
1054 * @param {boolean} show Show/hide error UI. 1086 * @param {boolean} show Show/hide error UI.
1055 * @param {!Object} opt_data Optional additional information. 1087 * @param {!Object} opt_data Optional additional information.
1056 */ 1088 */
1057 showWhitelistCheckFailedError: function(show, opt_data) { 1089 showWhitelistCheckFailedError: function(show, opt_data) {
1058 if (show) { 1090 if (show) {
1059 var isManaged = opt_data && opt_data.enterpriseManaged; 1091 var isManaged = opt_data && opt_data.enterpriseManaged;
1060 $('gaia-whitelist-error').textContent = 1092 $('gaia-whitelist-error').textContent =
1061 loadTimeData.getValue(isManaged ? 'whitelistErrorEnterprise' : 1093 loadTimeData.getValue(isManaged ? 'whitelistErrorEnterprise' :
1062 'whitelistErrorConsumer'); 1094 'whitelistErrorConsumer');
1063 } 1095 }
1064 1096
1065 this.classList.toggle('whitelist-error', show); 1097 this.classList.toggle('whitelist-error', show);
1066 this.loading = !show; 1098 this.loading = !show;
1067 1099
1068 if (show) 1100 if (show)
1069 $('gaia-whitelist-error').submitButton.focus(); 1101 $('gaia-whitelist-error').submitButton.focus();
1070 else 1102 else
1071 Oobe.showSigninUI(); 1103 Oobe.showSigninUI();
1072 1104
1073 this.updateControlsState(); 1105 this.updateControlsState();
1074 } 1106 }
1075 }; 1107 };
1076 }); 1108 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698