How to use policy-based authorization in ASP.Net Core – Info Web Dev
If you have experience building ASP.Net applications, you are undoubtedly familiar with role-based authorization. In ASP.Net core – Microsoft's lean and modular framework that can be used to build modern-day web applications on Windows, Linux, or MacOS – we have an additional option.
policy-based authorization is a new feature introduced in ASP.Net Core that allows you to implement a loosely coupled security model. In this article I will explain what policy-based authorization is all about and how we can implement it in ASP.Net Core.
Assuming that you have .Net Core installed in your system, follow the steps below to create a new ASP.Net Core project in Visual Studio 2017.
- Open Visual Studio
- Click File -> New -> Project
- In the New Project Dialog window, select the “ASP.NET Core Web Application” project template
- Specify the name and location for your project and click OK to save
- Select “Web API” from the list of templates displayed, make sure Authentication is set to “No Authentication and the Docker support box is unchecked, and click OK
And that's all you need to do to create an ASP.Net Core Web application that leverages Web API. Let's now explore how we can build a custom policy based security model.
Article Prepared by Ollala Corp