Authify is a secure authentication backend built using Spring Boot and Spring Security. It provides APIs for user authentication, authorization, and secure access control using JWT (JSON Web Tokens).
This project demonstrates how to implement a production-style authentication system with a layered architecture including controllers, services, repositories, DTOs, filters, and exception handling.
- User registration and login
- JWT-based authentication
- Secure API endpoints using Spring Security
- Email integration using SMTP
- Environment-based configuration using profiles
- DTO and mapper layer for clean architecture
- Global exception handling
- Password encryption using BCrypt
- Backend: Spring Boot, Spring Security, Spring Data JPA, SMTP Email Service
- Language: Java
- Security: JWT Authentication, BCrypt Password Encoder
- Database: MySQL
- Build Tool: Maven
- API Style: RESTful APIs
src
└── main
├── java/com/project/authentication_system
│ ├── config → Security and application configuration
│ ├── controller → REST API endpoints
│ ├── dto → Data transfer objects
│ ├── entity → Database entities
│ ├── exception → Global exception handling
│ ├── filter → JWT authentication filters
│ ├── mapper → DTO ↔ Entity mapping
│ ├── repository → Database repositories
│ ├── service → Business logic
│ └── AuthenticationSystemApplication.java
│
└── resources
├── application.properties
└── application-dev.properties
- User registers an account
- Password is encrypted using BCrypt
- User logs in with credentials
- Server generates a JWT token
- Client sends JWT in request headers (typically
Authorization: Bearer <token>) - Spring Security filter validates the token
- Access is granted to protected APIs
git clone https://github.com/rarestpreet/Authify_Backend.gitConfigure the required environment variables:
DB_URLDB_USERDB_PASSSECRET_KEYMAIL_USERMAIL_PASS
Run the main class:
AuthenticationSystemApplication.java
Server will start at:
http://localhost:8080
| Method | Endpoint | Description |
|---|---|---|
| POST | /auth/register |
Register new user |
| POST | /auth/login |
User login |
| GET | /user/profile |
Get user profile |
| POST | /auth/logout |
Logout user |
and more.
This project demonstrates:
- Spring Security authentication
- JWT token generation and validation
- Secure REST API development
- Layered backend architecture (Controller → Service → Repository + DTO/Mapper)
- Exception handling and validation
- Refresh token support
- OAuth2 / Google login
- Role-based authorization (Admin/User)
- Docker containerization
- API documentation using Swagger / OpenAPI