A simple authentication API built with ASP.NET Core, JWT, Entity Framework Core, and PostgreSQL.
This project demonstrates how to implement token-based authentication, protect API routes, and document endpoints using Swagger/OpenAPI.
- User registration
- User login with JWT generation
- Token-based authentication
- Protected endpoints using
[Authorize] - PostgreSQL integration with Entity Framework Core
- Interactive API documentation with Swagger
- ASP.NET Core Web API
- C#
- Entity Framework Core
- PostgreSQL
- JWT Authentication
- Swagger / OpenAPI
Client > Controller > Service > Entity Framework Core > PostgreSQL
AuthApi
│
├── Controllers/
│ ├── AuthController.cs
│ └── UserController.cs
│
├── Data/
│ └── AppDbContext.cs
│
├── Models/
│ └── User.cs
│
├── Services/
│ └── JwtService.cs
│
└── Program.cs
POST /auth/register
Creates a new user.
POST /auth/login
Returns a JWT token.
GET /user/profile
Returns information about the authenticated user.
Requires JWT token in the request header:
Authorization: Bearer {token}
The API includes Swagger UI for easy testing and documentation.
Access it at:
http://localhost:xxxx/swagger
git clone https://github.com/Lucas-aos/AuthApi.git
cd AuthApi
Update the connection string in:
appsettings.json
dotnet run
http://localhost:xxxx/swagger
- Register a new user
- Login to receive a JWT token
- Click Authorize in Swagger
- Paste the token
- Access protected endpoints
This project was built to practice:
- REST API development
- JWT authentication
- ASP.NET Core backend architecture
- Database integration using EF Core
- API documentation with Swagger
Lucas Albuquerque



