Securing Your Web API
This chapter is about security. The collection of recipes in this chapter covers the two fundamental aspects of API security: ensuring secure communication through HTTPS and implementing authentication and authorization mechanisms.
The first two recipes in this chapter focus on HTTPS implementation, guiding you through enforcing HTTPS and setting up custom development domains with self-signed certificates. Then, we will shift to focus on ASP.NET Core’s authentication and authorization capabilities. We will implement both cookie-based and JSON Web Token (JWT)-based authentication, along with role-based and policy-based access control.
We are going to cover the following recipes in this chapter:
- Rejecting HTTP requests with custom
ProblemDetails
middleware - Setting up HTTPS on a custom domain – creating a self-signed certificate with PowerShell
- Setting up ASP.NET Core Identity
- Using cookie authentication in ASP.NET Core Web...