59 Commits

Author SHA1 Message Date
Kshitij 490578cfe2 Added readme file. 2025-08-03 20:52:58 +05:30
Kshitij c45bc27c81 Fixed version for backend. It's not 1.5, it's still on 0.0.2. Dockerfile is at 1.5. 2025-08-03 20:42:39 +05:30
Kshitij 95d77fb3fe Added application.properties.bak to gitignore. 2025-08-03 20:35:54 +05:30
Kshitij 92b335410b Now passing in application.properties instead of hard coded values. 2025-08-03 20:35:31 +05:30
Kshitij b7ce85a5ec Lotta changes to Dockerfile.
- Bumped version to 1.5.
- Copying only the jar file now.
- No longer creating temp directory for downloading files. Fixed that in this version 0.0.2 of backend.
- Changed port to 8080.
- Updated CMD accn to new jar file.
2025-08-03 20:32:39 +05:30
Kshitij 7ae2eca31b Added instructions to create .p12 file using keytool (part of JDK) 2025-08-03 20:28:13 +05:30
Kshitij 0aba0e7911 Removed keystore.p12 2025-08-03 20:25:51 +05:30
Kshitij 7411f8b4fa Bumped version to 1.5 in pom.xml 2025-08-03 20:13:07 +05:30
SonaliChaudhari b2147537ca Handled Download API by not passing sensitive info 2025-07-27 15:05:33 +05:30
SonaliChaudhari 063bfa794a Implemented Cache for decrypted private key and handled refresh token 2025-07-25 13:36:15 +05:30
Kshitij 2622667de4 Moved contents from ./Backend/src/ to ./src/ 2025-07-23 14:54:13 +05:30
SonaliChaudhari dd958b0fde REMOVED OLD ENDPOINTS AND SOME ENCRYPTION AND DECRYPTION METHODS 2025-07-23 11:51:01 +05:30
Kshitij 4e028dd971 Added wiki directory in gitignore. 2025-07-04 01:45:15 +05:30
Kshitij a6325d5681 Set column type to longblob for encrypted_key field in entity/FileMetadata v0.0.2 2025-07-03 17:06:12 +05:30
Kshitij c5ff741f8c Refactor JWT config and enhance security, improve file download, and fix refresh token cleanup
- Restricted public auth endpoints to only /login and /register in SecurityConfig
- Added contentLength header and improved error response in FileController download API
- Refactored JwtService to load secret key and expiration from application properties
- Improved signing key handling using Base64 decoding
- Updated RefreshTokenRepository with @Transactional @Modifying delete query
- Ensured proper refresh token cleanup with flush() in RefreshTokenService
- Annotated refresh token methods with @Transactional for consistency
2025-07-03 16:59:29 +05:30
Kshitij 3920ec7fbd Using base64 encoded JWT secret key 2025-07-03 16:36:33 +05:30
Kshitij 4af5aabd42 Refactor encryption system to support hybrid RSA-AES encryption per file
- Changed file upload logic to:
  - Generate random AES key per file
  - Encrypt AES key using user's RSA public key
  - Store encrypted AES key, IV, and salt in FileMetadata entity

- Changed file download logic to:
  - Decrypt AES key using user's RSA private key (encrypted with password-derived AES)
  - Use decrypted AES key and IV to decrypt file contents from HDFS

- Modified FileMetadata entity:
  - Changed `encryptedKey` to @Lob byte[] to support large encrypted AES keys

- Updated User entity:
  - Encrypted private RSA key with password-derived AES
  - Stored associated salt and IV for decryption

- Updated AuthenticationService:
  - Generate RSA keypair during sign-up
  - Encrypt and store private key with AES (salt, IV)
  - Create user folder in HDFS upon registration

- Updated FileService:
  - Rewrote upload and download logic to support hybrid encryption
  - Handled key wrapping and unwrapping securely
  - Added logging for upload/download events

- Fixed FileController upload to remove password from endpoint
  - Password now only required during download for private key decryption

- Updated EncryptionUtil and RSAKeyUtil:
  - Added RSA OAEP support and helper methods
  - Added AES key generation, encryption, decryption utilities

FILE UPLOAD AND ENCRYPTION WORKS! TESTED USING HEXDUMP.
2025-07-03 16:22:41 +05:30
Kshitij 23eda639c0 Refactor file upload/download with service layer and secure encryption
- Replaced direct encryption logic in FileController with FileService delegation
- Added JWT-based username extraction in file operations
- Updated FileMetadata entity to include `uploadedAt` field and removed redundant getters/setters
- Refactored EncryptionUtil:
  - Switched to AES-CBC with PBKDF2 key derivation
  - Removed RSA-based encryption logic
  - Added salt and IV generation helpers
