2

Am just doing msal.logout() and it redirects to logout screen and then ask for login and then after login it navigates to www.office.com , How can I just stop all redirections after logout.

Here is the config

export const msalConfig: Configuration = {
 
  auth: {
    clientId: "xxxxxx",
    authority: "https://login.microsoftonline.com/xxx",
    redirectUri: `http://localhost:3000`,
    postLogoutRedirectUri: `https://localhost:3000/logout`
  }
};

import { IMsalContext, useMsal } from "@azure/msal-react";
   const { instance } = useMsal();

    export function handleLogout(instance: any) {   
        instance.logout(endSessionRequest); //This logouts and then ask for login and then go to www.office.com  which is not configured anywhere in msalConfig    
    }

    export const endSessionRequest: EndSessionRequest = {
      postLogoutRedirectUri: `https://localhost:3000/logout`
    };

Note : This is the redirecturl after login click which contains www.office.com

https://login.microsoftonline.com/common/oauth2/v2.0/authorize?client_id=xxxxxx&redirect_uri=https%3A%2F%2Fwww.office.com%2Flandingv2&response_type=code%20id_token&scope=openid%20profile%20https%3A%2F%2Fwww.office.com%2Fv2%2FOfficeHome.All&response_mode=form_post&nonce=637691229835396604.NDZlZjRkMTMtYWZlYy00Mzg1LTk3YmItODc4ZDFlNzhlMTRjMDhmN2Q4MjEtNTRiYi00NGQxLTgzNTItYTI4MGVkYjYzN2Ni&ui_locales=en-US&mkt=en-US&client-request-id=0eb6f9a0-525d-4939-8541-893d9a960497&state=Iw9_CAMwjrzffsm_V8laWMVsfcREPJmGdcsvXd9G0jVaYt7fRttltWjZz1Gkfi2caIY40VJ6aaSbNQMdjFUcadHS6walpe5THq2cszy_bisx4ygWv8Pe6HothKP8QHYzbuWo0PjTj2h9O1xUv-F2CC2vUBcAyTARXjOsr6uxxp4-aENCwsRO76rRqGRMPDq4C7-VdTaFmQoyRR1OHGfV6WJ7Ep5KNIR1j65NMPlYW-rZ2dAPMoFFeyPcSCsX5H1O0FTOPSGDAJdXf215L50Ybg&x-client-SKU=ID_NETSTANDARD2_0&x-client-ver=6.11.0.0#

Deepak Kothari
  • 1,601
  • 24
  • 31

1 Answers1

1

Login has two functions, loginPopup() and loginRedirect(). Logout only has one function: logout(). Read more here.

When you logout you need to clear the cookies both for application and also for the https://msft.sts.microsoft.com/.

Clearing the cookies for https://msft.sts.microsoft.com can only be done by the STS itself (security isolation), and therefore it needs to redirect to the postlogoutRedirectUrl afterward.

Rutha
  • 751
  • 3
  • 7