fix(login): add backend password validation to match frontend requirements#3070
Conversation
Fixes AntaresSimulatorTeam#3067 Adds server-side password strength validation in UserCreateDTO to ensure consistent security policy whether users are created via UI or API. Validation rules (matching frontend): - Length: 8-50 characters - At least one lowercase letter (a-z) - At least one uppercase letter (A-Z) - At least one digit (0-9) - At least one special character (!@#$%^&*(),.?":{}|<>) Previously, the frontend enforced these rules but the backend accepted any password, allowing scripts/API calls to create users with weak passwords. This fix ensures the same security standards apply regardless of the creation method.
|
Yes ? |
sylvlecl
left a comment
There was a problem hiding this comment.
Please add some unit test to ensure no regression in the future.
|
|
||
| @field_validator("password") | ||
| @classmethod | ||
| def validate_password_strength(cls, v: str) -> str: |
|
| GitGuardian id | GitGuardian status | Secret | Commit | Filename | |
|---|---|---|---|---|---|
| - | - | Generic Password | 937e29e | tests/integration/studies_blueprint/test_get_studies.py | View secret |
| 31568767 | Triggered | Generic Password | 937e29e | tests/login/test_web.py | View secret |
| - | - | Generic Password | 937e29e | tests/integration/test_integration.py | View secret |
| - | - | Generic Password | 937e29e | tests/integration/studies_blueprint/test_get_studies.py | View secret |
| - | - | Generic Password | 937e29e | tests/login/test_login_service.py | View secret |
| 14433192 | Triggered | Authentication Tuple | c6ba36c | antarest/dependencies.py | View secret |
| 31568767 | Triggered | Generic Password | f93cde9 | tests/login/test_model.py | View secret |
| 31568768 | Triggered | Generic Password | f93cde9 | tests/login/test_model.py | View secret |
🛠 Guidelines to remediate hardcoded secrets
- Understand the implications of revoking this secret by investigating where it is used in your code.
- Replace and store your secrets safely. Learn here the best practices.
- Revoke and rotate these secrets.
- If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.
To avoid such incidents in the future consider
- following these best practices for managing and storing secrets including API keys and other credentials
- install secret detection on pre-commit to catch secret before it leaves your machine and ease remediation.
🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.
Fixes #3067