From 93ddfac1b888e58dd62601966c5ec30617d460cd Mon Sep 17 00:00:00 2001 From: Udara Pathum <46132469+hwupathum@users.noreply.github.com> Date: Wed, 29 May 2024 16:05:46 +0530 Subject: [PATCH 1/9] Add reCaptcha toggle for username recovery --- .../src/extensions/i18n/models/extensions.ts | 1 + .../extensions/i18n/resources/en-US/extensions.ts | 3 ++- .../pages/connector-edit-page.tsx | 14 ++++++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/apps/console/src/extensions/i18n/models/extensions.ts b/apps/console/src/extensions/i18n/models/extensions.ts index c4fb96e17df..8c18c547f1f 100755 --- a/apps/console/src/extensions/i18n/models/extensions.ts +++ b/apps/console/src/extensions/i18n/models/extensions.ts @@ -3083,6 +3083,7 @@ export interface Extensions { subSection1: string; subSection2: string; subSection3: string; + subSection4: string; }; connectorDescription: string; heading: string; diff --git a/apps/console/src/extensions/i18n/resources/en-US/extensions.ts b/apps/console/src/extensions/i18n/resources/en-US/extensions.ts index d94af32f155..ead908c036f 100755 --- a/apps/console/src/extensions/i18n/resources/en-US/extensions.ts +++ b/apps/console/src/extensions/i18n/resources/en-US/extensions.ts @@ -3631,7 +3631,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", diff --git a/features/admin.server-configurations.v1/pages/connector-edit-page.tsx b/features/admin.server-configurations.v1/pages/connector-edit-page.tsx index e5e9fd443fb..ff20a8eea82 100644 --- a/features/admin.server-configurations.v1/pages/connector-edit-page.tsx +++ b/features/admin.server-configurations.v1/pages/connector-edit-page.tsx @@ -250,6 +250,12 @@ export const ConnectorEditPage: FunctionComponent = name: ServerConfigurationsConstants.PASSWORD_RECOVERY_NOTIFICATION_BASED_RE_CAPTCHA, value: data.checked.toString() }); + if ("account-recovery-username" in serverConfigurationConfig.connectorToggleName) { + updateRecoveryCaptchaData.properties.push({ + name: ServerConfigurationsConstants.USERNAME_RECOVERY_RE_CAPTCHA, + value: data.checked.toString() + }); + } updateGovernanceConnector(updateSSOCaptchaData, categoryId, connectorId) .then(() => { @@ -614,6 +620,14 @@ export const ConnectorEditPage: FunctionComponent = "botDetection.info.subSection2" ) } + { serverConfigurationConfig.connectorToggleName["account-recovery-username"] ?? +
  • + { t( + "extensions:manage.serverConfigurations.accountSecurity." + + "botDetection.info.subSection4" + ) } +
  • + }
  • { t( "extensions:manage.serverConfigurations.accountSecurity." + From 680e99bb8e9e47ee1158e218f9ca4fa7db41d5b2 Mon Sep 17 00:00:00 2001 From: Udara Pathum <46132469+hwupathum@users.noreply.github.com> Date: Wed, 29 May 2024 16:18:49 +0530 Subject: [PATCH 2/9] =?UTF-8?q?Add=20changeset=20=F0=9F=A6=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .changeset/quiet-maps-travel.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .changeset/quiet-maps-travel.md diff --git a/.changeset/quiet-maps-travel.md b/.changeset/quiet-maps-travel.md new file mode 100644 index 00000000000..908228426d5 --- /dev/null +++ b/.changeset/quiet-maps-travel.md @@ -0,0 +1,6 @@ +--- +"@wso2is/admin.server-configurations.v1": patch +"@wso2is/console": patch +--- + +Add username recovery for reCaptcha toggle From 2cedecf47067b318dd38a7f3dac83404e5046d06 Mon Sep 17 00:00:00 2001 From: Udara Pathum <46132469+hwupathum@users.noreply.github.com> Date: Wed, 29 May 2024 16:19:15 +0530 Subject: [PATCH 3/9] Fix lint issues --- .../console/src/extensions/i18n/resources/en-US/extensions.ts | 2 +- .../pages/connector-edit-page.tsx | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/console/src/extensions/i18n/resources/en-US/extensions.ts b/apps/console/src/extensions/i18n/resources/en-US/extensions.ts index ead908c036f..80aaef10703 100755 --- a/apps/console/src/extensions/i18n/resources/en-US/extensions.ts +++ b/apps/console/src/extensions/i18n/resources/en-US/extensions.ts @@ -3631,7 +3631,7 @@ 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.", diff --git a/features/admin.server-configurations.v1/pages/connector-edit-page.tsx b/features/admin.server-configurations.v1/pages/connector-edit-page.tsx index ff20a8eea82..7b0233a0e34 100644 --- a/features/admin.server-configurations.v1/pages/connector-edit-page.tsx +++ b/features/admin.server-configurations.v1/pages/connector-edit-page.tsx @@ -620,14 +620,14 @@ export const ConnectorEditPage: FunctionComponent = "botDetection.info.subSection2" ) }
  • - { serverConfigurationConfig.connectorToggleName["account-recovery-username"] ?? + {(serverConfigurationConfig.connectorToggleName["account-recovery-username"] ??
  • { t( "extensions:manage.serverConfigurations.accountSecurity." + "botDetection.info.subSection4" ) }
  • - } + )}
  • { t( "extensions:manage.serverConfigurations.accountSecurity." + From 1b38a7c81ae4abae165d055d9b9d831cb7f38625 Mon Sep 17 00:00:00 2001 From: Udara Pathum <46132469+hwupathum@users.noreply.github.com> Date: Wed, 29 May 2024 16:31:42 +0530 Subject: [PATCH 4/9] Fix eslint issues --- .../pages/connector-edit-page.tsx | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/features/admin.server-configurations.v1/pages/connector-edit-page.tsx b/features/admin.server-configurations.v1/pages/connector-edit-page.tsx index 7b0233a0e34..5e52f3bf7a0 100644 --- a/features/admin.server-configurations.v1/pages/connector-edit-page.tsx +++ b/features/admin.server-configurations.v1/pages/connector-edit-page.tsx @@ -620,14 +620,17 @@ export const ConnectorEditPage: FunctionComponent = "botDetection.info.subSection2" ) }
  • - {(serverConfigurationConfig.connectorToggleName["account-recovery-username"] ?? -
  • - { t( - "extensions:manage.serverConfigurations.accountSecurity." + - "botDetection.info.subSection4" - ) } -
  • - )} + { + serverConfigurationConfig.connectorToggleName["account-recovery-username"] ?? + ( +
  • + { t( + "extensions:manage.serverConfigurations.accountSecurity." + + "botDetection.info.subSection4" + ) } +
  • + ) + }
  • { t( "extensions:manage.serverConfigurations.accountSecurity." + From 7eb694a72c2216d217eaecf997ef8261a9ebda23 Mon Sep 17 00:00:00 2001 From: Udara Pathum <46132469+hwupathum@users.noreply.github.com> Date: Wed, 29 May 2024 16:46:02 +0530 Subject: [PATCH 5/9] Fix UI issue --- .../pages/connector-edit-page.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/features/admin.server-configurations.v1/pages/connector-edit-page.tsx b/features/admin.server-configurations.v1/pages/connector-edit-page.tsx index 5e52f3bf7a0..29f25172cde 100644 --- a/features/admin.server-configurations.v1/pages/connector-edit-page.tsx +++ b/features/admin.server-configurations.v1/pages/connector-edit-page.tsx @@ -621,7 +621,7 @@ export const ConnectorEditPage: FunctionComponent = ) }
  • { - serverConfigurationConfig.connectorToggleName["account-recovery-username"] ?? + serverConfigurationConfig.connectorToggleName["account-recovery-username"] ? (
  • { t( @@ -629,7 +629,7 @@ export const ConnectorEditPage: FunctionComponent = "botDetection.info.subSection4" ) }
  • - ) + ) : <> }
  • { t( From 520adfd6aa66947d91761d203df3f6e48f681f04 Mon Sep 17 00:00:00 2001 From: Udara Pathum <46132469+hwupathum@users.noreply.github.com> Date: Wed, 29 May 2024 16:55:50 +0530 Subject: [PATCH 6/9] Fix Eslint --- .../pages/connector-edit-page.tsx | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/features/admin.server-configurations.v1/pages/connector-edit-page.tsx b/features/admin.server-configurations.v1/pages/connector-edit-page.tsx index 29f25172cde..80dc69f2506 100644 --- a/features/admin.server-configurations.v1/pages/connector-edit-page.tsx +++ b/features/admin.server-configurations.v1/pages/connector-edit-page.tsx @@ -622,14 +622,12 @@ export const ConnectorEditPage: FunctionComponent =
  • { serverConfigurationConfig.connectorToggleName["account-recovery-username"] ? - ( -
  • + (
  • { t( "extensions:manage.serverConfigurations.accountSecurity." + "botDetection.info.subSection4" ) } -
  • - ) : <> + ) : <> }
  • { t( From 6920578f81b9382bd9d2a7ddd187744855605a80 Mon Sep 17 00:00:00 2001 From: Udara Pathum <46132469+hwupathum@users.noreply.github.com> Date: Thu, 30 May 2024 13:22:20 +0530 Subject: [PATCH 7/9] Define a constant for "account-recovery-username" --- .../pages/connector-edit-page.tsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/features/admin.server-configurations.v1/pages/connector-edit-page.tsx b/features/admin.server-configurations.v1/pages/connector-edit-page.tsx index 80dc69f2506..f8c42f51569 100644 --- a/features/admin.server-configurations.v1/pages/connector-edit-page.tsx +++ b/features/admin.server-configurations.v1/pages/connector-edit-page.tsx @@ -77,6 +77,7 @@ export const ConnectorEditPage: FunctionComponent = const { t } = useTranslation(); const { getLink } = useDocumentation(); + const ACCOUNT_RECOVERY_BY_USERNAME: string = "account-recovery-username"; const featureConfig: FeatureConfigInterface = useSelector((state: AppState) => state.config.ui.features); const allowedScopes: string = useSelector((state: AppState) => state?.auth?.allowedScopes); @@ -184,7 +185,7 @@ export const ConnectorEditPage: FunctionComponent = // TODO: remove this once the ID is fixed updateData.properties.push({ name: GovernanceConnectorUtils.decodeConnectorPropertyName( - serverConfigurationConfig.connectorToggleName["account-recovery-username"] + serverConfigurationConfig.connectorToggleName[ACCOUNT_RECOVERY_BY_USERNAME] ), value: data.checked.toString() }); @@ -250,7 +251,7 @@ export const ConnectorEditPage: FunctionComponent = name: ServerConfigurationsConstants.PASSWORD_RECOVERY_NOTIFICATION_BASED_RE_CAPTCHA, value: data.checked.toString() }); - if ("account-recovery-username" in serverConfigurationConfig.connectorToggleName) { + if (ACCOUNT_RECOVERY_BY_USERNAME in serverConfigurationConfig.connectorToggleName) { updateRecoveryCaptchaData.properties.push({ name: ServerConfigurationsConstants.USERNAME_RECOVERY_RE_CAPTCHA, value: data.checked.toString() @@ -621,7 +622,7 @@ export const ConnectorEditPage: FunctionComponent = ) }
  • { - serverConfigurationConfig.connectorToggleName["account-recovery-username"] ? + serverConfigurationConfig.connectorToggleName[ACCOUNT_RECOVERY_BY_USERNAME] ? (
  • { t( "extensions:manage.serverConfigurations.accountSecurity." + From d0cfb2d0ee5595a16f6c5f33a8717d2dd17921eb Mon Sep 17 00:00:00 2001 From: Udara Pathum <46132469+hwupathum@users.noreply.github.com> Date: Thu, 30 May 2024 14:40:43 +0530 Subject: [PATCH 8/9] Add constants to ServerConfigurationsConstants --- .../configs/server-configuration.tsx | 21 ++++++++++++------- .../server-configurations-constants.ts | 11 ++++++++++ .../pages/connector-edit-page.tsx | 10 +++++---- 3 files changed, 31 insertions(+), 11 deletions(-) diff --git a/features/admin.extensions.v1/configs/server-configuration.tsx b/features/admin.extensions.v1/configs/server-configuration.tsx index 04f8cd3dd29..1035b6df459 100644 --- a/features/admin.extensions.v1/configs/server-configuration.tsx +++ b/features/admin.extensions.v1/configs/server-configuration.tsx @@ -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, diff --git a/features/admin.server-configurations.v1/constants/server-configurations-constants.ts b/features/admin.server-configurations.v1/constants/server-configurations-constants.ts index 36aeef4f822..3edcd400332 100644 --- a/features/admin.server-configurations.v1/constants/server-configurations-constants.ts +++ b/features/admin.server-configurations.v1/constants/server-configurations-constants.ts @@ -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. */ diff --git a/features/admin.server-configurations.v1/pages/connector-edit-page.tsx b/features/admin.server-configurations.v1/pages/connector-edit-page.tsx index f8c42f51569..2cfc320e346 100644 --- a/features/admin.server-configurations.v1/pages/connector-edit-page.tsx +++ b/features/admin.server-configurations.v1/pages/connector-edit-page.tsx @@ -77,7 +77,6 @@ export const ConnectorEditPage: FunctionComponent = const { t } = useTranslation(); const { getLink } = useDocumentation(); - const ACCOUNT_RECOVERY_BY_USERNAME: string = "account-recovery-username"; const featureConfig: FeatureConfigInterface = useSelector((state: AppState) => state.config.ui.features); const allowedScopes: string = useSelector((state: AppState) => state?.auth?.allowedScopes); @@ -185,7 +184,8 @@ export const ConnectorEditPage: FunctionComponent = // TODO: remove this once the ID is fixed updateData.properties.push({ name: GovernanceConnectorUtils.decodeConnectorPropertyName( - serverConfigurationConfig.connectorToggleName[ACCOUNT_RECOVERY_BY_USERNAME] + serverConfigurationConfig.connectorToggleName[ + ServerConfigurationsConstants.ACCOUNT_RECOVERY_BY_USERNAME ] ), value: data.checked.toString() }); @@ -251,7 +251,8 @@ export const ConnectorEditPage: FunctionComponent = name: ServerConfigurationsConstants.PASSWORD_RECOVERY_NOTIFICATION_BASED_RE_CAPTCHA, value: data.checked.toString() }); - if (ACCOUNT_RECOVERY_BY_USERNAME in serverConfigurationConfig.connectorToggleName) { + if (ServerConfigurationsConstants.ACCOUNT_RECOVERY_BY_USERNAME in + serverConfigurationConfig.connectorToggleName) { updateRecoveryCaptchaData.properties.push({ name: ServerConfigurationsConstants.USERNAME_RECOVERY_RE_CAPTCHA, value: data.checked.toString() @@ -622,7 +623,8 @@ export const ConnectorEditPage: FunctionComponent = ) }
  • { - serverConfigurationConfig.connectorToggleName[ACCOUNT_RECOVERY_BY_USERNAME] ? + serverConfigurationConfig.connectorToggleName[ + ServerConfigurationsConstants.ACCOUNT_RECOVERY_BY_USERNAME ] ? (
  • { t( "extensions:manage.serverConfigurations.accountSecurity." + From 31d2e8976ff8d02de3409840b979301ae8a2ea27 Mon Sep 17 00:00:00 2001 From: Udara Pathum <46132469+hwupathum@users.noreply.github.com> Date: Thu, 30 May 2024 14:45:03 +0530 Subject: [PATCH 9/9] =?UTF-8?q?Add=20changeset=20=F0=9F=A6=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .changeset/{quiet-maps-travel.md => hip-hairs-fry.md} | 1 + 1 file changed, 1 insertion(+) rename .changeset/{quiet-maps-travel.md => hip-hairs-fry.md} (77%) diff --git a/.changeset/quiet-maps-travel.md b/.changeset/hip-hairs-fry.md similarity index 77% rename from .changeset/quiet-maps-travel.md rename to .changeset/hip-hairs-fry.md index 908228426d5..1c82455ebf3 100644 --- a/.changeset/quiet-maps-travel.md +++ b/.changeset/hip-hairs-fry.md @@ -1,5 +1,6 @@ --- "@wso2is/admin.server-configurations.v1": patch +"@wso2is/admin.extensions.v1": patch "@wso2is/console": patch ---