Change UI admin password check to a regex

This commit is contained in:
Théophile Diot 2023-05-04 19:44:29 -04:00
parent 51514df570
commit 573fe8fee2
No known key found for this signature in database
GPG Key ID: E752C80DB72BB014
1 changed files with 7 additions and 2 deletions

View File

@ -135,8 +135,13 @@ elif "ADMIN_PASSWORD" not in vars:
logger.error("ADMIN_PASSWORD is not set")
stop(1)
if not vars.get("FLASK_DEBUG", False) and vars["ADMIN_PASSWORD"] == "changeme":
logger.error("Please change the default admin password.")
if not vars.get("FLASK_DEBUG", False) and not re_match(
r"^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[#@?!$%^&*-]).{8,}$",
vars["ADMIN_PASSWORD"],
):
logger.error(
"The admin password is not strong enough. It must contain at least 8 characters, including at least 1 uppercase letter, 1 lowercase letter, 1 number and 1 special character (#@?!$%^&*-)."
)
stop(1)
if not vars["ABSOLUTE_URI"].endswith("/"):