Azure B2C for a Blazor WASM randomly stopped working?

Jeremy Beare 0 Reputation points
2024-04-18T14:22:24.6333333+00:00

Hey all sorry to be a burden but I am running out of options for this so I thought I would ask

Over the Easter Break I taught myself how to implement Azure B2C in a Blazor WASM+Api environment for SPA (using .Net 7). I followed this tutorial for the entirely of the build (https://learn.microsoft.com/en-us/aspnet/core/blazor/security/webassembly/hosted-with-azure-active-directory-b2c?view=aspnetcore-7.0#additional-resources) And I got it working by the end of it. I did a bit of refinement but not much and it still worked. I went away for my holiday and to study some evening courses and last night I returned to start adding a custom claim (roles) to allow my system to limit points based on a role.

What I found when I came back has been frustrating me as for some reason it no longer triggers the "NotAuthorized" tag of the AuthenticateRouteView even though when I debug the MainLayout it clearly has no user of any sort in the AuthenticationState. Debugging using jwt.ms no longer worked and I believe it is due to an invalid signature. I tested this on the Azure Portal by running the User Flow.

The most I have done since it initially worked was add the Roles to the User Attributes, modified the redirect URI (currently https://jwt.ms/ to try and debug this though that is failing with a reported invalid signature). I have also rebuilt the entire of the App Registration, Permissions and User Flows to no avail. Does anyone have any ideas?

(This is my first time posting here so please be reasonable when helping me. This subject is outside my knowledge zone)

Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
19,532 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. James Hamil 21,776 Reputation points Microsoft Employee
    2024-04-24T20:23:53.85+00:00

    Hi @Jeremy Beare , sorry for the delay in response. Based on the information you provided, it is possible that the issue could be related to the changes you made to the User Attributes or the redirect URI.

    To troubleshoot this issue, you can try the following steps:

    1. Check if the changes you made to the User Attributes or the redirect URI are causing the issue. Try reverting these changes and see if the authentication works as expected.
    2. Check if there are any errors or warnings in the browser console when you try to authenticate. This could provide more information about the issue.
    3. Check if the Azure B2C User Flow is working as expected. Try running the User Flow and see if you are able to authenticate successfully.
    4. Check if the issue is related to the JWT signature. Try using a different tool to decode the JWT token and see if it works.

    Please let me know if you have any questions and I can help you further.

    If this answer helps you please mark "Accept Answer" so other users can reference it.

    Thank you,

    James

    0 comments No comments