- Changed JwtAuthenticationFilter to fetch user by username (not email)
- Renamed method in FileMetadataRepository to match new parameter order

FILE UPLOAD NOW WORKS! TESTED USING CURL.
2025-07-03 15:20:10 +05:30
Kshitij f06dbd84ad Add user registration endpoint and HDFS directory creation
- Implemented a new registration endpoint in AuthController to handle user sign-ups.
- Integrated AuthenticationService to save the user and create a corresponding HDFS directory for the user upon registration.
- Updated User entity to return the username instead of email in getUsername method.
2025-07-03 14:24:04 +05:30
Kshitij 0661b2540f Added execution permission for mvnw 2025-07-03 04:49:41 +05:30
Kshitij 222fd796f2 Update application.properties for production deployment
- Set static MySQL connection with IP and password
- Changed server port from 8081 to 8080
- Enabled HTTPS with keystore configuration
- Exposed actuator endpoints for monitoring
- Removed old and unused commented-out configurations
2025-07-03 04:49:16 +05:30
Kshitij 7f6b2eb344 Refactor and secure backend configuration, DTOs, and authentication flow
- Updated pom.xml: removed redundant tags, grouped dependencies, added scopes, and upgraded plugins
- Enhanced RegisterUserDto with validation annotations and added missing fields (username, fullname)
- Updated User entity with builder constructor and removed redundant getters/setters
- Completed FileMetadata entity with Lombok and required setters/getters
- Improved HDFSConfig with correct annotation and clearer exception message
- Adjusted HTTP to HTTPS redirect port (8085 -> 8443)
- Allowed /actuator/** in SecurityConfig and disabled deprecated XSS protection
- Skipped JWT filter for /api/auth and /actuator paths
- Refactored AuthenticationService to use builder pattern and RSA key injection
- Fixed application.properties for static MySQL connection (removed ${MYSQL_PASSWORD})
2025-07-03 04:48:29 +05:30
Kshitij 88fd49c807 Refactor User entity and SignupRequest DTO to resolve method access issues and improve compatibility
- Added explicit getter/setter methods in User entity for use with service layer
- Implemented standard getters/setters in SignupRequest DTO
- Replaced incorrect imports from models.User to entity.User across services and repository
2025-07-03 03:54:20 +05:30
Kshitij 12355f25c7 Refactor Auth and HDFS controllers, fix User model, and improve HDFS config
- Rewrote AuthController to inject all dependencies via constructor
- Fixed token refresh/login logic and added rate limiter and blacklist support
- Implemented getters in LoginRequest DTO
- Updated User model to implement UserDetails and extend entity.User
- Switched HDFScontroller to use entity.User instead of models.User
- Rewrote HDFSConfig to include static getHDFS() method and secure config via env vars
- Simplified JwtService, added overload for entity.User, and fixed key handling
2025-07-03 03:47:08 +05:30
Kshitij 9cb9c67b09 Revoke refresh token on logout for enhanced session security 2025-07-03 03:21:53 +05:30
Kshitij 31f13b980b Update login response to return both access and refresh tokens 2025-07-03 03:19:15 +05:30
Kshitij 2379d95759 Add refresh token support with /api/auth/refresh endpoint
- RefreshToken entity added with 1-token-per-user logic.
- JWT can be renewed without full login using refresh token.
2025-07-03 03:15:31 +05:30
Kshitij 178a32f908 Removed obsolete files. Refactored certain files to use newer ones. 2025-07-03 03:10:51 +05:30
Kshitij 218ccb720f Implement token blacklist for JWT logout support
- TokenBlacklistService tracks invalidated tokens using Caffeine cache.
- AuthController adds tokens to blacklist on logout.
- JwtAuthenticationFilter blocks blacklisted tokens during authentication.
2025-07-03 02:57:29 +05:30
Kshitij dd52421392 Add brute-force protection with rate limiting on login
- Caffeine cache used to allow max 5 login attempts per minute.
- Login endpoint blocks IPs exceeding rate, returns 429 status.
- Failed attempts are reset after successful login or after 1 minute.
2025-07-03 02:47:19 +05:30
Kshitij aaf5d2dbd8 Add JWT authentication filter to secure protected routes
- Intercepts all requests and checks for Bearer token.
- Validates token signature and expiry using JwtService.
- Loads user from DB and sets authentication context.
- Sends 401 Unauthorized if token is missing, invalid, or expired.
2025-07-03 02:43:56 +05:30
Kshitij 4b21828510 Add JWT-based login and logout endpoints
- POST /api/auth/login authenticates user and returns JWT token.
- POST /api/auth/logout is a placeholder (client deletes token).
- JwtService handles token creation and expiry validation.
2025-07-03 02:38:55 +05:30
Kshitij e14f27830e Add HTTP to HTTPS redirect configuration using embedded Tomcat
- HTTP connector on port 8080 redirects to HTTPS (8443).
- Ensures users accessing http:// are forwarded to https://
- No need for external proxy (e.g., Nginx) for redirection.
2025-07-03 02:37:13 +05:30
Kshitij 04f291910f Harden Spring Security configuration and enforce HTTPS
- All requests now require HTTPS.
- Stateless sessions enabled for JWT-based auth.
- XSS, HSTS, and Frame-Options headers added.
- /api/auth/** is public, all other routes require authentication.
- CSRF disabled (assumes token-based auth).
2025-07-03 02:35:25 +05:30
Kshitij c88cb5ac0e Add secure file upload and download with per-user AES encryption
- FileController encrypts uploads using AES-GCM with salt and IV.
- Downloads are decrypted on-the-fly using user-supplied password.
- File metadata (salt, IV, username, path) stored in DB.
2025-07-03 02:32:42 +05:30
Kshitij c133617990 Move UserService to correct 'services' package and update related imports 2025-07-03 02:30:20 +05:30
Kshitij a9e7d23c3c Add HTTPS configuration for production profile
- SSL enabled on port 8443 using self-signed keystore.
- application-prod.yml configured for TLS.
2025-07-03 02:26:56 +05:30
Kshitij 91e0d50c0a Implement AES-GCM file encryption per user
- EncryptionService uses PBKDF2 to derive a key from user password and salt.
- AES-GCM encryption with 128-bit tag and 12-byte IV.
- Ready for streaming encryption to/from HDFS without temp files.
2025-07-03 02:26:46 +05:30
Kshitij 39aa31625d Add username validation and password breach check to signup
- Enforced alphanumeric-only usernames using regex validation.
- Passwords must be >= 8 chars and checked against haveibeenpwned.com.
- Improved SignupRequest DTO with validation annotations.
- Implemented UserService to handle password validation and encoding.
2025-07-03 02:26:30 +05:30
Kshitij 8ae2ced645 Harden ApplicationConfiguration with stronger BCrypt, cleanup, and security improvements
- Increased BCrypt password encoder strength to 12 for better hashing security.
- Switched to PasswordEncoder interface for flexibility (e.g., Argon2 support).
- Removed unused import (java.security.AuthProvider).
- Made all @Bean methods explicitly public.
- Added JavaDoc comments for better readability and maintainability.
- Improved exception message in UserDetailsService for clarity.
2025-07-03 02:01:05 +05:30
Kshitij d3e1aff0fb Fix: Downloading issue when deployed. Added a temp /Skycrate/downloaded directory and changed ownership to 1000:1000, this allows the file to be temporarily fetched to the server, then downloaded on client's site. Hoping to find a better (feasable) solution to this later. 2025-04-21 10:32:22 +05:30
Kshitij 18876f2780 Changed hdfs IP to docker container's hostname. 2025-04-20 20:51:01 +05:30
Kshitij b41b1071e6 Changed port from 8080 to 8081 in application.properties and exposed 8081 in Dockerfile for ref. 2025-04-20 04:25:10 +05:30
Kshitij c83898e34c Forgot to change the target dir in Dockerfile, my bad 😅 2025-04-20 03:57:18 +05:30
Kshitij 769ac030b3 Updated username, host and changed password to env var for DB in application.properties. 2025-04-20 03:54:04 +05:30
Kshitij 3801a9b5c2 Added maven binary directory in gitignore. 2025-04-20 03:50:13 +05:30
Kshitij 152ada0bad Added Dockerfile to build Docker image for backend. 2025-04-20 03:39:49 +05:30
vedang29 3b5736dc8e Retrieve Username by Email 2025-04-18 16:54:42 +05:30
SonaliChaudhari 03bdb5d898 Implemented Encryption and Decryption Needed to be as saved Response 2025-04-18 00:28:45 +05:30
SonaliChaudhari 5cd396951d MAIN CODE PUSHED ON MASTER BRANCH - NEED TO WORK ON ENCRYPTION AND DECRYPTION 2025-04-17 22:28:47 +05:30