When CDN and app live on different hosts, MSAL Guard calculates the destination url erroneously #7435
Labels
bug-unconfirmed
A reported bug that needs to be investigated and confirmed
more-information-needed
Use this label when you are waiting on information from the issue creator
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.
Core Library
MSAL.js (@azure/msal-browser)
Core Library Version
3.27.0
Wrapper Library
MSAL Angular (@azure/msal-angular)
Wrapper Library Version
3.1.0
Public or Confidential Client?
Public
Description
Scenario
https://cdn.example.com/my-app/1.2.3/
https://app.example.com/
(maybe it has the API there, or just a lot of important proxies etc)The idiomatic way of doing this
--base-href="https://cdn.example.com/my-app/1.2.3/"
https://app.example.com/
as APP_BASE_HREF (otherwise no routes will work)This will set
<base href="https://cdn.example.com/my-app/1.2.3/">
in the builtindex.html
, not hardcode any base urls in the assets, and prefix all routes in the app withhttps://app.example.com/
. Otherwise they'll try to use the base href and you'll end up on the CDN.Error Message
What happens is that, a lot of times, the MSAL library will redirect away for auth, then back again to the CDN and not the app! Which of course explodes, because that's not where the app lives, it's served by a web server on
https://app.example.com/
.I still haven't understood exactly when it happens and when it doesn't but the culprit seems to live here:
It calculates the baseUrl using the
base
element. Which Angular wants you to set to the CDN!Here's some context where people got mad when Angular deprecated
deployUrl
(later reversed, but with gotchas) with suggestions about the idiomatic way of serving things: angular/angular-cli#23765MSAL Logs
Not sure what logs are applicable here. I can barely capture anything before getting redirected away, I have to throw myself on the escape key :-)
Network Trace (Preferrably Fiddler)
MSAL Configuration
Relevant Code Snippets
Reproduction Steps
<base href>
as per Angular recommendationsgetDestinationUrl
by using the MsalGuardExpected Behavior
I expect to - when authenticating - jump back to where I started (the place the app is hosted from), not a completely different url (the referenced base href for the CDN).
Identity Provider
Entra ID (formerly Azure AD) / MSA
Browsers Affected (Select all that apply)
Chrome, Firefox, Edge, Safari
Regression
No response
The text was updated successfully, but these errors were encountered: