Authentication Overview
DriveX implements a credential-based authentication system using email and password. Passwords are securely hashed using BCrypt before storage.Authentication Endpoints
Login Flow
The login endpoint validates user credentials and returns the user object on success:Registration Flow
The registration endpoint creates new user accounts with duplicate email detection:Despite the field name being
password_hash, the client should send the plaintext password. The service layer is responsible for hashing it using BCrypt before storage.Password Security
DriveX uses BCrypt for password hashing, configured through Spring Security:BCrypt Features
Adaptive Hashing
Adaptive Hashing
BCrypt’s computational cost can be increased over time as hardware improves, making it resistant to brute-force attacks even as computing power increases.
Built-in Salt
Built-in Salt
Each password hash includes a random salt, ensuring that identical passwords produce different hashes. This protects against rainbow table attacks.
One-Way Function
One-Way Function
BCrypt is designed to be slow and computationally expensive, making it impractical to reverse the hash or perform rapid brute-force attempts.
User Roles
The system supports role-based access control through therole field in the User entity:
- USER - Standard customer with rental capabilities
- ADMIN - Administrative access for system management
Role enforcement must be implemented in the service layer or through Spring Security method-level security annotations.
User Status Management
Users have anis_active flag to control account status:
- Soft deletion of accounts
- Temporary account suspension
- Account activation workflows
Authentication State Management
Security Best Practices
User Entity Fields
Complete list of User entity fields:| Field | Type | Description |
|---|---|---|
id | Long | Primary key, auto-generated |
username | String | Unique username |
email | String | User email (used for login) |
password_hash | String | BCrypt hashed password |
firstname | String | User’s first name |
lastname | String | User’s last name |
phone_number | String | Contact phone number |
role | String | User role (USER, ADMIN) |
is_active | Boolean | Account active status |
created_at | Timestamp | Account creation timestamp |
updated_at | Timestamp | Last update timestamp |
profileImage | String | URL to profile image |