diff --git a/1-Authentication/1-sign-in/App/authConfig.js b/1-Authentication/1-sign-in/App/authConfig.js index 59b8d54..7b37a44 100644 --- a/1-Authentication/1-sign-in/App/authConfig.js +++ b/1-Authentication/1-sign-in/App/authConfig.js @@ -5,40 +5,39 @@ */ const msalConfig = { - auth: { - clientId: "Enter_the_Application_Id_Here", // This is the ONLY mandatory field that you need to supply. - authority: "https://login.microsoftonline.com/Enter_the_Tenant_Info_Here", // Defaults to "https://login.microsoftonline.com/common" - redirectUri: "Enter_the_Redirect_Uri_Here", // You must register this URI on Azure Portal/App Registration. Defaults to window.location.href - postLogoutRedirectUri: "Enter_the_Redirect_Uri_Here/signout", // Simply remove this line if you would like navigate to index page after logout. - navigateToLoginRequestUrl: false, // If "true", will navigate back to the original request location before processing the auth code response. - }, - cache: { - cacheLocation: "localStorage", // Configures cache location. "sessionStorage" is more secure, but "localStorage" gives you SSO. - storeAuthStateInCookie: false, // If you wish to store cache items in cookies as well as browser cache, set this to "true". - }, - system: { - loggerOptions: { - loggerCallback: (level, message, containsPii) => { - if (containsPii) { - return; - } - switch (level) { - case msal.LogLevel.Error: - console.error(message); - return; - case msal.LogLevel.Info: - console.info(message); - return; - case msal.LogLevel.Verbose: - console.debug(message); - return; - case msal.LogLevel.Warning: - console.warn(message); - return; - } - } - } - } + auth: { + clientId: 'Enter_the_Application_Id_Here', // This is the ONLY mandatory field that you need to supply. + authority: 'https://login.microsoftonline.com/Enter_the_Tenant_Info_Here', // Defaults to "https://login.microsoftonline.com/common" + redirectUri: '/', // You must register this URI on Azure Portal/App Registration. Defaults to window.location.href e.g. http://localhost:3000/ + navigateToLoginRequestUrl: true, // If "true", will navigate back to the original request location before processing the auth code response. + }, + cache: { + cacheLocation: 'sessionStorage', // Configures cache location. "sessionStorage" is more secure, but "localStorage" gives you SSO. + storeAuthStateInCookie: false, // set this to true if you have to support IE + }, + system: { + loggerOptions: { + loggerCallback: (level, message, containsPii) => { + if (containsPii) { + return; + } + switch (level) { + case msal.LogLevel.Error: + console.error(message); + return; + case msal.LogLevel.Info: + console.info(message); + return; + case msal.LogLevel.Verbose: + console.debug(message); + return; + case msal.LogLevel.Warning: + console.warn(message); + return; + } + }, + }, + }, }; /** @@ -64,6 +63,7 @@ const loginRequest = { // exporting config object for jest if (typeof exports !== 'undefined') { module.exports = { - msalConfig: msalConfig, + msalConfig: msalConfig, + loginRequest: loginRequest, }; } \ No newline at end of file diff --git a/1-Authentication/1-sign-in/App/authPopup.js b/1-Authentication/1-sign-in/App/authPopup.js index cf9f970..0e1c242 100644 --- a/1-Authentication/1-sign-in/App/authPopup.js +++ b/1-Authentication/1-sign-in/App/authPopup.js @@ -84,10 +84,12 @@ function signOut() { // Choose which account to logout from by passing a username. const logoutRequest = { - account: myMSALObj.getAccountByUsername(username) + account: myMSALObj.getAccountByUsername(username), + mainWindowRedirectUri: 'http://localhost:3000/signout', + redirectUri: 'http://localhost:3000/redirect.html', }; - myMSALObj.logout(logoutRequest); + myMSALObj.logoutPopup(logoutRequest); } selectAccount(); diff --git a/1-Authentication/1-sign-in/App/authRedirect.js b/1-Authentication/1-sign-in/App/authRedirect.js index 7ac7b4d..e1ec389 100644 --- a/1-Authentication/1-sign-in/App/authRedirect.js +++ b/1-Authentication/1-sign-in/App/authRedirect.js @@ -91,8 +91,10 @@ function signOut() { // Choose which account to logout from by passing a username. const logoutRequest = { - account: myMSALObj.getAccountByUsername(username) + account: myMSALObj.getAccountByUsername(username), + postLogoutRedirectUri: 'http://localhost:3000/signout', // Simply remove this line if you would like navigate to index page after logout. + }; - myMSALObj.logout(logoutRequest); + myMSALObj.logoutRedirect(logoutRequest); } diff --git a/1-Authentication/1-sign-in/App/index.html b/1-Authentication/1-sign-in/App/index.html index 638b7b4..c8ceb23 100644 --- a/1-Authentication/1-sign-in/App/index.html +++ b/1-Authentication/1-sign-in/App/index.html @@ -6,26 +6,22 @@ Microsoft identity platform + + - - - - - - + + -