From cf75e8c8895fc3c6bd6f1a01cbcc1622a6ae2f6d Mon Sep 17 00:00:00 2001 From: DonOmalVindula Date: Mon, 20 Nov 2023 13:08:56 +0530 Subject: [PATCH 1/3] Fix issues in the login and registration --- .../configs/server-configuration.tsx | 5 +- .../pages/saml2-configuration.tsx | 2 +- .../forms/connector-form-factory.tsx | 29 ++++++-- .../forms/username-recovery-form.tsx | 8 +-- .../pages/connector-edit-page.tsx | 67 ++++++++++++------- 5 files changed, 72 insertions(+), 39 deletions(-) diff --git a/apps/console/src/extensions/configs/server-configuration.tsx b/apps/console/src/extensions/configs/server-configuration.tsx index 5aafab99335..cc80eeb6e95 100644 --- a/apps/console/src/extensions/configs/server-configuration.tsx +++ b/apps/console/src/extensions/configs/server-configuration.tsx @@ -66,9 +66,12 @@ export const serverConfigurationConfig: ServerConfigurationConfig = { ], 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_AFTER_MAX_FAILED_ATTEMPTS_ENABLE }, connectorsToHide: [ ServerConfigurationsConstants.ALTERNATIVE_LOGIN_IDENTIFIER, diff --git a/apps/console/src/features/saml2-configuration/pages/saml2-configuration.tsx b/apps/console/src/features/saml2-configuration/pages/saml2-configuration.tsx index 95236abed3c..610cf744187 100644 --- a/apps/console/src/features/saml2-configuration/pages/saml2-configuration.tsx +++ b/apps/console/src/features/saml2-configuration/pages/saml2-configuration.tsx @@ -326,7 +326,7 @@ export const Saml2ConfigurationPage: FunctionComponent { - saml2WebSSO.deprecatedProperties + saml2WebSSO?.deprecatedProperties .includes("destinationURLs.pattern") && ( diff --git a/apps/console/src/features/server-configurations/forms/connector-form-factory.tsx b/apps/console/src/features/server-configurations/forms/connector-form-factory.tsx index 0eab1b10b6d..d4165e66a45 100644 --- a/apps/console/src/features/server-configurations/forms/connector-form-factory.tsx +++ b/apps/console/src/features/server-configurations/forms/connector-form-factory.tsx @@ -20,6 +20,7 @@ import { hasRequiredScopes } from "@wso2is/core/helpers"; import { TestableComponentInterface } from "@wso2is/core/models"; import React, { FunctionComponent, ReactElement, useMemo } from "react"; import { useSelector } from "react-redux"; +import { AdminForcedPasswordResetForm } from "./admin-forced-password-reset"; import { AnalyticsConfigurationForm } from "./analytics-form"; import { AskPasswordForm } from "./ask-password"; import { LoginAttemptSecurityConfigurationFrom } from "./login-attempt-security-form"; @@ -27,11 +28,10 @@ import { MultiAttributeLoginForm } from "./multi-attribute-login"; import { OrganizationSelfServiceForm } from "./organization-self-service-form"; import { PasswordRecoveryConfigurationForm } from "./password-recovery-form"; import { SelfRegistrationForm } from "./self-registration-form"; -import { AppState, FeatureConfigInterface } from "../../core"; +import { UsernameRecoveryConfigurationForm } from "./username-recovery-form"; +import { AppState, FeatureConfigInterface, history } from "../../core"; import { ServerConfigurationsConstants } from "../constants/server-configurations-constants"; import { GovernanceConnectorInterface } from "../models/governance-connectors"; -import { AdminForcedPasswordResetForm } from "./admin-forced-password-reset"; -import { UsernameRecoveryConfigurationForm } from "./username-recovery-form"; /** * Proptypes for the connector form factory component. @@ -95,7 +95,10 @@ export const ConnectorFormFactory: FunctionComponent ); case ServerConfigurationsConstants.ACCOUNT_RECOVERY_CONNECTOR_ID: + if (type === "username") { + return ( + + ); + } + return ( @@ -171,7 +186,7 @@ export const ConnectorFormFactory: FunctionComponent @@ -181,7 +196,7 @@ export const ConnectorFormFactory: FunctionComponent diff --git a/apps/console/src/features/server-configurations/forms/username-recovery-form.tsx b/apps/console/src/features/server-configurations/forms/username-recovery-form.tsx index 873cfb77a95..7af0619b16a 100644 --- a/apps/console/src/features/server-configurations/forms/username-recovery-form.tsx +++ b/apps/console/src/features/server-configurations/forms/username-recovery-form.tsx @@ -126,7 +126,7 @@ export const UsernameRecoveryConfigurationForm: FunctionComponent { if (allowedConnectorFields.includes(property.name)) { - if (property.name === ServerConfigurationsConstants.NOTIFY_SUCCESS) { + if (property.name === ServerConfigurationsConstants.USERNAME_RECOVERY_ENABLE) { resolvedInitialValues = { ...resolvedInitialValues, notifySuccess: CommonUtils.parseBoolean(property.value) @@ -229,8 +229,7 @@ export const UsernameRecoveryConfigurationForm: FunctionComponent { - t("extensions:manage.serverConfigurations.accountRecovery." + - "passwordRecovery.form.fields.notifySuccess.hint") + "This specifies whether to notify the user via an email when username recovery is successful" } { - t("extensions:manage.serverConfigurations.accountRecovery." + - "passwordRecovery.form.fields.expiryTime.hint") + "Username recovery link expiry time in minutes" } = const allowedScopes: string = useSelector((state: AppState) => state?.auth?.allowedScopes); const [ isConnectorRequestLoading, setConnectorRequestLoading ] = useState(false); - const [ connectorType, setConnectorType ] = useState(undefined); const [ connector, setConnector ] = useState(undefined); const [ categoryId, setCategoryId ] = useState(undefined); const [ connectorId, setConnectorId ] = useState(undefined); @@ -99,6 +98,9 @@ export const ConnectorEditPage: FunctionComponent = [ featureConfig, allowedScopes ] ); + const path: string[] = history.location.pathname.split("/"); + const type: string = path[ path.length - 3 ]; + useEffect(() => { // If Governance Connector read permission is not available, prevent from trying to load the connectors. if ( @@ -176,12 +178,24 @@ export const ConnectorEditPage: FunctionComponent = properties: [] }; - updateData.properties.push({ - name: GovernanceConnectorUtils.decodeConnectorPropertyName( - serverConfigurationConfig.connectorToggleName[ connector?.name ] ?? connector?.name - ), - value: data.checked.toString() - }); + if (type === "username") { + // special case for username recovery + // TODO: remove this once the ID is fixed + updateData.properties.push({ + name: GovernanceConnectorUtils.decodeConnectorPropertyName( + serverConfigurationConfig.connectorToggleName["account-recovery-username"] + ), + value: data.checked.toString() + }); + } else { + updateData.properties.push({ + name: GovernanceConnectorUtils.decodeConnectorPropertyName( + serverConfigurationConfig.connectorToggleName[ connector?.name ] ?? connector?.name + ), + value: data.checked.toString() + }); + } + updateGovernanceConnector(updateData, categoryId, connectorId) .then(() => { @@ -296,12 +310,9 @@ export const ConnectorEditPage: FunctionComponent = }; const loadConnectorDetails = () => { - const path: string[] = history.location.pathname.split("/"); - const type: string = path[ path.length - 3 ]; const categoryId: string = path[ path.length - 2 ]; const connectorId: string = path[ path.length - 1 ]; - setConnectorType(type); setCategoryId(categoryId); setConnectorId(connectorId); resolveBackButtonState(connectorId); @@ -359,8 +370,8 @@ export const ConnectorEditPage: FunctionComponent = case ServerConfigurationsConstants.ACCOUNT_LOCKING_CONNECTOR_ID: return t("extensions:manage.serverConfigurations.accountSecurity.loginAttemptSecurity.heading"); case ServerConfigurationsConstants.ACCOUNT_RECOVERY_CONNECTOR_ID: - return connectorType === "username" - ? "Username Reocvery" + return type === "username" + ? "Username Recovery" : t("extensions:manage.serverConfigurations.accountRecovery.passwordRecovery.heading"); case ServerConfigurationsConstants.CAPTCHA_FOR_SSO_LOGIN_CONNECTOR_ID: return t("extensions:manage.serverConfigurations.accountSecurity.botDetection.heading"); @@ -380,9 +391,9 @@ export const ConnectorEditPage: FunctionComponent = case ServerConfigurationsConstants.ACCOUNT_LOCKING_CONNECTOR_ID: return t("extensions:manage.serverConfigurations.accountSecurity.loginAttemptSecurity.subHeading"); case ServerConfigurationsConstants.ACCOUNT_RECOVERY_CONNECTOR_ID: - return connectorType === "username" - ? "Enable self-service password recovery for users on the login page." + - " The user will receive a password reset link via email upon request." + return type === "username" + ? "Enable self-service username recovery for users on the login page." + + " The user will receive a username reset link via email upon request." : (
{ t("extensions:manage.serverConfigurations.accountRecovery.passwordRecovery.subHeading") } @@ -446,10 +457,12 @@ export const ConnectorEditPage: FunctionComponent = "notification.success.description" ); case ServerConfigurationsConstants.ACCOUNT_RECOVERY_CONNECTOR_ID: - return t( - "extensions:manage.serverConfigurations.accountRecovery.passwordRecovery." + - "notification.success.description" - ); + return type === "username" + ? "Successfully updated the username recovery configuration." + : t( + "extensions:manage.serverConfigurations.accountRecovery.passwordRecovery." + + "notification.success.description" + ); case ServerConfigurationsConstants.ANALYTICS_ENGINE_CONNECTOR_ID: return t( "extensions:manage.serverConfigurations.analytics.form." + @@ -481,10 +494,12 @@ export const ConnectorEditPage: FunctionComponent = "notification.error.description" ); case ServerConfigurationsConstants.ACCOUNT_RECOVERY_CONNECTOR_ID: - return t( - "extensions:manage.serverConfigurations.accountRecovery.passwordRecovery." + - "notification.error.description" - ); + return type === "username" + ? "Error occurred while updating the username recovery configuration." + : t( + "extensions:manage.serverConfigurations.accountRecovery.passwordRecovery." + + "notification.error.description" + ); case ServerConfigurationsConstants.ANALYTICS_ENGINE_CONNECTOR_ID: return t( "extensions:manage.serverConfigurations.analytics.form." + @@ -533,9 +548,11 @@ export const ConnectorEditPage: FunctionComponent = case ServerConfigurationsConstants.SELF_SIGN_UP_CONNECTOR_ID: return ServerConfigurationsConstants.SELF_REGISTRATION_ENABLE; case ServerConfigurationsConstants.CAPTCHA_FOR_SSO_LOGIN_CONNECTOR_ID: - return ServerConfigurationsConstants.RE_CAPTCHA_ALWAYS_ENABLE; + return ServerConfigurationsConstants.RE_CAPTCHA_AFTER_MAX_FAILED_ATTEMPTS_ENABLE; case ServerConfigurationsConstants.ACCOUNT_RECOVERY_CONNECTOR_ID: - return ServerConfigurationsConstants.PASSWORD_RECOVERY_NOTIFICATION_BASED_ENABLE; + return type === "username" + ? ServerConfigurationsConstants.USERNAME_RECOVERY_ENABLE + : ServerConfigurationsConstants.PASSWORD_RECOVERY_NOTIFICATION_BASED_ENABLE; case ServerConfigurationsConstants.ORGANIZATION_SELF_SERVICE_CONNECTOR_ID: return ServerConfigurationsConstants.ORGANIZATION_SELF_SERVICE_ENABLE; case ServerConfigurationsConstants.MULTI_ATTRIBUTE_LOGIN_CONNECTOR_ID: From dd4e1a36211521534484cc0433150a887ebb2aca Mon Sep 17 00:00:00 2001 From: DonOmalVindula Date: Mon, 20 Nov 2023 14:05:53 +0530 Subject: [PATCH 2/3] Fix lint issues --- .../configs/server-configuration.tsx | 21 ++++++++++--------- .../pages/saml2-configuration.tsx | 2 +- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/apps/console/src/extensions/configs/server-configuration.tsx b/apps/console/src/extensions/configs/server-configuration.tsx index cc80eeb6e95..91aeee798b1 100644 --- a/apps/console/src/extensions/configs/server-configuration.tsx +++ b/apps/console/src/extensions/configs/server-configuration.tsx @@ -58,7 +58,7 @@ export const serverConfigurationConfig: ServerConfigurationConfig = { connectorCategoriesToShow: [ ServerConfigurationsConstants.USER_ONBOARDING_CONNECTOR_ID, ServerConfigurationsConstants.ACCOUNT_MANAGEMENT_CONNECTOR_CATEGORY_ID, - ServerConfigurationsConstants.LOGIN_ATTEMPT_SECURITY_CONNECTOR_CATEGORY_ID, + ServerConfigurationsConstants.LOGIN_ATTEMPT_SECURITY_CONNECTOR_CATEGORY_ID ], connectorPropertiesToShow: [ "all" ], connectorStatusViewDisabledConnectorIDs: [ @@ -88,16 +88,8 @@ export const serverConfigurationConfig: ServerConfigurationConfig = { ServerConfigurationsConstants.SESSION_MANAGEMENT_CONNECTOR_ID, ServerConfigurationsConstants.WS_FEDERATION_CONNECTOR_ID ], - extendedConnectors: [], - predefinedConnectorCategories: [ - "UGFzc3dvcmQgUG9saWNpZXM", - "VXNlciBPbmJvYXJkaW5n", - "TG9naW4gQXR0ZW1wdHMgU2VjdXJpdHk", - "T3RoZXIgU2V0dGluZ3M", - "QWNjb3VudCBNYW5hZ2VtZW50", - "TXVsdGkgRmFjdG9yIEF1dGhlbnRpY2F0b3Jz" - ], dynamicConnectors: true, + extendedConnectors: [], intendSettings: false, passwordExpiryComponent: ( componentId: string, @@ -125,6 +117,15 @@ export const serverConfigurationConfig: ServerConfigurationConfig = { t ); }, + predefinedConnectorCategories: [ + "UGFzc3dvcmQgUG9saWNpZXM", + "VXNlciBPbmJvYXJkaW5n", + "TG9naW4gQXR0ZW1wdHMgU2VjdXJpdHk", + "T3RoZXIgU2V0dGluZ3M", + "QWNjb3VudCBNYW5hZ2VtZW50", + "TXVsdGkgRmFjdG9yIEF1dGhlbnRpY2F0b3Jz" + ], + processInitialValues: ( initialValues: ValidationFormInterface, passwordHistoryCount: GovernanceConnectorInterface, diff --git a/apps/console/src/features/saml2-configuration/pages/saml2-configuration.tsx b/apps/console/src/features/saml2-configuration/pages/saml2-configuration.tsx index 610cf744187..5753ac42aaf 100644 --- a/apps/console/src/features/saml2-configuration/pages/saml2-configuration.tsx +++ b/apps/console/src/features/saml2-configuration/pages/saml2-configuration.tsx @@ -64,7 +64,7 @@ export const Saml2ConfigurationPage: FunctionComponent state?.config?.ui?.features?.governanceConnectors); const saml2WebSSO: DeprecatedFeatureInterface = gonvernanConnectorsConfig - .deprecatedFeaturesToShow.find((feature) => { + .deprecatedFeaturesToShow.find((feature: any) => { return feature?.name === "saml2"; }); From 8980a39fa97f5c21b315338669a2c3aa3b762883 Mon Sep 17 00:00:00 2001 From: DonOmalVindula Date: Mon, 20 Nov 2023 14:23:27 +0530 Subject: [PATCH 3/3] Fix issue in application info section --- .../features/applications/api/application.ts | 2 +- .../help-panel/oidc-configurations.tsx | 48 +++++++++---------- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/apps/console/src/features/applications/api/application.ts b/apps/console/src/features/applications/api/application.ts index 0966159ee17..ea075af6e3b 100644 --- a/apps/console/src/features/applications/api/application.ts +++ b/apps/console/src/features/applications/api/application.ts @@ -944,7 +944,7 @@ export const getOIDCApplicationConfigurations = (): Promise + + + + + + + + + { featureConfig?.residentIdp?.enabled && ( <> - - - - - - - - -