In the world of software development, a feature isn’t “done” until it is secure. Module 13 covers the “Who are you?” and “What are you allowed to do?” of a .NET application.
It is easy to confuse these two, but they are distinct steps in the security chain:
This is a complete membership system built by Microsoft. It handles:
AspNetUsers and AspNetRoles) in your database.While standard Web Apps use Cookies, modern APIs use JWTs. When a user logs in, the server sends back a “Token”—a signed string that the browser or mobile app stores.
Why JWT? It’s stateless. The server doesn’t need to store a session; it just validates the signature of the token the client sends in every request header.
Checks if a user belongs to a specific group.
C#
[Authorize(Roles = "Admin")]
public IActionResult DeleteUser() { ... }
Modern and flexible. You define a “Requirement” (e.g., “Must be over 18” or “Must have a specific Employee ID”) and group them into a Policy.
You’ve seen this whenever you click “Log in with Google” or “Log in with GitHub.”
When building production-grade APIs, you apply security at multiple layers:
By the end of this module, your applications will no longer be “open doors.” You will be able to: