Repository navigation
Security
flo351 edited this page Dec 23, 2024
·
1 revision
-
Django's Default Hashing:
Passwords are hashed using PBKDF2 by default, as per Django's configuration. This ensures strong security for storing user credentials.- Salting: Django automatically salts passwords.
-
Customization: If needed, we can switch to other strong algorithms like
bcryptorargon2
- The following validators are enforced for secure password management:
- Minimum Length Validator: Ensures passwords meet a minimum length for strength.
- Common Password Validator: Prevents commonly used passwords.
- Numeric Password Validator: Avoids passwords that are entirely numeric.
-
Implementation:
The project uses Simple JWT for token-based authentication.- Access Token Lifetime: 30 minutes.
- Refresh Token Lifetime: 1 day.
-
Header Type:
Bearer. -
User Claim: The
user_idfield is included in JWT claims for identification.
-
Endpoints:
Protected endpoints require theAuthorization: Bearer <token>header to access.
- Define roles and permissions for different user types (e.g. administrators, warehouse staff, QA personnel).
- Restrict access to APIs and UI elements based on user roles.
- Validate roles on both the backend and frontend.
- Input data is validated using Django REST Framework's serializers to ensure proper formatting and prevent injection attacks.
- Add rate limiting on sensitive endpoints in future iterations to prevent brute force attacks.
- Django’s built-in CSRF middleware is enabled for non-API endpoints to secure against cross-site request forgery.
- All client-server communication will use HTTPS with TLS to encrypt data in transit. This will be enabled when moving to production.
- Secrets like
SECRET_KEY, database credentials, and JWT signing keys are securely stored in a.envfile.- The
.envfile is excluded from version control using.gitignore.
- The
- Use Django's logging framework to log security events, such as failed login attempts or invalid token usage.
- Integrate monitoring tools (e.g., Sentry) to track and respond to suspicious activities.
-
Branch Protection: Protect the
mainbranch to prevent unauthorized changes.