A production-style Spring Boot authentication service built with JWT, email verification, password reset, and refresh token support. This project demonstrates how to build a secure and reusable authentication backend that can be integrated into any web or mobile application.
- Java 21
- Spring Boot
- Spring Security
- JWT (JSON Web Token)
- PostgreSQL (Neon)
- Brevo SMTP (Email Service)
- Maven
- Docker
Explore and test the API using Swagger UI:
π Swagger UI
Swagger provides interactive API documentation where you can:
- Test authentication endpoints
- View request/response schemas
- Understand API flows
- User registration with email & password
- Secure login with JWT authentication
- Refresh token support
- Logout with refresh token revocation
- Email verification after registration
- Password reset via email
- Email delivery using Brevo SMTP
- BCrypt password hashing
- JWT authentication filter
- Stateless authentication
- Token expiration handling
- PostgreSQL database
- JPA / Hibernate ORM
- Token lifecycle management
- Access Token (JWT)
- Refresh Token
- Email Verification Token
- Password Reset Token
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/auth/register | Register a new user |
| POST | /api/auth/login | Login user |
| POST | /api/auth/refresh | Refresh access token |
| POST | /api/auth/logout | Logout user |
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/auth/verify-email | Verify email using token |
| GET | /api/auth/verify-email | Verify email via link |
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/auth/forgot-password | Send password reset email |
| POST | /api/auth/reset-password | Reset password |
- User registers
- Verification token is generated
- Email sent via Brevo
- User clicks verification link
- Email is marked as verified
- User requests password reset
- Reset token generated
- Email sent with reset link
- User sets new password
./mvnw spring-boot:runBuild the image:
docker build -t auth-service .Run the container:
docker run --env-file .env -p 8080:8080 auth-serviceHealth check endpoint:
GET http://localhost:8080/test
Expected response:
Rockrangerz Spring Boot Docker Test Successful
authentication-service
β
βββ Dockerfile
βββ pom.xml
βββ README.md
βββ .dockerignore
βββ .gitignore
βββ .env.example
βββ mvnw
βββ mvnw.cmd
β
βββ src
β βββ main
β β βββ java
β β β βββ com
β β β βββ rockrager
β β β βββ authentication
β β β β
β β β βββ AuthenticationApplication.java
β β β β
β β β βββ config
β β β β βββ SecurityConfig.java
β β β β
β β β βββ controller
β β β β βββ AuthController.java
β β β β βββ TestController.java
β β β β
β β β βββ dto
β β β β βββ request
β β β β β βββ RegisterRequest.java
β β β β β βββ LoginRequest.java
β β β β β βββ RefreshTokenRequest.java
β β β β β βββ LogoutRequest.java
β β β β β βββ VerifyEmailRequest.java
β β β β β βββ ForgotPasswordRequest.java
β β β β β βββ ResetPasswordRequest.java
β β β β β
β β β β βββ response
β β β β βββ AuthResponse.java
β β β β
β β β βββ entity
β β β β βββ User.java
β β β β βββ RefreshToken.java
β β β β βββ EmailVerificationToken.java
β β β β βββ PasswordResetToken.java
β β β β
β β β βββ repository
β β β β βββ UserRepository.java
β β β β βββ RefreshTokenRepository.java
β β β β βββ EmailVerificationTokenRepository.java
β β β β βββ PasswordResetTokenRepository.java
β β β β
β β β βββ security
β β β β βββ jwt
β β β β β βββ JwtAuthenticationFilter.java
β β β β β βββ JwtService.java
β β β β β
β β β β βββ user
β β β β βββ CustomUserDetails.java
β β β β βββ CustomUserDetailsService.java
β β β β
β β β βββ service
β β β β βββ AuthService.java
β β β β βββ EmailService.java
β β β β
β β β βββ util
β β β
β β βββ resources
β β βββ application.properties
β β βββ static
β β βββ templates
β β
β βββ test
β βββ java
β βββ com
β βββ rockrager
β βββ authentication
β βββ AuthenticationApplicationTests.java
- users
- refresh_tokens
- email_verification_tokens
- password_reset_tokens
- HTML email templates
- OAuth login (Google / GitHub)
- API rate limiting
- Swagger API documentation
- Deployment to cloud platforms
Mohan Kumar
Backend Developer | Java | Spring Boot