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

MSAL Doesn't Redirect on Safari #5696

Closed
hansakaRightS opened this issue Feb 17, 2023 · 17 comments
Closed

MSAL Doesn't Redirect on Safari #5696

hansakaRightS opened this issue Feb 17, 2023 · 17 comments
Assignees
Labels
answered Question has received "first qualified response" 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 public-client Issues regarding PublicClientApplications question Customer is asking for a clarification, use case or information.

Comments

@hansakaRightS
Copy link

hansakaRightS commented Feb 17, 2023

Core Library

MSAL.js v2 (@azure/msal-browser)

Core Library Version

2.32.1

Wrapper Library

MSAL Angular (@azure/msal-angular)

Wrapper Library Version

2.1.2

Public or Confidential Client?

Public

Description

User tying to redirect to the login page from the application on safari mobile and the msal does not respond to the request. works with Chrome IOS and Android.

We only see this issue sometimes but we have users complaining they are not able to log into the application.

We were not able to see any errors in our logs to detect anything related to this issue. We would like to get more information about the situation and monitoring to tackle this issue. any help would be appreciated.

Error Message

No response

Msal Logs

No response

MSAL Configuration

auth: {
        clientId: clientId,
        authority: "B2C_1A_SIGNUP_SIGNIN",
        redirectUri: '/',
        navigateToLoginRequestUrl: false
    },
    cache: {
        cacheLocation: "LocalStoarage",
        storeAuthStateInCookie: false
    }

Relevant Code Snippets

extraParameters = {
        ...extraParameters
        device_id: deviceId
      };

      // set the redirection flag
      this.storage.setDeviceHasRedirectedToLogin(deviceId);
        
      const redirect = this.msalService.loginRedirect({
        scopes:[`https://${environment.activeDirectory.domain}/${environment.activeDirectory.tenantId}/access_as_user`],
        extraQueryParameters: extraParameters
      });

      return redirect;

Reproduction Steps

  1. Access the Application
  2. Press the login button
  3. Nothing happens

Expected Behavior

Needs to redirect to the login page.

Identity Provider

Azure AD / MSA

Browsers Affected (Select all that apply)

Safari

Regression

No response

Source

External (Customer)

@hansakaRightS hansakaRightS 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 Feb 17, 2023
@ghost ghost added the Needs: Attention 👋 Awaiting response from the MSAL.js team label Feb 17, 2023
@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 Feb 17, 2023
@ghost ghost assigned hectormmg Feb 17, 2023
@hectormmg
Copy link
Member

@HansakaSS could you please elaborate on the issue? It's hard to determine what's going on without logs or a reproducible scenario. Is the failure happening after the user logs in and the login page redirects back to the application? Or is the issue happening when MSAL first redirects to the login page?

My initial assumption if the problem is happening on the redirect back from the login screen is that there could be a race condition where the hash is being cleared by the apps routing logic before MSAL has a chance to parse the auth code.

@ghost ghost added answered Question has received "first qualified response" Needs: Author Feedback Awaiting response from issue author and removed Needs: Attention 👋 Awaiting response from the MSAL.js team labels Feb 17, 2023
@hansakaRightS
Copy link
Author

@hectormmg we were able to see following error on audits for users when they having the issue.

The provided grant has expired. Please re-authenticate and try again. Current time: 1676633207, Grant issued time: 1676514293, Grant expiration time: 1676575579

users were not able to redirect to the login page.

@ghost ghost added Needs: Attention 👋 Awaiting response from the MSAL.js team and removed Needs: Author Feedback Awaiting response from issue author labels Feb 18, 2023
@mlhamatms
Copy link

mlhamatms commented Feb 20, 2023

@HansakaSS , it looks like, from your posted, the request is taking 118 seconds from the time you got the grant time to the time you used it in the above log, your 57 seconds over the allowed exp of the token.

It looks like your grants are only valid for 60 seconds.

@hansakaRightS
Copy link
Author

@mlhamatms thanks for the response.
I understand the token expiration issue.
I would like to know how to increase this expiration time.

Some users seems to have this problem continuously on the same device, even after clearing cache. but they were able to login on other devices without a problem. Some users were able log in on chrome but not in Safari.

Also in case of this problem is there a way to let know the users know something went wrong or redirect to a another page to let user know more information about the problem ?

@hectormmg
Copy link
Member

@HansakaSS that error should cause MSAL to return an InteractionRequired error. The correct usage pattern is to call acquireTokenRedirect or acquireTokenPopup for the user to reauthenticate. As far as changing the access token lifetime, that is not something you can do from MSAL, I would suggest looking at the AAD docs and your portal configuration.

@ghost ghost added Needs: Author Feedback Awaiting response from issue author and removed Needs: Attention 👋 Awaiting response from the MSAL.js team labels Feb 21, 2023
@hectormmg hectormmg assigned jo-arroyo and unassigned hectormmg Feb 21, 2023
@ghost
Copy link

ghost commented Feb 27, 2023

@HansakaSS This issue has been automatically marked as stale because it is marked as requiring author feedback but has not had any activity for 5 days. If your issue has been resolved please let us know by closing the issue. If your issue has not been resolved please leave a comment to keep this open. It will be closed automatically in 7 days if it remains stale.

