This project implements a secure authentication system using Spring Boot Security with JWT (JSON Web Token) authentication. The system provides user registration and authentication endpoints, along with secured API routes.
- Stateless session management
- JWT-based authentication
- CSRF protection disabled for API endpoints
- Public endpoints for authentication
- Protected routes requiring authentication
All API endpoints are documented in requests.http file for easy testing. The following endpoints are available:
- POST /api/v1/auth/register - User registration
- POST /api/v1/auth/authenticate - User authentication
- GET /api/v1/demo-controller - Protected demo endpoint (requires JWT token)
- Intercepts all incoming requests
- Validates JWT tokens in the Authorization header
- Extracts user details and sets up security context
- Implements
OncePerRequestFilterfor single execution per request
- Custom user implementation with
UserDetailsinterface - Role-based authorization support
- Secure password handling using BCrypt encoding
- Email-based user identification
- Custom
DaoAuthenticationProviderconfiguration - Username/password authentication
- Integration with
UserDetailsService
- User sends registration/login request
- System validates credentials
- Upon successful authentication, JWT token is generated
- Token is returned to client
- Subsequent requests must include the JWT token in Authorization header
- Filter Layer: JWT authentication filter
- Provider Layer: DAO authentication provider
- User Details Layer: Custom user details service
- Password Encoding: BCrypt password encoder
All endpoints except /api/v1/auth/** require authentication. Protected endpoints include:
/api/v1/demo-controller- Example protected endpoint
- Spring Security
- Spring Web
- Spring Data JPA
- Jakarta Persistence
- Lombok
- JWT Implementation
- Stateless authentication
- Encrypted password storage
- Token-based authentication
- Role-based access control
- Secure password encoding
- Protected endpoints
All API endpoints can be tested using the provided requests.http file in the project root. Simply open it in IntelliJ IDEA and use the built-in HTTP client to execute the requests.
