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

Update the password length validation with Password max allowed length config. #7185

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
10 changes: 10 additions & 0 deletions .changeset/spicy-bottles-obey.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
"@wso2is/admin.validation.v1": minor
"@wso2is/admin.core.v1": minor
"@wso2is/myaccount": minor
"@wso2is/console": minor
"@wso2is/core": minor
"@wso2is/i18n": minor
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the changes to core and i18n are minor, let's add a separate changeset for those modules with patch version upgrade.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed by 3f33e36

---

Add the passwordMaxAllowed length config for password length values validation.
Original file line number Diff line number Diff line change
Expand Up @@ -1844,6 +1844,17 @@
{% else %}
"isPasswordInputValidationEnabled": true,
{% endif %}
"passwordPolicyConfigs": {
{% if identity_mgt.password_policy.items() is defined %}
{% for key, value in identity_mgt.password_policy.items() %}
{% if value is string %}
"{{ key }}": "{{ value }}"{{ "," if not loop.last }}
{% else %}
"{{ key }}": {{ value }}{{ "," if not loop.last }}
{% endif %}
{% endfor %}
{% endif %}
},
"isSignatureValidationCertificateAliasEnabled": {{ console.applications.ui.certificate_alias_enabled }},
"listAllAttributeDialects": {{ console.list_all_attribute_dialects }},
{% if console.enable_identity_claims is defined %}
Expand Down
3 changes: 3 additions & 0 deletions apps/console/src/public/deployment.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -1260,6 +1260,9 @@
"roleMapping": false
},
"listAllAttributeDialects": true,
"passwordPolicyConfigs": {
"maxPasswordAllowedLength": 64
},
"privacyPolicyConfigs": {},
"productName": "WSO2 Identity Server",
"productVersionConfig": {
Expand Down
3 changes: 2 additions & 1 deletion apps/myaccount/src/configs/app.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2022, WSO2 LLC. (https://www.wso2.com).
* Copyright (c) 2022-2024, WSO2 LLC. (https://www.wso2.com).
*
* WSO2 LLC. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
Expand Down Expand Up @@ -163,6 +163,7 @@ export class Config {
window["AppUtils"]?.getConfig()?.ui?.isMultipleEmailsAndMobileNumbersEnabled,
isPasswordInputValidationEnabled: window["AppUtils"]?.getConfig()?.ui?.isPasswordInputValidationEnabled,
isProfileUsernameReadonly: window["AppUtils"]?.getConfig()?.ui?.isProfileUsernameReadonly,
passwordPolicyConfigs: window[ "AppUtils" ]?.getConfig()?.ui?.passwordPolicyConfigs,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't use this value anywhere in myaccount, do we? if it's not used, better not to add it here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed by 74c5553

privacyPolicyConfigs: window["AppUtils"]?.getConfig()?.ui?.privacyPolicyConfigs,
productName: window["AppUtils"]?.getConfig()?.ui?.productName,
productVersionConfig: window["AppUtils"]?.getConfig()?.ui?.productVersionConfig,
Expand Down
1 change: 1 addition & 0 deletions features/admin.core.v1/configs/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ export class Config {
isXacmlConnectorEnabled: window[ "AppUtils" ]?.getConfig()?.ui?.isXacmlConnectorEnabled,
legacyMode: window[ "AppUtils" ]?.getConfig()?.ui?.legacyMode,
listAllAttributeDialects: window[ "AppUtils" ]?.getConfig()?.ui?.listAllAttributeDialects,
passwordPolicyConfigs: window[ "AppUtils" ]?.getConfig()?.ui?.passwordPolicyConfigs,
privacyPolicyConfigs: window[ "AppUtils" ]?.getConfig()?.ui?.privacyPolicyConfigs,
productName: window[ "AppUtils" ]?.getConfig()?.ui?.productName,
productVersionConfig: window[ "AppUtils" ]?.getConfig()?.ui?.productVersionConfig,
Expand Down
1 change: 1 addition & 0 deletions features/admin.core.v1/store/reducers/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ export const commonConfigReducerInitialState: CommonConfigReducerStateInterface<
isSignatureValidationCertificateAliasEnabled: undefined,
isTrustedAppConsentRequired: undefined,
listAllAttributeDialects: undefined,
passwordPolicyConfigs: null,
privacyPolicyConfigs: null,
productName: "",
productVersionConfig: null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,12 @@ export class ValidationConfigConstants {
public static readonly VALIDATION_CONFIGURATION_FORM_FIELD_CONSTRAINTS: {
MIN_LENGTH: number,
MIN_VALUE: number;
PASSWORD_MAX_LENGTH: number;
PASSWORD_MAX_VALUE: number;
PASSWORD_MIN_LENGTH: number;
PASSWORD_MIN_VALUE: number;
} = {

MIN_LENGTH: 1,
MIN_VALUE: 0,
PASSWORD_MAX_LENGTH: 2,
PASSWORD_MAX_VALUE: 30,
PASSWORD_MIN_LENGTH: 1,
PASSWORD_MIN_VALUE: 5
};
Expand Down
136 changes: 33 additions & 103 deletions features/admin.validation.v1/pages/validation-config-edit.tsx

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions modules/core/src/models/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,10 @@ export interface CommonUIConfigInterface<T = Record<string, unknown>> {
* Flag to check whether the password validation is performed using input validation listener.
*/
isPasswordInputValidationEnabled: boolean;
/**
* Password policy configs.
*/
passwordPolicyConfigs: PasswordPolicyConfigsInterface;
/**
* Privacy Policy configs.
*/
Expand All @@ -235,6 +239,16 @@ export interface CommonUIConfigInterface<T = Record<string, unknown>> {
theme: AppThemeConfigInterface;
}

/**
* Password policy configs interface.
*/
export interface PasswordPolicyConfigsInterface {
/**
* Maximum password length.
*/
maxPasswordAllowedLength: number;
}

/**
* Privacy Policy configs interface.
*/
Expand Down
2 changes: 1 addition & 1 deletion modules/i18n/src/translations/en-US/portals/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export const validation: validationNS = {
consecutiveChrMismatch: "Number of consecutive characters should be less than tha minimum " +
"length of the password.",
invalidConfig: "Unable to create password with the above configurations.",
maxLimitError: "The maximum length cannot be more than 30.",
maxLimitError: "The maximum length cannot be more than {{maxPasswordValue}}.",
minLimitError: "The minimum length cannot be less than 8.",
minMaxMismatch: "Minimum length should be less than maximum length.",
uniqueChrMismatch: "Number of unique characters should be less than tha minimum length of " +
Expand Down
Loading