Azure / Azure/static-web-apps

Azure B2C Custom Auth Provider doesn't seem to work

Open
#1,495 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
346
Forks
67
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**
I'm trying to configure Custom Auth Provider with Azure Static Web Apps while on the "Standard" Pricing Plan. I'm using Azure B2C as the auth provider as we want to allow our users from our b2c account to be able to login to this static web apps.

1. The index page is accessibile even though the allowedRoles is set to be "authenticated"
2. typing "./auth/login/aadb2c" in the browser returns 404

![image](https://github.com/Azure/static-web-apps/assets/25155738/eb63140f-5835-4b82-b9d5-696d006e914a)
![image](https://github.com/Azure/static-web-apps/assets/25155738/27943cff-cdf8-4e93-8f82-ed6ed6381986)
![image](https://github.com/Azure/static-web-apps/assets/25155738/e12e5ae2-83d7-4aef-b63a-66279c0a6cef)

**below is my staticweapp.config.json file**
```
{
"routes": [
{
"route": "/login",
"rewrite": "/.auth/login/aadb2c"
},
{
"route": "/logout",
"redirect": "/.auth/logout",
"allowedRoles": ["authenticated"]
},
{
"route": "/.auth/login/twitter",
"statusCode": 404
},
{
"route": "/.auth/login/google",
"statusCode": 404
},
{
"route": "/.auth/login/aad",
"statusCode": 404
},
{
"route": "/*",
"allowedRoles": ["authenticated"]
}
],
"responseOverrides": {
"401": {
"statusCode": 302,
"redirect": "/.auth/login/aadb2c"
}
},
"navigationFallback": {
"rewrite": "index.html",
"exclude": [
"/src2/docs/images/*.{png,jpg,gif,ico}",
"/src2/docs/img/*.{png,jpg,gif,ico}",
"/*.{css,scss,js}"
]
},
"auth": {
"rolesSource": "/api/Roles",
"identityProviders": {
"customOpenIdConnectProviders": {
"aadb2c": {
"registration": {
"clientIdSettingName": "AADB2C_PROVIDER_CLIENT_ID",
"clientCredential": {
"clientSecretSettingName": "AADB2C_PROVIDER_CLIENT_SECRET"
},
"openIdConnectConfiguration": {
"wellKnownOpenIdConfiguration": "https://.b2clogin.com/.onmicrosoft.com/B2C_1_SiIn/v2.0/.well-known/openid-configuration"
}
},
"login": {
"nameClaimType": "emails",
"scopes": [],
"loginParameterNames": []
},
"enabled": true
}
}
}
}
}

```

**Expected behavior**
1. I'm expecting for the page to automatically navigate to the "login" URL since I configured the wildcard route allowedRoles to be "authenticated" but users can still access the page even though they are not authenticated

2. checking the "/.auth/me" shows this
![image](https://github.com/Azure/static-web-apps/assets/25155738/807fac41-f04d-46e0-b3ad-ef9190c7fc21)

3. Navigating to "/.auth/login/aadb2c" returns 404 not found
![image](https://github.com/Azure/static-web-apps/assets/25155738/c2d8b484-909f-435e-ab22-38a3d928502d)

**Device info (if applicable):**
- Browser: Edge

**Additional context**

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.