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

Popup authentication with other domain as redirect URI than application URI #2320

Closed
1 of 5 tasks
ferryferry opened this issue Sep 19, 2020 · 4 comments
Closed
1 of 5 tasks
Labels
msal-angular Related to @azure/msal-angular package question Customer is asking for a clarification, use case or information.

Comments

@ferryferry
Copy link

ferryferry commented Sep 19, 2020

Library

  • msal@1.x.x or @azure/msal@1.x.x
  • @azure/msal-browser@2.x.x
  • @azure/msal-angular@0.x.x
  • @azure/msal-angular@1.x.x
  • @azure/msal-angularjs@1.x.x

Description

I'm using MSAL in an embedded Angular app. Due to embedding, I don't have a public endpoint which is reachable from the outside (for redirect URI).

So I have hosted the application somewhere else, and after authentication (via popup) I want to retrieve the id_token and access_token from the popup. But MSAL doesn't recognize the popup came back with a result.

Examples:
I'm running the Angular app local (so not embedded in another application). And the URL is: https://localhost:4200.
The redirect URL i'm using is: https://localhost:4200. This works fine, and the app is logged in successfully.

When running local again, (https://localhost:4200) and setting the redirect URL to https://angular-host.z6.web.core.windows.net/ the popup is showing the Angular application homepage, with in the URL the right id_token / access_token params.

How do I extract those parameters and send them back to my parent window and notify MSAL that the authentication was actually successful?
image

@ferryferry ferryferry added the question Customer is asking for a clarification, use case or information. label Sep 19, 2020
@jmckennon
Copy link
Contributor

When your app is running on localhost, msal will not be able to parse the response from a popup running on a different domain. msal does not support using a different domain for the redirectUri.

Does the popup flow work if the app and the redirectUri are both on the angular-host.z6.web.core.windows.net domain?

@jmckennon jmckennon added the msal-angular Related to @azure/msal-angular package label Sep 21, 2020
@ferryferry
Copy link
Author

When your app is running on localhost, msal will not be able to parse the response from a popup running on a different domain. msal does not support using a different domain for the redirectUri.

Does the popup flow work if the app and the redirectUri are both on the angular-host.z6.web.core.windows.net domain?

Yes, when logging in on application and redirect-url on the same domain, it's working as expected.
But in my case this is not possible when the app is embedded (since Microsoft Business Central cannot forward that request into my Angular app).

So, I'm using the MSAL library to authenticate against microsoft-api's (main use-case is to deploy a PowerApp inside my application to a user's tenant). And the "normal" authentication in my app is working via another auth library (angular-oauth2-oidc). This library is supporting the other domain in the popup window since it's redirecting to a page which extracts the url fragment from the redirectUri and posts it via (window.opener || window.parent).postMessage(message, "*");

But I can't figure out how to let MSAL know that we have retrieved the token in that popup window

@jmckennon
Copy link
Contributor

Unfortunately msal does not support CORS redirect URIs as a security consideration. We will consider supporting scenarios like this one in the future.

@ferryferry
Copy link
Author

Okay, I understand this security concern. I changed the way my application is embedded in the other application by embedding the application in an iframe. This way the origin remains the same.

This way the login works as expected. Thanks!

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 2, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
msal-angular Related to @azure/msal-angular package question Customer is asking for a clarification, use case or information.
Projects
None yet
Development

No branches or pull requests

2 participants