- Updated the .env.example file to reflect a development environment setup with enhanced secret key requirements and local host settings. - Modified the Docker Compose configuration to enhance security with read-only settings and no-new-privileges options. - Updated requirements.txt to pin package versions for better dependency management. - Enhanced the FastAPI application to include dynamic OpenAPI and documentation URLs based on the environment. - Implemented session versioning in JWT tokens to improve security and user session management. - Added new validation for user roles and password strength in schemas. - Improved email sending logic to handle recipient lists more robustly and added logging for SMTP operations. - Updated dashboard and profile templates to reflect new features and improve user experience.
19 lines
602 B
Python
19 lines
602 B
Python
import re
|
|
|
|
_PASSWORD_RULES: tuple[tuple[re.Pattern[str], str], ...] = (
|
|
(re.compile(r".{10,}"), "Mindestens 10 Zeichen."),
|
|
(re.compile(r"[A-Z]"), "Mindestens ein Großbuchstabe."),
|
|
(re.compile(r"[a-z]"), "Mindestens ein Kleinbuchstabe."),
|
|
(re.compile(r"\d"), "Mindestens eine Ziffer."),
|
|
)
|
|
|
|
|
|
def password_policy_errors(password: str) -> list[str]:
|
|
return [msg for pattern, msg in _PASSWORD_RULES if not pattern.search(password)]
|
|
|
|
|
|
def validate_password_strength(password: str) -> None:
|
|
errors = password_policy_errors(password)
|
|
if errors:
|
|
raise ValueError(errors[0])
|