ngx-feature-toggle icon indicating copy to clipboard operation
ngx-feature-toggle copied to clipboard

Using NgxFeatureToggleRouteGuard with MsalGuard in @azure/msal-angular

Open brandonsmith86 opened this issue 1 year ago • 0 comments

I'm submitting a ... (check one with "x")

  • [ ] bug report => search github for a similar issue or PR before submitting
  • [ x] feature request

Current behavior

Behavior is specific to using the route guard in combination with @azure/msal-angular package (for handling authentication). Route guard will always return false when MSAL is in process of getting token. This causes the guard to redirect to the URL configured in redirectTo. Once MSAL is ready to redirect to identity provider for token acquisition, it uses the redirectTo URL to bring the user back to the app (instead of the initial one requested by the user).

Expected behavior

Route guard does not evaluate (or does not redirect) until MSAL is finished initializing. It's possible that this is supported and I just haven't found the documentation. If that is the case, please share. 🙂

Reproduction of the problem

  1. Configure Angular app with SSO using @azure/msal-angular
  2. Configure ngx-feature-toggle to use a route guard, that also has an MsalGuard
  3. Navigate to guarded route without auth token

What is the motivation / use case for changing the behavior?

To be able to use this package in combination with MSAL.

Please tell us about your environment:

Reproducible on both MacOS and Windows.

  • Browser: Only tested on Chrome

  • Language: all

  • Node (if applicable): node --version = 20.10

brandonsmith86 avatar Jun 17 '24 17:06 brandonsmith86