Skip to content

fix(password): align validation feedback and show correct policy requirements#4778

Open
rakdutta wants to merge 5 commits into
mainfrom
debug/password-validation-logging
Open

fix(password): align validation feedback and show correct policy requirements#4778
rakdutta wants to merge 5 commits into
mainfrom
debug/password-validation-logging

Conversation

@rakdutta
Copy link
Copy Markdown
Collaborator

@rakdutta rakdutta commented May 15, 2026

Closes #4753

Summary

Centralizes password policy requirements and standardizes validation feedback across user
creation and password change flows. Users now receive consistent, explicit policy guidance
(12 characters minimum, 3-of-4 complexity groups) both during form entry and on validation failure.

Changes

Unified Policy Requirements

  • Introduced get_password_requirements() static method in PasswordPolicyService exposing a complete,
    descriptive set of password rules (minimum length, complexity rules, restrictions) for use by both backend
    and frontend
  • Backend now returns a single password_requirements dictionary instead of individual policy flags,
    ensuring the frontend always receives up-to-date requirements

Enhanced Error Handling

  • Improved password change flows to encode detailed error messages in redirect URLs
  • Added HTML escaping in error responses to prevent injection vulnerabilities
  • Backend validation failures now communicate specific policy violations to the user

Frontend User Experience

  • Refactored admin templates to dynamically render password policy guidance based on backend requirements
  • Implemented real-time client-side validation matching backend rules (3-of-4 complexity, minimum length, etc.)
  • Enhanced error display in user creation workflows to show specific backend validation failures
  • Form submission now only possible when all requirements are met

Configuration & Maintenance

  • Updated .env.example to document password length environment variables for different account types (following OWASP recommendations)
  • Refactored password complexity and restriction checks for clarity and maintainability (common passwords, username inclusion, sequential characters)

rakdutta added 3 commits May 15, 2026 16:25
…plexity) on validation failure

Signed-off-by: Rakhi Dutta <[email protected]>
Signed-off-by: Rakhi Dutta <[email protected]>
@rakdutta rakdutta changed the title Debug/password validation logging fix(password): align validation feedback and show correct policy requirements May 15, 2026
@rakdutta rakdutta marked this pull request as ready for review May 15, 2026 11:39
@rakdutta rakdutta added bug Something isn't working MUST P1: Non-negotiable, critical requirements without which the product is non-functional or unsafe labels May 15, 2026
Signed-off-by: Rakhi Dutta <[email protected]>
The doctest in validate_password_detailed() was not executable due to
SessionLocal initialization requirements. Unit tests provide comprehensive
coverage of this method's behavior. Coverage for password_policy_service.py
now at 97% (well above 93% threshold).

Co-Authored-By: Claude Haiku 4.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working MUST P1: Non-negotiable, critical requirements without which the product is non-functional or unsafe

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: Password Requirements UI Not Displaying All Validation Rules

1 participant