This project is an authentication microservice based on .NET 9.
- JWT-based authentication
- User management
- Advanced configuration options
- Modern .NET 9 architecture
- Pagination support
- Secure password management with hashing
- Multiple DbContext and UnitOfWork infrastructure
- .NET 9 SDK
- SQL Server (or a compatible database)
- Clone the repository:
- Restore dependencies:
- Initialize User Secrets (run this once if you are using it for the first time to securely store sensitive data in the development environment):
dotnet user-secrets init
- Set the database connection string securely:
- For development, use User Secrets or environment variables.
dotnet user-secrets set "ConnectionStrings:Default" "<CONNECTION_STRING>"
- Set the JWT SecurityKey:
- For development, you can use User Secrets.
dotnet user-secrets set "JwtTokenOption:SecurityKey" "<SECURITY_KEY>"
- Run the application:
Note: When the application starts for the first time, the database and required tables will be created automatically thanks to the
app.ApplyMigration();operation. There is no need for an extra migration or manual database creation step.
- All configurations are managed via the
appsettings.jsonfile or environment variables. - Do not store sensitive information such as connection strings directly in
appsettings.json.
src/Presentation/MediatorAuthService.Api: API projectsrc/Application: Application layersrc/Domain: Domain models and rulessrc/Infrastructure: Data access and infrastructure layer
- .NET 9 – Application infrastructure and API development
- ASP.NET Core – Web API and middleware architecture
- Entity Framework Core – ORM and database operations
- JWT (JSON Web Token) – Authentication and authorization
- User Secrets – Secure secret management in development
- Dependency Injection – Dependency management
- Automapper – Object mapping
- FluentValidation – Model validation
- Swagger / Swashbuckle – API documentation
- MediatR – CQRS and mediator pattern
- API Versioning (Microsoft.AspNetCore.Mvc.Versioning) – API version management
- Pagination – Efficient data listing for large datasets
- Hashing – Secure password storage and verification
- Multiple DbContext & UnitOfWork – Integrated transaction management with multiple DbContexts
- Docker – Containerization and deployment
This project supports API versioning using the Microsoft.AspNetCore.Mvc.Versioning package.
By default, versioning is done via URL segment:
/api/v1/Auth
To add a new version, you can add an attribute like [ApiVersion("2.0")] to your controller.
This project is licensed under the MIT License.