title | last update |
---|---|
ASP.NET 7 Web API JWT Authentication and Role-Based Authorization |
2024-Sep-28 |
- 2024/09 (V4)
- .Net 8
- Improve Program.cs
- Add IdentityRole + Custom Stores + Custom ClaimPrincipalFactory
JWT(Json Web Token) is one of the most popular ways to implement authentication and role-based authorization in WebAPI Projects. It uses claims and manage your security.
In this repository, we create a new .Net 7 WebAPI project from scratch and implement Fully authentication and authorization in it.
https://www.youtube.com/watch?v=KRVjIgr-WOU
- "Microsoft.AspNetCore.Authentication.JwtBearer"
- "Microsoft.AspNetCore.Identity.EntityFrameworkCore"
- "Microsoft.EntityFrameworkCore.SqlServer"
- "Microsoft.EntityFrameworkCore.Tools"
- https://www.nuget.org/packages/Microsoft.AspNetCore.Authentication.JwtBearer
- https://www.nuget.org/packages/Microsoft.AspNetCore.Identity.EntityFrameworkCore
- https://www.nuget.org/packages/Microsoft.EntityFrameworkCore.SqlServer
- https://www.nuget.org/packages/Microsoft.EntityFrameworkCore.Tools
- Dtos
- Static classes
- Entities
- Dependency injection
- Refactoring
- Git branches
- Pull request
- Identity Package
- Custom User fields
- Add request headers to swagger
💖 You can Buy me a coffee to support: https://www.buymeacoffee.com/DevEmpower 💖
Disclaimer: This repository is just a tutorial for beginners and it is not a commercial code. Use these Codes and functions on your responsibilities. Don’t forget that security is very important in any software and website and you must be aware of any functionality of codes of your projects.