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

Authentication issues in Angular app with Static Web Apps and MSAL #1522

Open
alexkolt opened this issue Aug 3, 2024 · 0 comments
Open

Authentication issues in Angular app with Static Web Apps and MSAL #1522

alexkolt opened this issue Aug 3, 2024 · 0 comments

Comments

@alexkolt
Copy link

alexkolt commented Aug 3, 2024

Describe the bug

After successful login through SWA, MSAL doesn't detect any authenticated accounts, causing a redirect loop.

Setup

Angular application using the latest MSAL version
Deployed on Azure Static Web Apps (SWA) with Entra ID authentication
Route guard checks MSAL for user authentication
If not authenticated, redirects to SWA auth route

Expected behavior
User authenticates with SWA and is able to be used by MSAL when Angular application auth runs.

SWA auth config

"identityProviders": {
  "azureActiveDirectory": {
    "registration": {
      "openIdIssuer": "https://login.microsoftonline.com/#{PLACEHOLDER_ADTENANTID}#/v2.0",
      "clientIdSettingName": "AZURE_CLIENT_ID",
      "clientSecretSettingName": "AZURE_CLIENT_SECRET"
    }
  }
}

MSAL config
Same Tenant and Client Id

Route guard(simplified) causing the loop

if (this.msal.instance.getAccounts().length > 0)
  return 'AUTHENTICATED'

return redirectTo(SWAURL + '/.auth/login/aad')

Additional context
The application should be able to run and authenticate locally using only Angular, without relying on Azure Static Web Apps or its CLI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant