Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query params are being lost after Azure AD Login #7326

Open
2 tasks
pavankarthikparuchuri opened this issue Sep 20, 2024 · 1 comment
Open
2 tasks

Query params are being lost after Azure AD Login #7326

pavankarthikparuchuri opened this issue Sep 20, 2024 · 1 comment
Labels
bug-unconfirmed A reported bug that needs to be investigated and confirmed msal-angular Related to @azure/msal-angular package msal-browser Related to msal-browser package Needs: Attention 👋 Awaiting response from the MSAL.js team public-client Issues regarding PublicClientApplications question Customer is asking for a clarification, use case or information.

Comments

@pavankarthikparuchuri
Copy link

pavankarthikparuchuri commented Sep 20, 2024

Core Library

MSAL.js (@azure/msal-browser)

Core Library Version

3.5.0

Wrapper Library

MSAL Angular (@azure/msal-angular)

Wrapper Library Version

none

Public or Confidential Client?

Public

Description

Hi Team,

We are using Azure AD Authentication to validate users after successful verification it is navigating to url with same pathname but not carrying query params

For example :

redirecturi : https://www.testurl.com/ (Configured in App registration under Auzre portal)
Here it will navigate azure ad login page after successful login it will navigate to above redirecturi.

Problem : Now If user is trying to access specific document or specific url as mentioned below (If user is not authenticated)

https://www.testurl.com/abc?id=100

User should navigate to Azure AD login page >> after successful login >> it should navigate to user requested URL for example above URL (https://www.testurl.com/abc?id=100), But it is navigating to https://www.testurl.com/abc.

How to handle this type of scenario to navigate to desired URL?

Error Message

No response

MSAL Logs

No response

Network Trace (Preferrably Fiddler)

  • Sent
  • Pending

MSAL Configuration

const msalConfig = {
  auth: {
    clientId: REACT_APP_CLIENT_ID, // This is the ONLY mandatory field that you need to supply.
    authority: REACT_APP_AUTHORITY, // Defaults to "https://login.microsoftonline.com/common"
    redirectUri: window.location.href.includes("http://localhost:3000/")
      ? "http://localhost:3000/"
      : REACT_APP_REDIRECT_URI, // You must register this URI on Azure Portal/App Registration. Defaults to window.location.origin
    // postLogoutRedirectUri: `${process.env["REACT_APP_AAD_APP_REDIRECT_URI"]}`, // Indicates the page to navigate after logout.
    navigateToLoginRequestUrl: false, // 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 between tabs.
    storeAuthStateInCookie: false, // Set this to "true" if you are having issues on IE11 or Edge
  },
  system: {
    loggerOptions: {
      loggerCallback: (level, message, containsPii) => {
        if (containsPii) {
          return;
        }
        switch (level) {
          case LogLevel.Error:
            console.error(message);
            return;
          case LogLevel.Info:
            console.info(message);
            return;
          case LogLevel.Verbose:
            console.debug(message);
            return;
          case LogLevel.Warning:
            console.warn(message);
            return;
        }
      },
    },
  },
};

Relevant Code Snippets

async function handleLogin() {
    //loginRedirect || loginPopup
    sessionStorage.setItem("authMethod", "SSO");

    // Adding Source code to prevent browser errors
    await instance.handleRedirectPromise();
    const accounts = instance.getAllAccounts();

    if (accounts.length === 0) {
      //This will be executed if there's no user authenticated
      let request = { ...loginRequest, state: window.location.href };
      await instance.loginRedirect(request).catch((error) => {
        console.error(error);
      });
    }
  } using this code in unauthenticated template

  try {
        await msalInstance.initialize();
        const response = await msalInstance.handleRedirectPromise();
        if (response) {
          const originalUrl = response.state;
          if (originalUrl) {
            window.location.href = originalUrl;
          }
        }
      } catch (error) {
        console.error(error);
      }
    } using this after redirection

Reproduction Steps

none

Expected Behavior

Redirection along with query params

Identity Provider

Entra ID (formerly Azure AD) / MSA

Browsers Affected (Select all that apply)

Chrome, Firefox, Edge, Safari, Other

Regression

@azure/msal-browser 3.5.0

Source

Internal (Microsoft)

@pavankarthikparuchuri pavankarthikparuchuri added bug-unconfirmed A reported bug that needs to be investigated and confirmed question Customer is asking for a clarification, use case or information. labels Sep 20, 2024
@github-actions github-actions bot added msal-angular Related to @azure/msal-angular package msal-browser Related to msal-browser package public-client Issues regarding PublicClientApplications labels Sep 20, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot added the Needs: Attention 👋 Awaiting response from the MSAL.js team label Sep 20, 2024
@pavankarthikparuchuri
Copy link
Author

@jo-arroyo hi could you help me out with this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug-unconfirmed A reported bug that needs to be investigated and confirmed msal-angular Related to @azure/msal-angular package msal-browser Related to msal-browser package Needs: Attention 👋 Awaiting response from the MSAL.js team public-client Issues regarding PublicClientApplications question Customer is asking for a clarification, use case or information.
Projects
None yet
Development

No branches or pull requests

1 participant