Fixing improper authorization
Incorrectly using ASP.NET Core's authorization components could lead to insecure code. The authorization feature offers a simple and declarative way to impose authorization, but mistakes can occur in implementing this. In this recipe, we will correctly implement the role-based authorization feature of ASP.NET Core in our sample Online Banking application.
Run the sample app to verify that there are no build or compile errors. In your command shell, navigate to the sample app folder at \Chapter06\improper-authorization\before\OnlineBankingApp
.
Let's see in action how improper authorization can lead someone to use functions a customer is not authorized to use.
Testing improper authorization
Here are the steps:
- Navigate to Terminal | New Terminal in the menu or do this by simply pressing Ctrl + Shift + ' in VS Code.
- Type the following command in the terminal to build and run the sample app:
dotnet run
- Open a browser...