fix: Strict password validation in login form
Strict password validation is for registration, change password, reset password and similar forms. In login form, we don't want to interrupt user with unnecessary validation as it's completely irrelevant what they actually entered. The one thing it's about is the correctness of the email and the password. Disabling strict validation for password is a kind of security through obscurity, which could filter some untargeted attempts for trying passwords by bots. If the bot immediatelly receives notes about the requirements, it has more imformation for better attacks.
This commit is contained in:
10 files changed
+49
-35
No files matched your search
@@ -27,7 +27,7 @@ const lastnameSchema = joi
|
||||
"Surname must contain only letters, spaces, apostrophes, or hyphens",
|
||||
});
|
||||
|
||||
const passwordSchema = joi
|
||||
const newPasswordSchema = joi
|
||||
.string()
|
||||
.trim()
|
||||
.min(8)
|
||||
@@ -64,7 +64,7 @@ const passwordSchema = joi
|
||||
special: "Password must contain at least one special character",
|
||||
});
|
||||
|
||||
const credentials = joi.object({
|
||||
const newOrChangedCredentials = joi.object({
|
||||
firstName: nameSchema,
|
||||
lastName: lastnameSchema,
|
||||
email: joi
|
||||
@@ -76,8 +76,8 @@ const credentials = joi.object({
|
||||
"string.empty": "authRegisterEmailRequired",
|
||||
"string.email": "authRegisterEmailInvalid",
|
||||
}),
|
||||
password: passwordSchema,
|
||||
newPassword: passwordSchema,
|
||||
password: newPasswordSchema,
|
||||
newPassword: newPasswordSchema,
|
||||
confirm: joi
|
||||
.string()
|
||||
.trim()
|
||||
@@ -97,6 +97,23 @@ const credentials = joi.object({
|
||||
inviteToken: joi.string().allow(""),
|
||||
});
|
||||
|
||||
const loginCredentials = joi.object({
|
||||
email: joi
|
||||
.string()
|
||||
.trim()
|
||||
.email({ tlds: { allow: false } })
|
||||
.lowercase()
|
||||
.messages({
|
||||
"string.empty": "authRegisterEmailRequired",
|
||||
"string.email": "authRegisterEmailInvalid",
|
||||
}),
|
||||
password: joi
|
||||
.string()
|
||||
.messages({
|
||||
"string.empty": "Please enter your password",
|
||||
}),
|
||||
});
|
||||
|
||||
const monitorValidation = joi.object({
|
||||
url: joi.when("type", {
|
||||
is: "docker",
|
||||
@@ -391,7 +408,8 @@ const infrastructureMonitorValidation = joi.object({
|
||||
});
|
||||
|
||||
export {
|
||||
credentials,
|
||||
newOrChangedCredentials,
|
||||
loginCredentials,
|
||||
imageValidation,
|
||||
monitorValidation,
|
||||
settingsValidation,
|
||||
|
||||
Reference in new issue
Block a user