Skip to content

Commit

Permalink
Merge pull request #6369 from hwupathum/recaptcha
Browse files Browse the repository at this point in the history
Add username recovery for reCaptcha toggle
  • Loading branch information
hwupathum authored Jun 13, 2024
2 parents 44d125b + 31d2e89 commit bad6a5c
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 9 deletions.
7 changes: 7 additions & 0 deletions .changeset/hip-hairs-fry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@wso2is/admin.server-configurations.v1": patch
"@wso2is/admin.extensions.v1": patch
"@wso2is/console": patch
---

Add username recovery for reCaptcha toggle
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 @@ -3084,6 +3084,7 @@ export interface Extensions {
subSection1: string;
subSection2: string;
subSection3: string;
subSection4: string;
};
connectorDescription: string;
heading: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3632,7 +3632,8 @@ export const extensions: Extensions = {
heading: "This will enforce reCAPTCHA validation in respective UIs of the following flows.",
subSection1: "Login to business applications",
subSection2: "Recover the password of a user account",
subSection3: "Self registration for user accounts"
subSection3: "Self registration for user accounts",
subSection4: "Recover the username of a user account"
},
connectorDescription: "Enable reCAPTCHA for the organization.",
heading: "Bot Detection",
Expand Down
21 changes: 14 additions & 7 deletions features/admin.extensions.v1/configs/server-configuration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,20 @@ export const serverConfigurationConfig: ServerConfigurationConfig = {
ServerConfigurationsConstants.ANALYTICS_ENGINE_CONNECTOR_ID
],
connectorToggleName: {
"account-recovery": ServerConfigurationsConstants.PASSWORD_RECOVERY_NOTIFICATION_BASED_ENABLE,
"account-recovery-username": ServerConfigurationsConstants.USERNAME_RECOVERY_ENABLE,
"account.lock.handler": ServerConfigurationsConstants.ACCOUNT_LOCK_ENABLE,
"multiattribute.login.handler": ServerConfigurationsConstants.MULTI_ATTRIBUTE_LOGIN_ENABLE,
"organization-self-service": ServerConfigurationsConstants.ORGANIZATION_SELF_SERVICE_ENABLE,
"self-sign-up": ServerConfigurationsConstants.SELF_REGISTRATION_ENABLE,
"sso.login.recaptcha": ServerConfigurationsConstants.RE_CAPTCHA_ALWAYS_ENABLE
[ServerConfigurationsConstants.ACCOUNT_RECOVERY]:
ServerConfigurationsConstants.PASSWORD_RECOVERY_NOTIFICATION_BASED_ENABLE,
[ServerConfigurationsConstants.ACCOUNT_RECOVERY_BY_USERNAME]:
ServerConfigurationsConstants.USERNAME_RECOVERY_ENABLE,
[ServerConfigurationsConstants.ACCOUNT_LOCK_HANDLER]:
ServerConfigurationsConstants.ACCOUNT_LOCK_ENABLE,
[ServerConfigurationsConstants.MULTI_ATTRIBUTE_LOGIN_HANDLER]:
ServerConfigurationsConstants.MULTI_ATTRIBUTE_LOGIN_ENABLE,
[ServerConfigurationsConstants.ORGANIZATION_SELF_SERVICE]:
ServerConfigurationsConstants.ORGANIZATION_SELF_SERVICE_ENABLE,
[ServerConfigurationsConstants.SELF_SIGNUP]:
ServerConfigurationsConstants.SELF_REGISTRATION_ENABLE,
[ServerConfigurationsConstants.SSO_LOGIN_RECAPTCHA]:
ServerConfigurationsConstants.RE_CAPTCHA_AFTER_MAX_FAILED_ATTEMPTS_ENABLE
},
connectorsToHide: [
ServerConfigurationsConstants.ALTERNATIVE_LOGIN_IDENTIFIER,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,17 @@ export class ServerConfigurationsConstants {
public static readonly PASSWORD_RECOVERY_QUESTION_FORCED_ENABLE: string =
"Recovery.Question.Password.Forced.Enable";

/**
* Connector toggle constants.
*/
public static readonly ACCOUNT_RECOVERY: string = "account-recovery";
public static readonly ACCOUNT_RECOVERY_BY_USERNAME: string = "account-recovery-username";
public static readonly ACCOUNT_LOCK_HANDLER: string = "account.lock.handler";
public static readonly MULTI_ATTRIBUTE_LOGIN_HANDLER: string = "multiattribute.login.handler";
public static readonly ORGANIZATION_SELF_SERVICE: string = "organization-self-service";
public static readonly SELF_SIGNUP: string = "self-sign-up";
public static readonly SSO_LOGIN_RECAPTCHA: string = "sso.login.recaptcha";

/**
* Login policies - account locking API Keyword constants.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,8 @@ export const ConnectorEditPage: FunctionComponent<ConnectorEditPageInterface> =
// TODO: remove this once the ID is fixed
updateData.properties.push({
name: GovernanceConnectorUtils.decodeConnectorPropertyName(
serverConfigurationConfig.connectorToggleName["account-recovery-username"]
serverConfigurationConfig.connectorToggleName[
ServerConfigurationsConstants.ACCOUNT_RECOVERY_BY_USERNAME ]
),
value: data.checked.toString()
});
Expand Down Expand Up @@ -250,6 +251,13 @@ export const ConnectorEditPage: FunctionComponent<ConnectorEditPageInterface> =
name: ServerConfigurationsConstants.PASSWORD_RECOVERY_NOTIFICATION_BASED_RE_CAPTCHA,
value: data.checked.toString()
});
if (ServerConfigurationsConstants.ACCOUNT_RECOVERY_BY_USERNAME in
serverConfigurationConfig.connectorToggleName) {
updateRecoveryCaptchaData.properties.push({
name: ServerConfigurationsConstants.USERNAME_RECOVERY_RE_CAPTCHA,
value: data.checked.toString()
});
}

updateGovernanceConnector(updateSSOCaptchaData, categoryId, connectorId)
.then(() => {
Expand Down Expand Up @@ -614,6 +622,16 @@ export const ConnectorEditPage: FunctionComponent<ConnectorEditPageInterface> =
"botDetection.info.subSection2"
) }
</li>
{
serverConfigurationConfig.connectorToggleName[
ServerConfigurationsConstants.ACCOUNT_RECOVERY_BY_USERNAME ] ?
(<li>
{ t(
"extensions:manage.serverConfigurations.accountSecurity." +
"botDetection.info.subSection4"
) }
</li>) : <></>
}
<li>
{ t(
"extensions:manage.serverConfigurations.accountSecurity." +
Expand Down

0 comments on commit bad6a5c

Please sign in to comment.