Skip to content

adriEstigarribia/todo-api-auth

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 

Repository files navigation

📝 Todo API – JWT Authentication

This project is a simple To-Do List Web API built with ASP.NET Core that demonstrates JWT authentication, user-scoped data access, and clean architecture practices.


🎯 Features

  • CRUD operations for To-Do items
  • JWT-based authentication
  • Tasks are scoped to the authenticated user
  • Data persistence with Entity Framework Core + SQLite
  • Unit and integration tests

🧱 Architecture

The solution follows a clean, layered structure:

  • Domain – Core entities and behavior
  • Application – Use cases, DTOs, interfaces
  • Infrastructure – Persistence, repositories, security
  • API – Controllers and HTTP layer
  • Tests – Unit and integration tests

Business logic lives in the Application layer, keeping the API thin and testable.


🔐 Authentication & User Scoping

  • A login endpoint issues a JWT for a static test user
  • The authenticated user is obtained from JWT claims via IUserContext
  • Each TodoItem stores a UserId
  • All operations are filtered by the authenticated user

User management is intentionally out of scope.


🧪 Testing

  • Unit tests cover application services and user-scoped behavior
  • Integration tests validate JWT authentication and API endpoints
  • Tests are written using xUnit, Moq, and FluentAssertions

Configure JWT Secret

For security reasons, JWT secrets are not committed to source control.
You must provide a valid secret at runtime.

The secret must be at least 32 characters long.

▶️ Running the Project

dotnet run --project Todo.Api
dotnet test

About

RESTful To-Do List API built with .NET 8, JWT authentication and EF Core

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages