Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ui): enhanced email and password length constraint in basic authentication #4261

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions ui/src/components/admin/stats/BasicAuthPrompt.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<el-form-item
:label="$t('password')"
required
prop="password"
>
<el-input v-model="form.password" type="password" show-password />
</el-form-item>
Expand Down Expand Up @@ -62,6 +63,28 @@
trigger: ["blur"],
pattern: "^$|^[a-zA-Z0-9_!#$%&’*+/=?`{|}~^.-]+@[a-zA-Z0-9.-]+$"
},
{
validator: (rule, value, callback) => {
if (value && value.length > 256) {
callback(new Error(this.$t("email length constraint")));
} else {
callback();
}
},
trigger: ["blur", "change"]
}
],
password: [
{
validator: (rule, value, callback) => {
if (value && value.length > 256) {
callback(new Error(this.$t("password length constraint")));
} else {
callback();
}
},
trigger: ["blur", "change"]
}
],
confirmPassword: [
{
Expand Down
2 changes: 2 additions & 0 deletions ui/src/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,8 @@
"email": "Email",
"password": "Password",
"confirm password": "Confirm password",
"email length constraint": "Email must not exceed 256 characters",
"password length constraint": "Password must not exceed 256 characters",
"passwords do not match": "Passwords do not match",
"avg duration": "Avg. execution duration",
"neutral trend": "Stable",
Expand Down
2 changes: 2 additions & 0 deletions ui/src/translations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,8 @@
"email": "Email",
"password": "Mot de passe",
"confirm password": "Confirmer le mot de passe",
"email length constraint": "L'e-mail ne doit pas dépasser 256 caractères.",
"password length constraint": "Le mot de passe ne doit pas dépasser 256 caractères.",
"passwords do not match": "Les mots de passe ne correspondent pas",
"avg duration": "Durée moyenne d'exécution",
"neutral trend": "Stable",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
public class BasicAuthService {
public static final String BASIC_AUTH_SETTINGS_KEY = "kestra.server.basic-auth";
private static final Pattern EMAIL_PATTERN = Pattern.compile("^[a-zA-Z0-9_!#$%&’*+/=?`{|}~^.-]+@[a-zA-Z0-9.-]+$");
private static final int EMAIL_PASSWORD_MAX_LEN = 256;

@Inject
private SettingRepositoryInterface settingRepository;
Expand Down Expand Up @@ -75,6 +76,12 @@ public void save(String uid, BasicAuthConfiguration basicAuthConfiguration) {
throw new IllegalArgumentException("No password set for Basic Authentication. Please provide a password.");
}

if (basicAuthConfiguration.getUsername().length() > EMAIL_PASSWORD_MAX_LEN ||
basicAuthConfiguration.password.length() > EMAIL_PASSWORD_MAX_LEN) {
throw new IllegalArgumentException("The length of email or password should not exceed 256 characters.");
}


SaltedBasicAuthConfiguration previousConfiguration = this.configuration();
String salt = previousConfiguration == null
? null
Expand Down
Loading