Skip to content

Using NgxFeatureToggleRouteGuard with MsalGuard in @azure/msal-angular #301

@brandonsmith86

Description

@brandonsmith86

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions