From the course: ASP.NET Core Identity: Authorization Management

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Using custom IAuthorizationPolicyProvider

Using custom IAuthorizationPolicyProvider - ASP.NET Core Tutorial

From the course: ASP.NET Core Identity: Authorization Management

Start my 1-month free trial

Using custom IAuthorizationPolicyProvider

- [Instructor] The custom minimum age authorize attribute that we created on the last part makes it really easy to request different age policies without having to create them one by one in our Startup.CS class. Now the next problem that we need to solve is making sure that the authorization policies are available for all different ages, and this is when the IAuthorizationPolicyProvider interface comes into play. So let us take for instance the MinimumAgeAuthorizationAttribute that we created on the last part. So by using this authorization attribute we have defined the MinimumAge plus the Age value pattern. What we need to do next is that we need to get the age and parse it to see if it's a value of integer or not, then create a new authorization policy by using the AuthorizationPolicyBuilder and at the end we need to add the requirements. So in our case we are going to add the MinimumAge requirement that we created on the last chapter. So now let us go to our project and see how we…

Contents