Home > OS >  How to add existing ASP CBAC authorization and authentication to a Blazor WebApp but not to use Enti
How to add existing ASP CBAC authorization and authentication to a Blazor WebApp but not to use Enti

Time:04-28

I need to add the MS ASP Authorization and Authentication to my Blazor web app.

The existing MS implementation assumes you use Entity Framework to store user and claim data.

In my case, I need to keep the existing CBAC MS ASP authorization and authentication functionality (including using Auth attributes and policies) but use my own way to store the user and claim data, not using the Entity Framework package.

I wonder, if anyone knows how to do it the easiest way?

CodePudding user response:

Blazor authorizes pages by getting the authentication state from the built in authentication state provider. You need to create your own and and override the GetAuthenticationState method. Here is an example that uses web assembly and authorizes users from a web token to help you implement your own logic: https://chrissainty.com/securing-your-blazor-apps-authentication-with-clientside-blazor-using-webapi-aspnet-core-identity/

  • Related