Skip to content

fix: add backend password validation to match frontend requirements#3070

Open
aicontentcreate2023-star wants to merge 1 commit intoAntaresSimulatorTeam:devfrom
aicontentcreate2023-star:fix/password-validation-backend
Open

fix: add backend password validation to match frontend requirements#3070
aicontentcreate2023-star wants to merge 1 commit intoAntaresSimulatorTeam:devfrom
aicontentcreate2023-star:fix/password-validation-backend

Conversation

@aicontentcreate2023-star

Fixes #3067

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.
@sylvlecl
Copy link
Member

sylvlecl commented Mar 3, 2026

Yes ?

@TheoPascoli TheoPascoli changed the base branch from master to dev March 4, 2026 08:06
Copy link
Member

@sylvlecl sylvlecl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add some unit test to ensure no regression in the future.


@field_validator("password")
@classmethod
def validate_password_strength(cls, v: str) -> str:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would need some unit tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Inconsistent password validation between frontend and backend user creation

2 participants