A robust Spring Boot application demonstrating enterprise-grade security practices. This project moves beyond standard authentication to implement Defense in Depth strategies including OAuth2 Single Sign-On, Database Encryption (AES), and DoS Protection.
This application actively defends against the OWASP Top 10 vulnerabilities:
- Hybrid Login System: Supports both Standard Login (Username/Password) and Google OAuth2 Single Sign-On (SSO).
- BCrypt Hashing: Passwords are never stored in plain text.
- Session Management: Uses
HttpOnlyandSecurecookies to prevent session hijacking.
- AES-256 Encryption: Sensitive employee data (e. g., Emails) is automatically encrypted before saving to the database and decrypted only when viewed by authorized admins.
- Transparent Converter: Implements a JPA
AttributeConverterso the database administrator sees only ciphertext (e.g.,kL9#mP2...).
- Rate Limiting (DoS Protection): Implements
Bucket4jtoken-bucket algorithm to limit requests per IP address, preventing Denial of Service attacks. - TLS/HTTPS: Enforces end-to-end encryption for data in transit using a self-signed SSL certificate (Port 8443).
- Role-Based Access Control (RBAC):
ADMIN: Can Delete employees.MANAGER: Can Add/Update employees.EMPLOYEE: Read-only access.
- Audit Logging: Tracks critical actions (Create, Update, Delete) with user identity timestamps for accountability.
- SQL Injection: Uses Spring Data JPA (Parameterized Queries) to sanitize all database inputs.
- XSS Protection: Implements strict input validation (
@Email,@Size,@NotBlank) to reject malicious scripts before processing.
- Backend: Java 17, Spring Boot 3, Spring Security 6
- Database: MySQL 8.0
- Security: OAuth2 Client, Bucket4j, BCrypt, AES
- Frontend: HTML5, CSS3 (Material Design), JavaScript (Fetch API)
- Build Tool: Maven
- Java 17+
- MySQL Server
- Maven
Create a MySQL database named security_app. The application will automatically create the tables (users, employee, authorities) on first run.
Update src/main/resources/application. properties:
# Database Credentials
spring.datasource. username=YOUR_DB_USERNAME
spring.datasource.password=YOUR_DB_PASSWORD
# Google OAuth2 Credentials (Get these from Google Cloud Console)
spring.security.oauth2.client.registration. google.client-id=YOUR_CLIENT_ID
spring.security. oauth2.client.registration.google.client-secret=YOUR_CLIENT_SECRET./mvnw spring-boot:runGo to: https://localhost:8443/Login/index.html (Note: You must accept the self-signed certificate warning in the browser since this is a local development environment.)
- Register: Create a new local account.
- SSO: Click "Continue with Google" to auto-register via OAuth.
- Dashboard:
- Admins: View decrypted emails and delete records.
- Auditing: Check the application console logs to see the audit trail of your actions.