So I've got MSAL-ANGULAR piece working correctly in my angular project. The problem lies when I've left the session open for a certain period of time and MSAL invokes re-authentication request to Azure AD when the token presumably expires. This automatically redirects to Azure AD for verification and will fail if the initiating path is not a registered path in Azure (e.g. localhost:1000/login will succeed but localhost:1000/orders will not).
Ideally I shouldn't have to specify every path permutation in Azure AD so I had the thought that I would intercept the authentication redirect, redirect to the default URL and then initiate the authentication process. Here was my original thinking:
I would think that the following code in the authentication layer would have a hook in place for this i.e.
import { MsalService, BroadcastService } from '@azure/msal-angular';
broadcast.subscribe("msal:loginSuccess",
() => {
...
}
this.broadcast.subscribe("msal:loginFailure",
() => {
...
});
but it doesn't look it hits that piece but, but rather, hooks in within app.routing:
import { MsalGuard } from "@azure/msal-angular";
const appRoutes: Routes = [
{ path: 'login', component: LoginComponent, canActivate: [MsalGuard] },
{ path: 'orders', component: OrdersComponent, canActivate: [MsalGuard] },
];
Any thoughts would be appreciated.