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

Add new configuration to indefinitely lock the user util admin unlock #6997

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
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
6 changes: 6 additions & 0 deletions .changeset/cuddly-jeans-hope.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@wso2is/admin.server-configurations.v1": patch
"@wso2is/console": patch
---

Support the feature indefinitely lock user until admin unlocks
1 change: 1 addition & 0 deletions apps/console/src/extensions/i18n/models/extensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3145,6 +3145,7 @@ export interface Extensions {
form: {
fields: {
accountLockIncrementFactor: FormAttributes;
enableIndefiniteUserLockduration: FormAttributes;
accountLockTime: FormAttributes;
enable: FormAttributes;
maxFailedAttempts: FormAttributes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3773,6 +3773,12 @@ export const extensions: Extensions = {
"with 1 or 2 digits."
}
},
enableIndefiniteUserLockduration: {
hint:
"The account will be locked indefinitely after max failed attempts until the account " +
"is manually unlocked by an admin",
label: "Enable indefinite user lock duration"
},
accountLockTime: {
hint:
"This specifies the initial duration that the account will be locked for. " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ export const LoginAttemptSecurityConfigurationFrom: FunctionComponent<
const [ lockDuration, setLockDuration ] = useState<string>(undefined);
const [ lockIncrementRatio, setLockIncrementRatio ] = useState<string>(undefined);
const [ notifyUserOnAccountLockIncrement, setNotifyUserOnAccountLockIncrement ] = useState<boolean>(undefined);
const [ enableIndefiniteUserLockduration, setEnableIndefiniteUserLockduration ] = useState<boolean>(undefined);
const [ accordionActiveIndex, setAccordionActiveIndex ] = useState<string | number>(undefined);

/**
Expand Down Expand Up @@ -173,6 +174,7 @@ export const LoginAttemptSecurityConfigurationFrom: FunctionComponent<
accountLockTime: property.value
};
setLockDuration(property.value);
setEnableIndefiniteUserLockduration(parseInt(property.value) === 0);
} else if (property.name === ServerConfigurationsConstants.ACCOUNT_LOCK_TIME_INCREMENT_FACTOR) {
resolvedInitialValues = {
...resolvedInitialValues,
Expand Down Expand Up @@ -269,8 +271,9 @@ export const LoginAttemptSecurityConfigurationFrom: FunctionComponent<
// Check for invalid input.
errors.accountLockTime = t("extensions:manage.serverConfigurations.accountSecurity." +
"loginAttemptSecurity.form.fields.accountLockTime.validations.invalid");
} else if ((parseInt(values.accountLockTime, 10) < GovernanceConnectorConstants
.LOGINS_ATTEMPT_SECURITY_FORM_FIELD_CONSTRAINTS.ACCOUNT_LOCK_TIME_MIN_VALUE)
} else if (((parseInt(values.accountLockTime, 10) < GovernanceConnectorConstants
.LOGINS_ATTEMPT_SECURITY_FORM_FIELD_CONSTRAINTS.ACCOUNT_LOCK_TIME_MIN_VALUE) &&
!enableIndefiniteUserLockduration)
|| (parseInt(values.accountLockTime, 10) > GovernanceConnectorConstants
.LOGINS_ATTEMPT_SECURITY_FORM_FIELD_CONSTRAINTS.ACCOUNT_LOCK_TIME_MAX_VALUE)) {
// Check for invalid range.
Expand Down Expand Up @@ -325,6 +328,11 @@ export const LoginAttemptSecurityConfigurationFrom: FunctionComponent<
setAccordionActiveIndex(newIndex);
};

const updateEnableIndefiniteAccountLockDuration = (value: any) => {
setEnableIndefiniteUserLockduration(value);
setLockDuration("0");
};

/**
* Renders sample info section with example configuration details.
*
Expand Down Expand Up @@ -472,6 +480,25 @@ export const LoginAttemptSecurityConfigurationFrom: FunctionComponent<
"loginAttemptSecurity.form.fields.maxFailedAttempts.hint")
}
</Hint>
<Field.Checkbox
ariaLabel="enableIndefiniteUserLockduration"
name="enableIndefiniteUserLockduration"
label={ t("extensions:manage.serverConfigurations.accountSecurity." +
"loginAttemptSecurity.form.fields.enableIndefiniteUserLockduration.label") }
listen={ (value: boolean) => updateEnableIndefiniteAccountLockDuration(value) }
checked={ enableIndefiniteUserLockduration }
required={ false }
readOnly={ readOnly }
disabled={ !isConnectorEnabled }
width={ 10 }
data-testid={ `${testId}-enable-indefinite-user-lock-duration` }
/>
<Hint className={ "mb-5" }>
{
t("extensions:manage.serverConfigurations.accountSecurity." +
"loginAttemptSecurity.form.fields.enableIndefiniteUserLockduration.hint")
}
</Hint>
<Field.Input
ariaLabel="accountLockTime"
inputType="number"
Expand Down Expand Up @@ -501,7 +528,7 @@ export const LoginAttemptSecurityConfigurationFrom: FunctionComponent<
.LOGINS_ATTEMPT_SECURITY_FORM_FIELD_CONSTRAINTS.ACCOUNT_LOCK_TIME_MIN_LENGTH
}
width={ 10 }
disabled={ !isConnectorEnabled }
disabled={ !isConnectorEnabled || enableIndefiniteUserLockduration }
labelPosition="right"
data-testid={ `${testId}-account-lock-time` }
readOnly={ readOnly }
Expand Down Expand Up @@ -546,7 +573,7 @@ export const LoginAttemptSecurityConfigurationFrom: FunctionComponent<
.ACCOUNT_LOCK_INCREMENT_FACTOR_MIN_LENGTH
}
width={ 10 }
disabled={ !isConnectorEnabled }
disabled={ !isConnectorEnabled || enableIndefiniteUserLockduration }
data-testid={ `${testId}-account-lock-increment` }
readOnly={ readOnly }
/>
Expand Down
Loading