andrii-kryvoviaz / slink

Self-hosted image sharing service.
GNU Affero General Public License v3.0
313 stars 9 forks source link

[Feature Request] Password validation rules configuration #17

Closed maksii closed 7 months ago

maksii commented 7 months ago

Currently, the password-setting rules need to be more straightforward and more friendly. There is no indication besides a short error. Moreover, the rule is based on the number of characters rather than their quality.

Example password: 1qaz@Wsx#Edc - number, low-uppercase, specials - NOT VALID, less than 16chars 1qaz2wsx3edc4rfv - number, lowercase only - VALID, 16chars

Suggested changes: Add a docker environment variable that can overwrite the character count requirement, eg, set it to x chars (or, allow the user to change it from the profile page with lower standards). Add a validation error message that will specify what exactly is wrong with the password. Adjust rules to something like:

andrii-kryvoviaz commented 7 months ago

Certaenly, that's what I was going to change anyway.

As of now it uses this Symfony PasswordStrenght constraint, which is not that straightforward on how to configure the complexity:

#[Assert\PasswordStrength(minScore: Assert\PasswordStrength::STRENGTH_MEDIUM)]
private string $password

More information here: https://symfony.com/doc/current/reference/constraints/PasswordStrength.html

I will just introduce a custom constraint, since the Symfony option is too general and oversimplified in terms of configuration.

andrii-kryvoviaz commented 7 months ago

Two ENV variables, USER_PASSWORD_MIN_LENGTH and USER_PASSWORD_REQUIREMENTS, have been introduced (47afe3d). These changes are included in the new release.

Password requirements are represented as a bitmask. I thought it would be ideal to consolidate all the flags under one parameter. Once Slink has an admin panel, it will be easier to adjust these settings.

Here are some options for the bitmask:

Default values are: USER_PASSWORD_MIN_LENGTH = 6 USER_PASSWORD_REQUIREMENTS = 15