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

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

Issue 2519823006: Chromad: Add authentication flow (Closed)
Patch Set: Rename HandleAdAuth. Use system_api enums Created 3 years, 12 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
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 var currentFrame = null;
201 if (isEventOffline === that.isOffline()) 203 switch (that.screenMode_) {
204 case ScreenMode.DEFAULT:
205 case ScreenMode.SAML_INTERSTITIAL:
206 currentFrame = that.gaiaAuthHost_;
207 break;
208 case ScreenMode.OFFLINE:
209 currentFrame = $('offline-gaia');
210 break;
211 case ScreenMode.AD_AUTH:
212 currentFrame = $('offline-ad-auth');
213 break;
214 }
215 if (frame === currentFrame)
202 callback.call(that, e); 216 callback.call(that, e);
203 }; 217 };
204 }; 218 };
205 219
206 frame.addEventListener('authCompleted', 220 frame.addEventListener('authCompleted',
207 frameFilter(that.onAuthCompletedMessage_)); 221 frameFilter(that.onAuthCompletedMessage_));
208 frame.addEventListener('backButton', frameFilter(that.onBackButton_)); 222 frame.addEventListener('backButton', frameFilter(that.onBackButton_));
209 frame.addEventListener('dialogShown', frameFilter(that.onDialogShown_)); 223 frame.addEventListener('dialogShown', frameFilter(that.onDialogShown_));
210 frame.addEventListener('dialogHidden', 224 frame.addEventListener('dialogHidden',
211 frameFilter(that.onDialogHidden_)); 225 frameFilter(that.onDialogHidden_));
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 * accordingly. 321 * accordingly.
308 * @param {integer} value The screen mode. 322 * @param {integer} value The screen mode.
309 */ 323 */
310 set screenMode(value) { 324 set screenMode(value) {
311 this.screenMode_ = value; 325 this.screenMode_ = value;
312 switch (this.screenMode_) { 326 switch (this.screenMode_) {
313 case ScreenMode.DEFAULT: 327 case ScreenMode.DEFAULT:
314 $('signin-frame').hidden = false; 328 $('signin-frame').hidden = false;
315 $('offline-gaia').hidden = true; 329 $('offline-gaia').hidden = true;
316 $('saml-interstitial').hidden = true; 330 $('saml-interstitial').hidden = true;
331 $('offline-ad-auth').hidden = true;
317 break; 332 break;
318 case ScreenMode.OFFLINE: 333 case ScreenMode.OFFLINE:
319 $('signin-frame').hidden = true; 334 $('signin-frame').hidden = true;
320 $('offline-gaia').hidden = false; 335 $('offline-gaia').hidden = false;
321 $('saml-interstitial').hidden = true; 336 $('saml-interstitial').hidden = true;
337 $('offline-ad-auth').hidden = true;
338 break;
339 case ScreenMode.AD_AUTH:
340 $('signin-frame').hidden = true;
341 $('offline-gaia').hidden = true;
342 $('saml-interstitial').hidden = true;
343 $('offline-ad-auth').hidden = false;
322 break; 344 break;
323 case ScreenMode.SAML_INTERSTITIAL: 345 case ScreenMode.SAML_INTERSTITIAL:
324 $('signin-frame').hidden = true; 346 $('signin-frame').hidden = true;
325 $('offline-gaia').hidden = true; 347 $('offline-gaia').hidden = true;
326 $('saml-interstitial').hidden = false; 348 $('saml-interstitial').hidden = false;
349 $('offline-ad-auth').hidden = true;
327 break; 350 break;
328 } 351 }
329 352
330 chrome.send('updateOfflineLogin', [this.isOffline()]); 353 chrome.send('updateOfflineLogin', [this.isOffline()]);
331 this.updateControlsState(); 354 this.updateControlsState();
332 }, 355 },
333 356
334 /** 357 /**
335 * This enables or disables trying to go back to the online login page 358 * 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 359 * 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; 547 this.lastBackMessageValue_ = false;
525 this.updateControlsState(); 548 this.updateControlsState();
526 }, 549 },
527 550
528 getSigninFrame_: function() { 551 getSigninFrame_: function() {
529 switch (this.screenMode_) { 552 switch (this.screenMode_) {
530 case ScreenMode.DEFAULT: 553 case ScreenMode.DEFAULT:
531 return $('signin-frame'); 554 return $('signin-frame');
532 case ScreenMode.OFFLINE: 555 case ScreenMode.OFFLINE:
533 return $('offline-gaia'); 556 return $('offline-gaia');
557 case ScreenMode.AD_AUTH:
558 return $('offline-ad-auth');
534 case ScreenMode.SAML_INTERSTITIAL: 559 case ScreenMode.SAML_INTERSTITIAL:
535 return $('saml-interstitial'); 560 return $('saml-interstitial');
536 } 561 }
537 }, 562 },
538 563
539 focusSigninFrame: function() { 564 focusSigninFrame: function() {
540 this.getSigninFrame_().focus(); 565 this.getSigninFrame_().focus();
541 }, 566 },
542 567
543 onAfterShow: function() { 568 onAfterShow: function() {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 this.gaiaAuthParams_ = params; 624 this.gaiaAuthParams_ = params;
600 switch (this.screenMode_) { 625 switch (this.screenMode_) {
601 case ScreenMode.DEFAULT: 626 case ScreenMode.DEFAULT:
602 this.loadGaiaAuthHost_(false /* doSamlRedirect */); 627 this.loadGaiaAuthHost_(false /* doSamlRedirect */);
603 break; 628 break;
604 629
605 case ScreenMode.OFFLINE: 630 case ScreenMode.OFFLINE:
606 this.loadOffline(params); 631 this.loadOffline(params);
607 break; 632 break;
608 633
634 case ScreenMode.AD_AUTH:
635 this.loadAdAuth(params);
636 break;
637
609 case ScreenMode.SAML_INTERSTITIAL: 638 case ScreenMode.SAML_INTERSTITIAL:
610 $('saml-interstitial').domain = data.enterpriseDomain; 639 $('saml-interstitial').domain = data.enterpriseDomain;
611 if (this.loading) 640 if (this.loading)
612 this.loading = false; 641 this.loading = false;
613 // This event is for the browser tests. 642 // This event is for the browser tests.
614 $('saml-interstitial').fire('samlInterstitialPageReady'); 643 $('saml-interstitial').fire('samlInterstitialPageReady');
615 break; 644 break;
616 } 645 }
617 this.updateControlsState(); 646 this.updateControlsState();
618 chrome.send('authExtensionLoaded'); 647 chrome.send('authExtensionLoaded');
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
865 samlApiUsed_: function() { 894 samlApiUsed_: function() {
866 chrome.send('usingSAMLAPI'); 895 chrome.send('usingSAMLAPI');
867 }, 896 },
868 897
869 /** 898 /**
870 * Invoked when auth is completed successfully. 899 * Invoked when auth is completed successfully.
871 * @param {!Object} credentials Credentials of the completed authentication. 900 * @param {!Object} credentials Credentials of the completed authentication.
872 * @private 901 * @private
873 */ 902 */
874 onAuthCompleted_: function(credentials) { 903 onAuthCompleted_: function(credentials) {
875 if (credentials.useOffline) { 904 if (this.screenMode_ == ScreenMode.AD_AUTH) {
905 this.email = credentials.username;
906 chrome.send('completeAdAuthentication',
907 [credentials.username,
908 credentials.password]);
909 } else if (credentials.useOffline) {
876 this.email = credentials.email; 910 this.email = credentials.email;
877 chrome.send('authenticateUser', 911 chrome.send('authenticateUser',
878 [credentials.email, 912 [credentials.email,
879 credentials.password, 913 credentials.password,
880 false]); 914 false]);
881 } else if (credentials.authCode) { 915 } else if (credentials.authCode) {
882 if (credentials.hasOwnProperty('authCodeOnly') && 916 if (credentials.hasOwnProperty('authCodeOnly') &&
883 credentials.authCodeOnly) { 917 credentials.authCodeOnly) {
884 chrome.send('completeAuthenticationAuthCodeOnly', 918 chrome.send('completeAuthenticationAuthCodeOnly',
885 [credentials.authCode]); 919 [credentials.authCode]);
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
1041 this.startLoadingTimer_(); 1075 this.startLoadingTimer_();
1042 var offlineLogin = $('offline-gaia'); 1076 var offlineLogin = $('offline-gaia');
1043 if ('enterpriseDomain' in params) 1077 if ('enterpriseDomain' in params)
1044 offlineLogin.domain = params['enterpriseDomain']; 1078 offlineLogin.domain = params['enterpriseDomain'];
1045 if ('emailDomain' in params) 1079 if ('emailDomain' in params)
1046 offlineLogin.emailDomain = '@' + params['emailDomain']; 1080 offlineLogin.emailDomain = '@' + params['emailDomain'];
1047 offlineLogin.setEmail(params.email); 1081 offlineLogin.setEmail(params.email);
1048 this.onAuthReady_(); 1082 this.onAuthReady_();
1049 }, 1083 },
1050 1084
1085 loadAdAuth: function(params) {
1086 this.loading = true;
1087 this.startLoadingTimer_();
1088 var ADAuthUI = this.getSigninFrame_();
1089 if ('realm' in params) {
1090 ADAuthUI.realm = params['realm'];
1091 ADAuthUI.userRealm = '@' + params['realm'];
1092 }
1093 this.onAuthReady_();
1094 },
1095
1051 /** 1096 /**
1052 * Show/Hide error when user is not in whitelist. When UI is hidden 1097 * Show/Hide error when user is not in whitelist. When UI is hidden
1053 * GAIA is reloaded. 1098 * GAIA is reloaded.
1054 * @param {boolean} show Show/hide error UI. 1099 * @param {boolean} show Show/hide error UI.
1055 * @param {!Object} opt_data Optional additional information. 1100 * @param {!Object} opt_data Optional additional information.
1056 */ 1101 */
1057 showWhitelistCheckFailedError: function(show, opt_data) { 1102 showWhitelistCheckFailedError: function(show, opt_data) {
1058 if (show) { 1103 if (show) {
1059 var isManaged = opt_data && opt_data.enterpriseManaged; 1104 var isManaged = opt_data && opt_data.enterpriseManaged;
1060 $('gaia-whitelist-error').textContent = 1105 $('gaia-whitelist-error').textContent =
1061 loadTimeData.getValue(isManaged ? 'whitelistErrorEnterprise' : 1106 loadTimeData.getValue(isManaged ? 'whitelistErrorEnterprise' :
1062 'whitelistErrorConsumer'); 1107 'whitelistErrorConsumer');
1063 } 1108 }
1064 1109
1065 this.classList.toggle('whitelist-error', show); 1110 this.classList.toggle('whitelist-error', show);
1066 this.loading = !show; 1111 this.loading = !show;
1067 1112
1068 if (show) 1113 if (show)
1069 $('gaia-whitelist-error').submitButton.focus(); 1114 $('gaia-whitelist-error').submitButton.focus();
1070 else 1115 else
1071 Oobe.showSigninUI(); 1116 Oobe.showSigninUI();
1072 1117
1073 this.updateControlsState(); 1118 this.updateControlsState();
1074 } 1119 }
1075 }; 1120 };
1076 }); 1121 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698