From c3a881c4a6ba3e66ba93a139202dfc05fa47cc79 Mon Sep 17 00:00:00 2001 From: Sietse Snel Date: Wed, 18 Oct 2023 16:38:09 +0200 Subject: [PATCH] YDA-5505: do not accept backslashes in passwords These don't get passed correctly to the external-auth script on the provider, and therefore cause authentication to fail. --- yoda_eus/password_complexity.py | 3 +++ yoda_eus/templates/web/activate.html | 4 ++++ yoda_eus/templates/web/password-requirements.html | 2 +- yoda_eus/templates/web/reset-password.html | 4 ++++ yoda_eus/tests/test_integration.py | 2 +- yoda_eus/tests/test_unit.py | 4 ++++ 6 files changed, 17 insertions(+), 2 deletions(-) diff --git a/yoda_eus/password_complexity.py b/yoda_eus/password_complexity.py index db15905..2ab51b6 100644 --- a/yoda_eus/password_complexity.py +++ b/yoda_eus/password_complexity.py @@ -33,4 +33,7 @@ def check_password_complexity(password: str) -> List[str]: if not (any(c in string.punctuation for c in password)): errors.append("Password needs to contain at least one punctuation character ({})".format(string.punctuation)) + if "\\" in password: + errors.append("Password must not contain backslashes.") + return errors diff --git a/yoda_eus/templates/web/activate.html b/yoda_eus/templates/web/activate.html index d683cb2..feb6db2 100644 --- a/yoda_eus/templates/web/activate.html +++ b/yoda_eus/templates/web/activate.html @@ -111,6 +111,10 @@ passwordErrors.innerHTML = 'The password needs to contain an uppercase letter, lowercase letter, number and punctuation character.'; submitButton.disabled = true; } + else if ( password1Input.value.indexOf('\\') > -1 ) { + passwordErrors.innerHTML = 'The password contains a backslash.'; + submitButton.disabled = true; + } else if ( password2Input.value.trim().length == 0 ) { passwordErrors.innerHTML = 'Please enter the password again.'; submitButton.disabled = true; diff --git a/yoda_eus/templates/web/password-requirements.html b/yoda_eus/templates/web/password-requirements.html index aee37c9..96fdfb6 100644 --- a/yoda_eus/templates/web/password-requirements.html +++ b/yoda_eus/templates/web/password-requirements.html @@ -1,7 +1,7 @@

Your password must meet the following requirements: