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.

Default policy

Default policy - ASP.NET Core Tutorial

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

Start my 1-month free trial

Default policy

- [Instructor] .NET Core uses only one instance of the IAuthorizationPolicy provider that we used on the last part. So, this means that we need to always have a backup plan if something goes wrong. Like, for example, piercing a policy name fails, no perimeter is provided, etcetera. And to avoid these kind of issues, we are going to use the GetDefaultPolicyAsync method. And for that, let us go to our project, and write some code. In here we need to go to our custom authorization policy provider, so for that we go to solution explorer, then inside the Helpers method, we have the minimum age policy provider. And then here we see that the iAuthorizationPolicyProvider comes with two methods. The first one is the GetDefaultPolicyAsync, and the other one is the GetPolicyAsync, which we talked about on the last part. And on the spot we are going to use the GetDefaultPolicyAsync method, to write a default policy. So in here we are going to create the new policy using the authorization policy…

Contents