HOW TO IMPLEMENT CUSTOM AUTHORIZATION FOR BLAZOR SERVER APP USING AZURE AD FOR AUTHENTICATION

Опубликовано: 29 Октябрь 2024
на канале: Benjamin Fadina
1,287
6

I had to redo this video because of poor audio quality in the first one.
In this video I create a database containing three tables to store Azure AD Users and their roles.

Next I create a Data Service for the database inside my Blazor Server application.
Next I modify AccountController class by injecting the DataService into it.

Next I create a private method GetUserRolesAsync() which fetches user role from the database.
This method is then called inside CurrentUser() method.

Next I add authorize attribute to the top of pages I want to restrict access to.

Next I use authorizeview tag to group Navigation Menu Items I want to restrict access to.
Finally, I run the application to check if everything works well.

Source code can be pulled from https://github.com/benjaminsqlserver/...