AuthService Microservice

Authentication and authorization microservice

Self-contained authentication and authorization system with Spring Boot and JWT.

Project Overview

I developed a complete authentication and authorization microservice using Spring Boot and Java 21. This system is essentially a self-contained and ready-to-use service that handles everything related to user registration, login, and access control. It provides a complete solution that includes role and permission management, password management, and support for multiple languages (Spanish and English), all packaged in a single service. The system uses JSON Web Tokens (JWT) for authentication, allowing client applications to verify user identity without needing to query the database on each request.

Main Features

JWT authentication system with access and refresh tokens

User registration and login with email verification

Role and permission management system

Password recovery via email

Session management with configurable limits

Multi-language support (Spanish and English)

Password encryption with BCrypt

Token revocation and blacklisting

Email notifications with Thymeleaf templates

REST API documented with Swagger

Custom exception handling system

Database connection pooling with HikariCP

Technical Challenges

Challenge 1

Implement secure session management with JWT tokens and prevent unauthorized access

Solution:

Created a JWT token management system with separate tables for storing tokens and implementing session limits with automatic cleanup

Challenge 2

Create a custom exception handling system for better error management

Solution:

Developed a global exception handler with custom exceptions and an exception factory for consistent error management

Challenge 3

Design a scalable architecture that can work as both template and microservice

Solution:

Implemented a modular architecture with Spring Boot that can be easily integrated as a microservice or used as a project template

Technologies Used

Spring Boot 3.4.4 Spring Security 6 Spring Data JPA Hibernate 6.5.2 PostgreSQL JWT (JJWT 0.12.6) BCrypt SpringDoc OpenAPI 3 Swagger UI Thymeleaf Lombok Jackson HikariCP
AuthService Microservice

Project Information

Duration: 3 months
My Role: Full Stack Developer