@ghost ghost added the no-issue-activity Issue author has not responded in 5 days label Feb 27, 2023
@jo-arroyo jo-arroyo assigned tnorling and unassigned jo-arroyo Feb 27, 2023
@hansakaRightS
Copy link
Author

hansakaRightS commented Mar 6, 2023

we have applied the acquireTokenRedirect solution to out application but we still see some users still having the login problems. user was able to see the login page and after redirect to the application user is not authenticated. and alos user cannot access the redirect again with the login button

we were able to see the Acquire Token Error. Unexpected Error. Error message: BrowserAuthError: no_account_error: No account object provided to acquireTokenSilent and no active account has been set. Please call setActiveAccount or provide an account on the request in our logs

@hansakaRightS hansakaRightS reopened this Mar 6, 2023
@ghost ghost added Needs: Attention 👋 Awaiting response from the MSAL.js team and removed no-issue-activity Issue author has not responded in 5 days labels Mar 6, 2023
@tnorling
Copy link
Collaborator

tnorling commented Mar 6, 2023

@HansakaSS The error message tells you exactly what is wrong and how to fix it. Did you have specific questions about this?

@ghost ghost added Needs: Author Feedback Awaiting response from issue author and removed Needs: Attention 👋 Awaiting response from the MSAL.js team labels Mar 6, 2023
@hansakaRightS
Copy link
Author

@tnorling i understand that. but this is happening right after user login to the system. i wanted to prevent this from happening, is there a reason for this kind of behaviour ?

@ghost ghost added Needs: Attention 👋 Awaiting response from the MSAL.js team and removed Needs: Author Feedback Awaiting response from issue author labels Mar 8, 2023
@tnorling
Copy link
Collaborator

tnorling commented Mar 8, 2023

You either didn't pass an account to acquireTokenSilent or you didn't set the active account after login. You need to do one of those things to resolve this error.

@ghost ghost added Needs: Author Feedback Awaiting response from issue author and removed Needs: Attention 👋 Awaiting response from the MSAL.js team labels Mar 8, 2023
@JohnButare
Copy link

@HansakaSS i think we are seeing similar issues in Safari using MSAL, it may be related to Safari's lack of look regex lookbehind, ours is erroring out in the MSAL function CredentialEntity.getCredentialType calling 'f (key.toLowerCase().search("(?<=" + separator + domainRe + ")" + separator + credVal + separator) !== -1) {' can you confirm if yours is failing there? If so I believe MSFT will need to change the search function to support Safari's lack of regex look behind

@hansakaRightS
Copy link
Author

hansakaRightS commented Mar 9, 2023

@tnorling thanks, i have updated the code with the setActivateAccount. i will keep you posted.

@JohnButare Yes we had the same issue, i believe it has been fixed now. you can find the discussion here. #5548

@ghost ghost added Needs: Attention 👋 Awaiting response from the MSAL.js team and removed Needs: Author Feedback Awaiting response from issue author labels Mar 9, 2023
@lalimasharda lalimasharda added Needs: Author Feedback Awaiting response from issue author and removed Needs: Attention 👋 Awaiting response from the MSAL.js team labels Mar 9, 2023
@ghost
Copy link

ghost commented Mar 15, 2023

@HansakaSS This issue has been automatically marked as stale because it is marked as requiring author feedback but has not had any activity for 5 days. If your issue has been resolved please let us know by closing the issue. If your issue has not been resolved please leave a comment to keep this open. It will be closed automatically in 7 days if it remains stale.

@ghost ghost added the no-issue-activity Issue author has not responded in 5 days label Mar 15, 2023
@ghost ghost closed this as completed Mar 22, 2023
@hansakaRightS
Copy link
Author

hansakaRightS commented Mar 28, 2023

@tnorling we have set the active account after login. now we have less no_account_error. i have one question, do we have to check if we have an activeAccount before calling the acquireTokenSilent ? currently we call the acquireTokenSilent and if the no active account, and when we get the error we are redirecting to login page.

@ghost ghost reopened this Mar 28, 2023
@ghost ghost added Needs: Attention 👋 Awaiting response from the MSAL.js team and removed no-issue-activity Issue author has not responded in 5 days Needs: Author Feedback Awaiting response from issue author labels Mar 28, 2023
@ghost
Copy link

ghost commented Apr 4, 2023

This issue requires attention from the MSAL.js team and has not seen activity in 5 days. @tnorling please follow up.

@tnorling
Copy link
Collaborator

tnorling commented Apr 4, 2023

What you've described is fine, although our recommended best-practice approach is to check if a user is signed in prior to calling acquireTokenSilent and invoking interaction if not.

@ghost ghost added Needs: Author Feedback Awaiting response from issue author and removed Needs: Attention 👋 Awaiting response from the MSAL.js team labels Apr 4, 2023
@hansakaRightS
Copy link
Author

hansakaRightS commented Apr 5, 2023

@tnorling I understand now, Thanks everyone for the support.

@ghost ghost removed the Needs: Author Feedback Awaiting response from issue author label Apr 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
answered Question has received "first qualified response" 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 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

7 participants