From aba518f85e31d244503f200585573e817b7c6471 Mon Sep 17 00:00:00 2001 From: JayaShakthi97 Date: Fri, 26 Jul 2024 13:44:35 +0530 Subject: [PATCH 01/18] Revamp error message constants in `admin.identity-providers` feature --- .../api/authenticators.ts | 6 ++-- .../constants/connection-ui-constants.ts | 35 +++++++++++++++++++ .../api/fido-configs.ts | 5 +-- .../api/fido-trusted-apps.ts | 6 ++-- .../api/identity-provider.ts | 12 +++---- .../fido-authenticator-form.tsx | 3 +- .../identity-provider-management-constants.ts | 35 ------------------- .../identity-provider-management-utils.ts | 4 +-- 8 files changed, 54 insertions(+), 52 deletions(-) diff --git a/features/admin.connections.v1/api/authenticators.ts b/features/admin.connections.v1/api/authenticators.ts index 745bf3d198a..0f471d4f6d7 100644 --- a/features/admin.connections.v1/api/authenticators.ts +++ b/features/admin.connections.v1/api/authenticators.ts @@ -24,7 +24,6 @@ import useRequest, { RequestResultInterface } from "@wso2is/admin.core.v1/hooks/use-request"; import useResourceEndpoints from "@wso2is/admin.core.v1/hooks/use-resource-endpoints"; -import { IdentityProviderManagementConstants } from "@wso2is/admin.identity-providers.v1/constants"; import { IdentityAppsApiException } from "@wso2is/core/exceptions"; import { HttpMethods } from "@wso2is/core/models"; import { AxiosError, AxiosRequestConfig, AxiosResponse } from "axios"; @@ -32,6 +31,7 @@ import { AuthenticatorManagementConstants } from "../constants/autheticator-cons import { ConnectionManagementConstants } from "../constants/connection-constants"; +import { ConnectionUIConstants } from "../constants/connection-ui-constants"; import { AuthenticatorInterface, AuthenticatorTypes, @@ -117,7 +117,7 @@ export const getAuthenticators = (filter?: string, type?: AuthenticatorTypes): P .then((response: AxiosResponse) => { if (response.status !== 200) { throw new IdentityAppsApiException( - IdentityProviderManagementConstants.AUTHENTICATORS_FETCH_INVALID_STATUS_CODE_ERROR, + ConnectionUIConstants.ERROR_MESSAGES.AUTHENTICATORS_FETCH_INVALID_STATUS_CODE_ERROR, null, response.status, response.request, @@ -140,7 +140,7 @@ export const getAuthenticators = (filter?: string, type?: AuthenticatorTypes): P return Promise.resolve(response.data); }).catch((error: AxiosError) => { throw new IdentityAppsApiException( - IdentityProviderManagementConstants.AUTHENTICATORS_FETCH_ERROR, + ConnectionUIConstants.ERROR_MESSAGES.AUTHENTICATORS_FETCH_ERROR, error.stack, error.code, error.request, diff --git a/features/admin.connections.v1/constants/connection-ui-constants.ts b/features/admin.connections.v1/constants/connection-ui-constants.ts index d290e33b679..5f212f0e74c 100644 --- a/features/admin.connections.v1/constants/connection-ui-constants.ts +++ b/features/admin.connections.v1/constants/connection-ui-constants.ts @@ -197,4 +197,39 @@ export class ConnectionUIConstants { this.APPLE_SECRET_REGENERATIVE_FIELDS_DICTIONARY.SECRET_VALIDITY_PERIOD, this.APPLE_SECRET_REGENERATIVE_FIELDS_DICTIONARY.TEAM_ID ]; + + /* eslint-disable max-len */ + // TODO: These error messages need to be localized. + public static readonly ERROR_MESSAGES: { + AUTHENTICATORS_FETCH_ERROR: string; + AUTHENTICATORS_FETCH_INVALID_STATUS_CODE_ERROR: string; + COMBINED_AUTHENTICATOR_FETCH_ERROR: string; + FIDO_AUTHENTICATOR_CONFIG_UPDATE_ERROR: string; + FIDO_AUTHENTICATOR_CONFIG_UPDATE_INVALID_STATUS_CODE_ERROR: string; + FIDO_TRUSTED_APPS_UPDATE_ERROR: string; + FIDO_TRUSTED_APPS_UPDATE_INVALID_STATUS_CODE_ERROR: string; + IDENTITY_PROVIDER_TEMPLATES_LIST_FETCH_ERROR: string; + IDENTITY_PROVIDER_TEMPLATES_LIST_FETCH_INVALID_STATUS_CODE_ERROR: string; + LOCAL_AUTHENTICATORS_FETCH_ERROR: string; + LOCAL_AUTHENTICATORS_FETCH_INVALID_STATUS_CODE_ERROR: string; + } = { + AUTHENTICATORS_FETCH_ERROR: "An error occurred while fetching the authenticators.", + AUTHENTICATORS_FETCH_INVALID_STATUS_CODE_ERROR: "Received an invalid status code while fetching the authenticators.", + COMBINED_AUTHENTICATOR_FETCH_ERROR: "An error occurred while fetching the local and federated authenticators.", + FIDO_AUTHENTICATOR_CONFIG_UPDATE_ERROR: "An error occurred while updating the Passkey connector configs.", + FIDO_AUTHENTICATOR_CONFIG_UPDATE_INVALID_STATUS_CODE_ERROR: "Received an invalid status code while updating the Passkey connector configs.", + FIDO_TRUSTED_APPS_UPDATE_ERROR: "An error occurred while updating the Passkey trusted apps.", + FIDO_TRUSTED_APPS_UPDATE_INVALID_STATUS_CODE_ERROR: "Received an invalid status code while updating the Passkey trusted apps.", + IDENTITY_PROVIDER_TEMPLATES_LIST_FETCH_ERROR: "An error occurred while fetching the required connection templates list.", + IDENTITY_PROVIDER_TEMPLATES_LIST_FETCH_INVALID_STATUS_CODE_ERROR: "Received an invalid status code while fetching connection templates list.", + LOCAL_AUTHENTICATORS_FETCH_ERROR: "An error occurred while fetching the local authenticators.", + LOCAL_AUTHENTICATORS_FETCH_INVALID_STATUS_CODE_ERROR: "Received an invalid status code while fetching local authenticators." + }; + /* eslint-enable max-len */ + + public static readonly ERROR_CODES: { + FIDO_CONNECTOR_CONFIGS_NOT_CONFIGURED_ERROR_CODE: string; + } = { + FIDO_CONNECTOR_CONFIGS_NOT_CONFIGURED_ERROR_CODE: "CONFIGM_00017" + }; } diff --git a/features/admin.identity-providers.v1/api/fido-configs.ts b/features/admin.identity-providers.v1/api/fido-configs.ts index b8f1f83aef6..7a29e8ecf67 100644 --- a/features/admin.identity-providers.v1/api/fido-configs.ts +++ b/features/admin.identity-providers.v1/api/fido-configs.ts @@ -17,6 +17,7 @@ */ import { AsgardeoSPAClient, HttpClientInstance } from "@asgardeo/auth-react"; +import { ConnectionUIConstants } from "@wso2is/admin.connections.v1/constants/connection-ui-constants"; import { store } from "@wso2is/admin.core.v1"; import useRequest, { RequestConfigInterface, @@ -93,7 +94,7 @@ export const updateFidoConfigs = ( .then((response: AxiosResponse) => { if (response?.status !== 200) { throw new IdentityAppsApiException( - IdentityProviderManagementConstants.FIDO_AUTHENTICATOR_CONFIG_UPDATE_INVALID_STATUS_CODE_ERROR, + ConnectionUIConstants.ERROR_MESSAGES.FIDO_AUTHENTICATOR_CONFIG_UPDATE_INVALID_STATUS_CODE_ERROR, null, response?.status, response?.request, @@ -104,7 +105,7 @@ export const updateFidoConfigs = ( return Promise.resolve(response.data as FIDOConnectorConfigsInterface); }).catch((error: AxiosError) => { throw new IdentityAppsApiException( - IdentityProviderManagementConstants.FIDO_AUTHENTICATOR_CONFIG_UPDATE_ERROR, + ConnectionUIConstants.ERROR_MESSAGES.FIDO_AUTHENTICATOR_CONFIG_UPDATE_ERROR, error?.stack, error?.response?.data?.code, error?.request, diff --git a/features/admin.identity-providers.v1/api/fido-trusted-apps.ts b/features/admin.identity-providers.v1/api/fido-trusted-apps.ts index d176ed65282..306beebe5cf 100644 --- a/features/admin.identity-providers.v1/api/fido-trusted-apps.ts +++ b/features/admin.identity-providers.v1/api/fido-trusted-apps.ts @@ -17,6 +17,7 @@ */ import { AsgardeoSPAClient, HttpClientInstance } from "@asgardeo/auth-react"; +import { ConnectionUIConstants } from "@wso2is/admin.connections.v1/constants/connection-ui-constants"; import { store } from "@wso2is/admin.core.v1"; import useRequest, { RequestConfigInterface, @@ -26,7 +27,6 @@ import useRequest, { import { IdentityAppsApiException } from "@wso2is/core/exceptions"; import { HttpMethods } from "@wso2is/core/models"; import { AxiosError, AxiosResponse } from "axios"; -import { IdentityProviderManagementConstants } from "../constants"; import { FIDOTrustedAppsResponseInterface } from "../models"; /** @@ -91,7 +91,7 @@ export const updateFidoTrustedApps = ( .then((response: AxiosResponse) => { if (response?.status !== 200) { throw new IdentityAppsApiException( - IdentityProviderManagementConstants.FIDO_TRUSTED_APPS_UPDATE_INVALID_STATUS_CODE_ERROR, + ConnectionUIConstants.ERROR_MESSAGES.FIDO_TRUSTED_APPS_UPDATE_INVALID_STATUS_CODE_ERROR, null, response?.status, response?.request, @@ -100,7 +100,7 @@ export const updateFidoTrustedApps = ( } }).catch((error: AxiosError) => { throw new IdentityAppsApiException( - IdentityProviderManagementConstants.FIDO_TRUSTED_APPS_UPDATE_ERROR, + ConnectionUIConstants.ERROR_MESSAGES.FIDO_TRUSTED_APPS_UPDATE_ERROR, error?.stack, error?.response?.data?.code, error?.request, diff --git a/features/admin.identity-providers.v1/api/identity-provider.ts b/features/admin.identity-providers.v1/api/identity-provider.ts index d228fc6c8af..6afa96a14ec 100755 --- a/features/admin.identity-providers.v1/api/identity-provider.ts +++ b/features/admin.identity-providers.v1/api/identity-provider.ts @@ -1,5 +1,5 @@ /** - * Copyright (c) 2023, WSO2 LLC. (https://www.wso2.com). + * Copyright (c) 2023-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 @@ -16,6 +16,7 @@ * under the License. */ import { AsgardeoSPAClient, HttpClientInstance } from "@asgardeo/auth-react"; +import { ConnectionUIConstants } from "@wso2is/admin.connections.v1/constants/connection-ui-constants"; import { store } from "@wso2is/admin.core.v1"; import useRequest, { RequestConfigInterface, @@ -25,7 +26,6 @@ import useRequest, { import { IdentityAppsApiException } from "@wso2is/core/exceptions"; import { HttpMethods } from "@wso2is/core/models"; import { AxiosError, AxiosResponse } from "axios"; -import { IdentityProviderManagementConstants } from "../constants"; import { FederatedAuthenticatorMetaInterface, IdentityProviderListResponseInterface, @@ -147,7 +147,7 @@ export const getIdentityProviderTemplateList = (limit?: number, offset?: number, .then((response: AxiosResponse) => { if (response.status !== 200) { throw new IdentityAppsApiException( - IdentityProviderManagementConstants + ConnectionUIConstants.ERROR_MESSAGES .IDENTITY_PROVIDER_TEMPLATES_LIST_FETCH_INVALID_STATUS_CODE_ERROR, null, response.status, @@ -159,7 +159,7 @@ export const getIdentityProviderTemplateList = (limit?: number, offset?: number, return Promise.resolve(response.data as IdentityProviderTemplateListResponseInterface); }).catch((error: AxiosError) => { throw new IdentityAppsApiException( - IdentityProviderManagementConstants.IDENTITY_PROVIDER_TEMPLATES_LIST_FETCH_ERROR, + ConnectionUIConstants.ERROR_MESSAGES.IDENTITY_PROVIDER_TEMPLATES_LIST_FETCH_ERROR, error.stack, error.code, error.request, @@ -190,7 +190,7 @@ export const getLocalAuthenticators = (): Promise .then((response: AxiosResponse) => { if (response.status !== 200) { throw new IdentityAppsApiException( - IdentityProviderManagementConstants.LOCAL_AUTHENTICATORS_FETCH_INVALID_STATUS_CODE_ERROR, + ConnectionUIConstants.ERROR_MESSAGES.LOCAL_AUTHENTICATORS_FETCH_INVALID_STATUS_CODE_ERROR, null, response.status, response.request, @@ -201,7 +201,7 @@ export const getLocalAuthenticators = (): Promise return Promise.resolve(response.data); }).catch((error: AxiosError) => { throw new IdentityAppsApiException( - IdentityProviderManagementConstants.LOCAL_AUTHENTICATORS_FETCH_ERROR, + ConnectionUIConstants.ERROR_MESSAGES.LOCAL_AUTHENTICATORS_FETCH_ERROR, error.stack, error.code, error.request, diff --git a/features/admin.identity-providers.v1/components/forms/authenticators/fido-authenticator-forms/fido-authenticator-form.tsx b/features/admin.identity-providers.v1/components/forms/authenticators/fido-authenticator-forms/fido-authenticator-form.tsx index 6daf0d7236b..4ab3d437b8b 100644 --- a/features/admin.identity-providers.v1/components/forms/authenticators/fido-authenticator-forms/fido-authenticator-form.tsx +++ b/features/admin.identity-providers.v1/components/forms/authenticators/fido-authenticator-forms/fido-authenticator-form.tsx @@ -16,6 +16,7 @@ * under the License. */ +import { ConnectionUIConstants } from "@wso2is/admin.connections.v1/constants/connection-ui-constants"; import { identityProviderConfig } from "@wso2is/admin.extensions.v1"; import { useGetCurrentOrganizationType } from "@wso2is/admin.organizations.v1/hooks/use-get-organization-type"; import { IdentityAppsApiException } from "@wso2is/core/exceptions"; @@ -126,7 +127,7 @@ export const FIDOAuthenticatorForm: FunctionComponent { throw new IdentityAppsApiException( - IdentityProviderManagementConstants.COMBINED_AUTHENTICATOR_FETCH_ERROR, + ConnectionUIConstants.ERROR_MESSAGES.COMBINED_AUTHENTICATOR_FETCH_ERROR, error.stack, error.code, error.request, From d28ee8cc2e675b013e15ea08b2247c92faa23f41 Mon Sep 17 00:00:00 2001 From: JayaShakthi97 Date: Fri, 26 Jul 2024 14:36:16 +0530 Subject: [PATCH 02/18] Move federated authenticator related constants --- .../components/sign-on-methods-core.tsx | 40 ++++++++++++------- .../constants/application-management.ts | 12 +++--- ...ined-social-flow-handler-modal-factory.tsx | 20 +++++----- .../federated-authenticator-constants.ts | 30 ++++++++++++++ .../local-authenticator-constants.ts | 16 ++++++++ .../api/fido-configs.ts | 4 +- .../fido-authenticator-form.tsx | 10 ++--- .../fido-trusted-apps.tsx | 6 +-- .../identity-provider-management-constants.ts | 27 ------------- 9 files changed, 98 insertions(+), 67 deletions(-) diff --git a/features/admin.applications.v1/components/settings/sign-on-methods/components/sign-on-methods-core.tsx b/features/admin.applications.v1/components/settings/sign-on-methods/components/sign-on-methods-core.tsx index 7d8f6168815..f8e624cf7de 100644 --- a/features/admin.applications.v1/components/settings/sign-on-methods/components/sign-on-methods-core.tsx +++ b/features/admin.applications.v1/components/settings/sign-on-methods/components/sign-on-methods-core.tsx @@ -605,19 +605,19 @@ export const SignOnMethodsCore: FunctionComponent { if (option.authenticator === authenticatorType) { @@ -640,19 +640,24 @@ export const SignOnMethodsCore: FunctionComponent(shouldFetch ? requestConfig : null); diff --git a/features/admin.identity-providers.v1/components/forms/authenticators/fido-authenticator-forms/fido-authenticator-form.tsx b/features/admin.identity-providers.v1/components/forms/authenticators/fido-authenticator-forms/fido-authenticator-form.tsx index 4ab3d437b8b..a51f96b360f 100644 --- a/features/admin.identity-providers.v1/components/forms/authenticators/fido-authenticator-forms/fido-authenticator-form.tsx +++ b/features/admin.identity-providers.v1/components/forms/authenticators/fido-authenticator-forms/fido-authenticator-form.tsx @@ -17,6 +17,7 @@ */ import { ConnectionUIConstants } from "@wso2is/admin.connections.v1/constants/connection-ui-constants"; +import { LocalAuthenticatorConstants } from "@wso2is/admin.connections.v1/constants/local-authenticator-constants"; import { identityProviderConfig } from "@wso2is/admin.extensions.v1"; import { useGetCurrentOrganizationType } from "@wso2is/admin.organizations.v1/hooks/use-get-organization-type"; import { IdentityAppsApiException } from "@wso2is/core/exceptions"; @@ -33,7 +34,6 @@ import { useDispatch } from "react-redux"; import { Dispatch } from "redux"; import { FIDOTrustedApps } from "./fido-trusted-apps"; import { updateFidoConfigs, useFIDOConnectorConfigs } from "../../../../api/fido-configs"; -import { IdentityProviderManagementConstants } from "../../../../constants"; import { CommonAuthenticatorFormFieldMetaInterface, CommonAuthenticatorFormInitialValuesInterface, @@ -105,7 +105,7 @@ export const FIDOAuthenticatorForm: FunctionComponent - attribute?.key === IdentityProviderManagementConstants.FIDO_TRUSTED_ORIGINS_ATTRIBUTE_KEY + attribute?.key === LocalAuthenticatorConstants.FIDO_TRUSTED_ORIGINS_ATTRIBUTE_KEY ); if (trustedOriginsAttribute) { @@ -198,11 +198,11 @@ export const FIDOAuthenticatorForm: FunctionComponent = fidoTrustedApps?.android?.forEach((app: string) => { if (app) { const appData: string[] = app?.split( - IdentityProviderManagementConstants.FIDO_TRUSTED_APPS_SHA_SEPARATOR); + LocalAuthenticatorConstants.FIDO_TRUSTED_APPS_SHA_SEPARATOR); if (!trustedApps?.android?.[appData[0]]) { trustedApps.android[appData[0]] = []; @@ -189,7 +189,7 @@ export const FIDOTrustedApps: FunctionComponent = if (FIDOTrustedApps?.android?.[appName]?.length > 0) { FIDOTrustedApps?.android?.[appName]?.forEach((hash: string) => { androidApps?.push(`${appName}${ - IdentityProviderManagementConstants.FIDO_TRUSTED_APPS_SHA_SEPARATOR + LocalAuthenticatorConstants.FIDO_TRUSTED_APPS_SHA_SEPARATOR }${hash}`); }); } else { diff --git a/features/admin.identity-providers.v1/constants/identity-provider-management-constants.ts b/features/admin.identity-providers.v1/constants/identity-provider-management-constants.ts index e8a2b8dd572..d07f200f92f 100755 --- a/features/admin.identity-providers.v1/constants/identity-provider-management-constants.ts +++ b/features/admin.identity-providers.v1/constants/identity-provider-management-constants.ts @@ -24,8 +24,6 @@ import { authenticatorConfig } from "@wso2is/admin.extensions.v1/configs/authent */ export class IdentityProviderManagementConstants { - public static readonly FIDO_TRUSTED_APPS_SHA_SEPARATOR: string = "|"; - public static readonly SESSION_EXECUTOR_AUTHENTICATOR: string = "SessionExecutor"; public static readonly TOTP_AUTHENTICATOR: string = "totp"; public static readonly IPROOV_AUTHENTICATOR: string = "IproovAuthenticator"; @@ -71,34 +69,9 @@ export class IdentityProviderManagementConstants { public static readonly SAML_AUTHENTICATOR_NAME: string = "SAMLSSOAuthenticator"; public static readonly OIDC_AUTHENTICATOR_NAME: string = "OpenIDConnectAuthenticator"; - // Known Social/Enterprise authenticator names; - public static readonly GOOGLE_OIDC_AUTHENTICATOR_NAME: string = "GoogleOIDCAuthenticator"; - public static readonly FACEBOOK_AUTHENTICATOR_NAME: string = "FacebookAuthenticator"; - public static readonly GITHUB_AUTHENTICATOR_NAME: string = "GithubAuthenticator"; - public static readonly TWITTER_AUTHENTICATOR_NAME: string = "TwitterAuthenticator"; - public static readonly MICROSOFT_AUTHENTICATOR_NAME: string = "MicrosoftAuthenticator"; - public static readonly APPLE_AUTHENTICATOR_NAME: string = "AppleOIDCAuthenticator"; - - // Known Social authenticator display names; - public static readonly GOOGLE_OIDC_AUTHENTICATOR_DISPLAY_NAME: string = "Google"; - public static readonly FACEBOOK_AUTHENTICATOR_DISPLAY_NAME: string = "Facebook"; - public static readonly GITHUB_AUTHENTICATOR_DISPLAY_NAME: string = "GitHub"; - public static readonly MICROSOFT_AUTHENTICATOR_DISPLAY_NAME: string = "Microsoft"; - public static readonly APPLE_AUTHENTICATOR_DISPLAY_NAME: string = "Apple"; - // Keys for the initial values of Email OTP Authenticator public static readonly AUTHENTICATOR_INIT_VALUES_EMAIL_OTP_EXPIRY_TIME_KEY: string = "EmailOTP_ExpiryTime"; // Keys for the initial values of SMS OTP Authenticator public static readonly AUTHENTICATOR_INIT_VALUES_SMS_OTP_EXPIRY_TIME_KEY: string = "SmsOTP_ExpiryTime"; - - /** - * Name of the FIDO connector configuration. - */ - public static readonly FIDO_CONNECTOR_CONFIG_NAME: string = "fido-connector"; - - /** - * Attribute key for the trusted origins in the FIDO connector configuration. - */ - public static readonly FIDO_TRUSTED_ORIGINS_ATTRIBUTE_KEY: string = "FIDO2TrustedOrigins"; } From 56f21d6410730236fe53e5c453bed41003406da9 Mon Sep 17 00:00:00 2001 From: JayaShakthi97 Date: Fri, 26 Jul 2024 15:08:29 +0530 Subject: [PATCH 03/18] Move federated authenticator constants --- .../components/sign-on-methods-core.tsx | 4 ++-- .../constants/application-management.ts | 10 +++++----- ...fined-social-flow-handler-modal-factory.tsx | 4 ++-- .../federated-authenticator-constants.ts | 6 ++++++ .../factories/authenticator-form-factory.tsx | 4 ++-- .../identity-provider-management-constants.ts | 9 --------- .../meta/authenticator-meta.ts | 18 +++++++++--------- 7 files changed, 26 insertions(+), 29 deletions(-) diff --git a/features/admin.applications.v1/components/settings/sign-on-methods/components/sign-on-methods-core.tsx b/features/admin.applications.v1/components/settings/sign-on-methods/components/sign-on-methods-core.tsx index f8e624cf7de..f3213d18b31 100644 --- a/features/admin.applications.v1/components/settings/sign-on-methods/components/sign-on-methods-core.tsx +++ b/features/admin.applications.v1/components/settings/sign-on-methods/components/sign-on-methods-core.tsx @@ -252,7 +252,7 @@ export const SignOnMethodsCore: FunctionComponent { if (authenticator.defaultAuthenticator.authenticatorId - === IdentityProviderManagementConstants.GOOGLE_OIDC_AUTHENTICATOR_ID) { + === FederatedAuthenticatorConstants.AUTHENTICATOR_IDS.GOOGLE_OIDC_AUTHENTICATOR_ID) { google.push(authenticator); } else if (authenticator.defaultAuthenticator.authenticatorId @@ -260,7 +260,7 @@ export const SignOnMethodsCore: FunctionComponent ); - case IdentityProviderManagementConstants.FACEBOOK_AUTHENTICATOR_ID: + case FederatedAuthenticatorConstants.AUTHENTICATOR_IDS.FACEBOOK_AUTHENTICATOR_ID: return ( Date: Mon, 29 Jul 2024 11:53:15 +0530 Subject: [PATCH 04/18] Restructure identity-provider constants --- .../components/sign-on-methods-core.tsx | 2 +- .../constants/application-management.ts | 4 ++-- .../predefined-social-flow-handler-modal-factory.tsx | 5 +---- .../forms/factories/authenticator-form-factory.tsx | 2 +- .../identity-provider-management-constants.ts | 2 -- .../meta/authenticator-meta.ts | 12 ++++++------ 6 files changed, 11 insertions(+), 16 deletions(-) diff --git a/features/admin.applications.v1/components/settings/sign-on-methods/components/sign-on-methods-core.tsx b/features/admin.applications.v1/components/settings/sign-on-methods/components/sign-on-methods-core.tsx index f3213d18b31..c5517a1b106 100644 --- a/features/admin.applications.v1/components/settings/sign-on-methods/components/sign-on-methods-core.tsx +++ b/features/admin.applications.v1/components/settings/sign-on-methods/components/sign-on-methods-core.tsx @@ -256,7 +256,7 @@ export const SignOnMethodsCore: FunctionComponent ); - case IdentityProviderManagementConstants.GITHUB_AUTHENTICATOR_ID: + case FederatedAuthenticatorConstants.AUTHENTICATOR_IDS.GITHUB_AUTHENTICATOR_ID: return ( Date: Mon, 29 Jul 2024 13:27:12 +0530 Subject: [PATCH 05/18] Restructure constants --- .../sign-on-methods/components/sign-on-methods-core.tsx | 2 +- .../constants/application-management.ts | 4 ++-- .../constants/federated-authenticator-constants.ts | 2 ++ .../forms/factories/authenticator-form-factory.tsx | 2 +- .../constants/identity-provider-management-constants.ts | 5 ----- .../admin.identity-providers.v1/meta/authenticator-meta.ts | 2 +- 6 files changed, 7 insertions(+), 10 deletions(-) diff --git a/features/admin.applications.v1/components/settings/sign-on-methods/components/sign-on-methods-core.tsx b/features/admin.applications.v1/components/settings/sign-on-methods/components/sign-on-methods-core.tsx index c5517a1b106..65d27176195 100644 --- a/features/admin.applications.v1/components/settings/sign-on-methods/components/sign-on-methods-core.tsx +++ b/features/admin.applications.v1/components/settings/sign-on-methods/components/sign-on-methods-core.tsx @@ -264,7 +264,7 @@ export const SignOnMethodsCore: FunctionComponent ); - case IdentityProviderManagementConstants.MICROSOFT_AUTHENTICATOR_ID: + case FederatedAuthenticatorConstants.AUTHENTICATOR_IDS.MICROSOFT_AUTHENTICATOR_ID: if (templateId === MicrosoftIDPTemplate.id){ return( Date: Mon, 29 Jul 2024 13:35:23 +0530 Subject: [PATCH 06/18] Restructure identity-provider constants --- .../step-based-flow/authenticators.tsx | 5 +++-- .../constants/local-authenticator-constants.ts | 13 ++++++++++++- .../meta/authenticator-meta.ts | 7 ++++--- .../identity-provider-management-constants.ts | 2 -- .../meta/authenticator-meta.ts | 16 ++++++++++------ 5 files changed, 29 insertions(+), 14 deletions(-) diff --git a/features/admin.applications.v1/components/settings/sign-on-methods/step-based-flow/authenticators.tsx b/features/admin.applications.v1/components/settings/sign-on-methods/step-based-flow/authenticators.tsx index 49bd4597a6f..b4920557aad 100644 --- a/features/admin.applications.v1/components/settings/sign-on-methods/step-based-flow/authenticators.tsx +++ b/features/admin.applications.v1/components/settings/sign-on-methods/step-based-flow/authenticators.tsx @@ -18,6 +18,7 @@ import Chip from "@oxygen-ui/react/Chip"; import { AuthenticatorManagementConstants } from "@wso2is/admin.connections.v1"; +import { LocalAuthenticatorConstants } from "@wso2is/admin.connections.v1/constants/local-authenticator-constants"; import { AuthenticatorMeta } from "@wso2is/admin.connections.v1/meta/authenticator-meta"; import { ConnectionsManagementUtils } from "@wso2is/admin.connections.v1/utils/connection-utils"; import { AppState } from "@wso2is/admin.core.v1"; @@ -163,7 +164,7 @@ export const Authenticators: FunctionComponent = ( if ([ IdentityProviderManagementConstants.IDENTIFIER_FIRST_AUTHENTICATOR_ID, - IdentityProviderManagementConstants.BASIC_AUTHENTICATOR_ID ].includes(authenticator.id)) { + LocalAuthenticatorConstants.AUTHENTICATOR_IDS.BASIC_AUTHENTICATOR_ID ].includes(authenticator.id)) { return SignInMethodUtils.isFirstFactorValid(currentStep, authenticationSteps); } @@ -281,7 +282,7 @@ export const Authenticators: FunctionComponent = ( ); } else if ([ IdentityProviderManagementConstants.IDENTIFIER_FIRST_AUTHENTICATOR_ID, - IdentityProviderManagementConstants.BASIC_AUTHENTICATOR_ID ].includes(authenticator.id)) { + LocalAuthenticatorConstants.AUTHENTICATOR_IDS.BASIC_AUTHENTICATOR_ID ].includes(authenticator.id)) { return ( { InfoLabel } diff --git a/features/admin.connections.v1/constants/local-authenticator-constants.ts b/features/admin.connections.v1/constants/local-authenticator-constants.ts index 3cfffe68745..7c6736fc636 100644 --- a/features/admin.connections.v1/constants/local-authenticator-constants.ts +++ b/features/admin.connections.v1/constants/local-authenticator-constants.ts @@ -31,7 +31,18 @@ export class LocalAuthenticatorConstants { */ public static readonly LOCAL_IDP_IDENTIFIER: string = "LOCAL"; - public static readonly BASIC_AUTHENTICATOR_ID: string = "QmFzaWNBdXRoZW50aWNhdG9y"; + /** + * Authenticator IDs for the local authenticators. + */ + public static readonly AUTHENTICATOR_IDS: { + BASIC_AUTHENTICATOR_ID: string; + IDENTIFIER_FIRST_AUTHENTICATOR_ID: string; + MAGIC_LINK_AUTHENTICATOR_ID: string; + } = { + BASIC_AUTHENTICATOR_ID: "QmFzaWNBdXRoZW50aWNhdG9y", + IDENTIFIER_FIRST_AUTHENTICATOR_ID: "Qml0cmljdF9hdXRoZW50aWNhdG9y", + MAGIC_LINK_AUTHENTICATOR_ID: "TWFnaWNMaW5rQXV0aGVudGljYXRvcg" + }; // FIDO authenticator constants. /** diff --git a/features/admin.connections.v1/meta/authenticator-meta.ts b/features/admin.connections.v1/meta/authenticator-meta.ts index a5910b585b8..16c4df3f2ef 100644 --- a/features/admin.connections.v1/meta/authenticator-meta.ts +++ b/features/admin.connections.v1/meta/authenticator-meta.ts @@ -45,7 +45,8 @@ export class AuthenticatorMeta { public static getAuthenticatorDescription(authenticatorId: string): string { return get({ - [ LocalAuthenticatorConstants.BASIC_AUTHENTICATOR_ID ]: "Login users with username and password " + + [ LocalAuthenticatorConstants.AUTHENTICATOR_IDS + .BASIC_AUTHENTICATOR_ID ]: "Login users with username and password " + "credentials.", [ AuthenticatorManagementConstants.IDENTIFIER_FIRST_AUTHENTICATOR_ID ]: "Get users Identity first to " + "control the authentication flow.", @@ -186,7 +187,7 @@ export class AuthenticatorMeta { [ AuthenticatorManagementConstants.FIDO_AUTHENTICATOR_ID ]: getConnectionIcons()?.fido, [ AuthenticatorManagementConstants.X509_CERTIFICATE_AUTHENTICATOR_ID ]: getConnectionIcons()?.x509, [ AuthenticatorManagementConstants.TOTP_AUTHENTICATOR_ID ]: getConnectionIcons()?.totp, - [ LocalAuthenticatorConstants.BASIC_AUTHENTICATOR_ID ]: getConnectionIcons()?.basic, + [ LocalAuthenticatorConstants.AUTHENTICATOR_IDS.BASIC_AUTHENTICATOR_ID ]: getConnectionIcons()?.basic, [ AuthenticatorManagementConstants.ACTIVE_SESSION_LIMIT_HANDLER_AUTHENTICATOR_ID ]: getConnectionIcons()?.sessionExecutor, @@ -254,7 +255,7 @@ export class AuthenticatorMeta { public static getAuthenticatorTemplateName(authenticatorId: string): string { return get({ - [ LocalAuthenticatorConstants.BASIC_AUTHENTICATOR_ID ]: "username-and-password", + [ LocalAuthenticatorConstants.AUTHENTICATOR_IDS.BASIC_AUTHENTICATOR_ID ]: "username-and-password", [ AuthenticatorManagementConstants.FIDO_AUTHENTICATOR_ID ]: "fido", [ AuthenticatorManagementConstants.TOTP_AUTHENTICATOR_ID ]: "totp", [ AuthenticatorManagementConstants.SMS_OTP_AUTHENTICATOR_ID ]: "sms-otp", diff --git a/features/admin.identity-providers.v1/constants/identity-provider-management-constants.ts b/features/admin.identity-providers.v1/constants/identity-provider-management-constants.ts index fefddc54768..05d4611c3a8 100755 --- a/features/admin.identity-providers.v1/constants/identity-provider-management-constants.ts +++ b/features/admin.identity-providers.v1/constants/identity-provider-management-constants.ts @@ -38,7 +38,6 @@ export class IdentityProviderManagementConstants { public static readonly MAGIC_LINK_AUTHENTICATOR: string = "MagicLinkAuthenticator"; // Known Local Authenticator IDS. - public static readonly BASIC_AUTHENTICATOR_ID: string = "QmFzaWNBdXRoZW50aWNhdG9y"; public static readonly IDENTIFIER_FIRST_AUTHENTICATOR_ID: string = "SWRlbnRpZmllckV4ZWN1dG9y"; public static readonly JWT_BASIC_AUTHENTICATOR_ID: string = "SldUQmFzaWNBdXRoZW50aWNhdG9y"; public static readonly FIDO_AUTHENTICATOR_ID: string = "RklET0F1dGhlbnRpY2F0b3I"; @@ -51,7 +50,6 @@ export class IdentityProviderManagementConstants { public static readonly EMAIL_OTP_AUTHENTICATOR_ID: string = "ZW1haWwtb3RwLWF1dGhlbnRpY2F0b3I"; public static readonly LEGACY_EMAIL_OTP_AUTHENTICATOR_ID: string = "RW1haWxPVFA"; public static readonly BACKUP_CODE_AUTHENTICATOR_ID: string = "YmFja3VwLWNvZGUtYXV0aGVudGljYXRvcg"; - public static readonly MAGIC_LINK_AUTHENTICATOR_ID: string = "TWFnaWNMaW5rQXV0aGVudGljYXRvcg"; // Keys for the initial values of Email OTP Authenticator public static readonly AUTHENTICATOR_INIT_VALUES_EMAIL_OTP_EXPIRY_TIME_KEY: string = "EmailOTP_ExpiryTime"; diff --git a/features/admin.identity-providers.v1/meta/authenticator-meta.ts b/features/admin.identity-providers.v1/meta/authenticator-meta.ts index 32871fc76e6..dcf40311761 100644 --- a/features/admin.identity-providers.v1/meta/authenticator-meta.ts +++ b/features/admin.identity-providers.v1/meta/authenticator-meta.ts @@ -20,6 +20,7 @@ import { AuthenticatorLabels, ConnectionManagementConstants } from "@wso2is/admi import { FederatedAuthenticatorConstants } from "@wso2is/admin.connections.v1/constants/federated-authenticator-constants"; +import { LocalAuthenticatorConstants } from "@wso2is/admin.connections.v1/constants/local-authenticator-constants"; import get from "lodash-es/get"; import { ReactNode } from "react"; import { getAuthenticatorIcons } from "../configs/ui"; @@ -45,7 +46,8 @@ export class AuthenticatorMeta { public static getAuthenticatorDescription(authenticatorId: string): string { return get({ - [ IdentityProviderManagementConstants.BASIC_AUTHENTICATOR_ID ]: "Login users with username and password " + + [ LocalAuthenticatorConstants.AUTHENTICATOR_IDS + .BASIC_AUTHENTICATOR_ID ]: "Login users with username and password " + "credentials.", [ IdentityProviderManagementConstants.IDENTIFIER_FIRST_AUTHENTICATOR_ID ]: "Get users Identity first to " + "control the authentication flow.", @@ -71,7 +73,8 @@ export class AuthenticatorMeta { "using one-time passcode sent via email.", [ IdentityProviderManagementConstants.SMS_OTP_AUTHENTICATOR_ID ]: "Two-factor authentication using " + "SMS one-time passcode.", - [ IdentityProviderManagementConstants.MAGIC_LINK_AUTHENTICATOR_ID ]: "Email users a magic link to " + + [ LocalAuthenticatorConstants.AUTHENTICATOR_IDS + .MAGIC_LINK_AUTHENTICATOR_ID ]: "Email users a magic link to " + "log in passwordless", [ FederatedAuthenticatorConstants.AUTHENTICATOR_IDS.APPLE_AUTHENTICATOR_ID ]: "Login users with " + "their Apple IDs.", @@ -129,13 +132,14 @@ export class AuthenticatorMeta { [ IdentityProviderManagementConstants.FIDO_AUTHENTICATOR_ID ]: getAuthenticatorIcons()?.fido, [ IdentityProviderManagementConstants.X509_CERTIFICATE_AUTHENTICATOR_ID ]: getAuthenticatorIcons()?.x509, [ IdentityProviderManagementConstants.TOTP_AUTHENTICATOR_ID ]: getAuthenticatorIcons()?.totp, - [ IdentityProviderManagementConstants.BASIC_AUTHENTICATOR_ID ]: getAuthenticatorIcons()?.basic, + [ LocalAuthenticatorConstants.AUTHENTICATOR_IDS.BASIC_AUTHENTICATOR_ID ]: getAuthenticatorIcons()?.basic, [ IdentityProviderManagementConstants.ACTIVE_SESSION_LIMIT_HANDLER_AUTHENTICATOR_ID ]: getAuthenticatorIcons()?.sessionExecutor, [ IdentityProviderManagementConstants.EMAIL_OTP_AUTHENTICATOR_ID ]: getAuthenticatorIcons()?.emailOTP, [ IdentityProviderManagementConstants.SMS_OTP_AUTHENTICATOR_ID ]: getAuthenticatorIcons()?.smsOTP, - [ IdentityProviderManagementConstants.MAGIC_LINK_AUTHENTICATOR_ID ]: getAuthenticatorIcons()?.magicLink, + [ LocalAuthenticatorConstants.AUTHENTICATOR_IDS + .MAGIC_LINK_AUTHENTICATOR_ID ]: getAuthenticatorIcons()?.magicLink, [ IdentityProviderManagementConstants.BACKUP_CODE_AUTHENTICATOR_ID ]: getAuthenticatorIcons()?.backupCode }, authenticatorId); @@ -154,7 +158,7 @@ export class AuthenticatorMeta { return get({ [ IdentityProviderManagementConstants.IDENTIFIER_FIRST_AUTHENTICATOR_ID ]: "Predefined", [ IdentityProviderManagementConstants.FIDO_AUTHENTICATOR_ID ]: "Predefined", - [ IdentityProviderManagementConstants.MAGIC_LINK_AUTHENTICATOR_ID ]: "Predefined", + [ LocalAuthenticatorConstants.AUTHENTICATOR_IDS.MAGIC_LINK_AUTHENTICATOR_ID ]: "Predefined", [ IdentityProviderManagementConstants.TOTP_AUTHENTICATOR_ID ]: "Predefined", [ FederatedAuthenticatorConstants.AUTHENTICATOR_IDS.GOOGLE_OIDC_AUTHENTICATOR_ID ]: "Google", [ FederatedAuthenticatorConstants.AUTHENTICATOR_IDS.GITHUB_AUTHENTICATOR_ID ]: "GitHub", @@ -200,7 +204,7 @@ export class AuthenticatorMeta { return get({ [ IdentityProviderManagementConstants.BASIC_AUTHENTICATOR ]: "username-and-password", - [ IdentityProviderManagementConstants.BASIC_AUTHENTICATOR_ID ]: "username-and-password", + [ LocalAuthenticatorConstants.AUTHENTICATOR_IDS.BASIC_AUTHENTICATOR_ID ]: "username-and-password", [ IdentityProviderManagementConstants.FIDO_AUTHENTICATOR_ID ]: "fido", [ IdentityProviderManagementConstants.TOTP_AUTHENTICATOR_ID ]: "totp", [ IdentityProviderManagementConstants.SMS_OTP_AUTHENTICATOR_ID ]: "sms-otp", From c582838d9a1324f807dfb6a110072a82b2089bfa Mon Sep 17 00:00:00 2001 From: JayaShakthi97 Date: Mon, 29 Jul 2024 14:31:24 +0530 Subject: [PATCH 07/18] Restructure identity-provider constants --- .../sign-in-method-landing.tsx | 3 +- .../step-based-flow/authentication-step.tsx | 6 +- .../step-based-flow/authenticators.tsx | 6 +- .../constants/application-management.ts | 8 +-- .../utils/sign-in-method-utils.ts | 39 ++++++------ .../federated-authenticator-constants.ts | 2 + .../local-authenticator-constants.ts | 16 ++++- .../factories/authenticator-form-factory.tsx | 7 ++- .../identity-provider-management-constants.ts | 9 --- .../meta/authenticator-meta.ts | 62 +++++++++++-------- 10 files changed, 88 insertions(+), 70 deletions(-) diff --git a/features/admin.applications.v1/components/settings/sign-on-methods/sign-in-method-landing.tsx b/features/admin.applications.v1/components/settings/sign-on-methods/sign-in-method-landing.tsx index 8ef41d17a10..99d532e25a1 100644 --- a/features/admin.applications.v1/components/settings/sign-on-methods/sign-in-method-landing.tsx +++ b/features/admin.applications.v1/components/settings/sign-on-methods/sign-in-method-landing.tsx @@ -17,6 +17,7 @@ */ import useAuthenticationFlow from "@wso2is/admin.authentication-flow-builder.v1/hooks/use-authentication-flow"; import { ConnectionManagementConstants } from "@wso2is/admin.connections.v1/constants/connection-constants"; +import { LocalAuthenticatorConstants } from "@wso2is/admin.connections.v1/constants/local-authenticator-constants"; import { EventPublisher, FeatureConfigInterface } from "@wso2is/admin.core.v1"; import useDeploymentConfig from "@wso2is/admin.core.v1/hooks/use-deployment-configs"; import { @@ -292,7 +293,7 @@ export const SignInMethodLanding: FunctionComponent ); } else if ([ - IdentityProviderManagementConstants.IDENTIFIER_FIRST_AUTHENTICATOR_ID, + LocalAuthenticatorConstants.AUTHENTICATOR_IDS.IDENTIFIER_FIRST_AUTHENTICATOR_ID, LocalAuthenticatorConstants.AUTHENTICATOR_IDS.BASIC_AUTHENTICATOR_ID ].includes(authenticator.id)) { return ( @@ -392,7 +392,7 @@ export const Authenticators: FunctionComponent = ( { heading && { heading } } { authenticators.map((authenticator: GenericAuthenticatorInterface, index: number) => ( - authenticator.id === IdentityProviderManagementConstants.BACKUP_CODE_AUTHENTICATOR_ID ? + authenticator.id === LocalAuthenticatorConstants.AUTHENTICATOR_IDS.BACKUP_CODE_AUTHENTICATOR_ID ? null : ( { + public static checkImmediateStepHavingSpecificFactors = (factors: string[], + steps: AuthenticationStepInterface[]): boolean => { - let isFound: boolean = false; + let isFound: boolean = false; - for (const [ , step ] of steps.entries()) { - for (const option of step.options) { - if (factors.includes(option.authenticator)) { - isFound = true; + for (const [ , step ] of steps.entries()) { + for (const option of step.options) { + if (factors.includes(option.authenticator)) { + isFound = true; - break; - } - } + break; + } + } - if (isFound) { - break; - } - } + if (isFound) { + break; + } + } - return isFound; - }; + return isFound; + }; /** * Counts the occurrence of a specific factors in the passed in steps. @@ -199,12 +200,12 @@ export class SignInMethodUtils { const [ leftSideSteps ]: AuthenticationStepInterface[][] = this.getLeftAndRightSideSteps(addingStep, steps); // If the adding authenticator is TOTP, evaluate if there are valid TOTP handlers in previous steps. - if (authenticatorId === IdentityProviderManagementConstants.TOTP_AUTHENTICATOR_ID) { + if (authenticatorId === LocalAuthenticatorConstants.AUTHENTICATOR_IDS.TOTP_AUTHENTICATOR_ID) { return this.hasSpecificFactorsInSteps(ApplicationManagementConstants.TOTP_HANDLERS, leftSideSteps); } // If the adding authenticator is Email OTP, evaluate if there are valid handlers in previous steps. - if (authenticatorId === IdentityProviderManagementConstants.EMAIL_OTP_AUTHENTICATOR_ID) { + if (authenticatorId === LocalAuthenticatorConstants.AUTHENTICATOR_IDS.EMAIL_OTP_AUTHENTICATOR_ID) { return this.hasSpecificFactorsInSteps(ApplicationManagementConstants.EMAIL_OTP_HANDLERS, leftSideSteps); } diff --git a/features/admin.connections.v1/constants/federated-authenticator-constants.ts b/features/admin.connections.v1/constants/federated-authenticator-constants.ts index 58484ee4ce2..9bcd9ba3882 100644 --- a/features/admin.connections.v1/constants/federated-authenticator-constants.ts +++ b/features/admin.connections.v1/constants/federated-authenticator-constants.ts @@ -28,6 +28,7 @@ export class FederatedAuthenticatorConstants { public static readonly AUTHENTICATOR_IDS: { APPLE_AUTHENTICATOR_ID: string; + EMAIL_OTP_AUTHENTICATOR_ID: string; FACEBOOK_AUTHENTICATOR_ID: string; GITHUB_AUTHENTICATOR_ID: string; GOOGLE_OIDC_AUTHENTICATOR_ID: string; @@ -40,6 +41,7 @@ export class FederatedAuthenticatorConstants { TWITTER_AUTHENTICATOR_ID: string; } = { APPLE_AUTHENTICATOR_ID: "QXBwbGVPSURDQXV0aGVudGljYXRvcg", + EMAIL_OTP_AUTHENTICATOR_ID: "RW1haWxPVFA", FACEBOOK_AUTHENTICATOR_ID: "RmFjZWJvb2tBdXRoZW50aWNhdG9y", GITHUB_AUTHENTICATOR_ID: "R2l0aHViQXV0aGVudGljYXRvcg", GOOGLE_OIDC_AUTHENTICATOR_ID: "R29vZ2xlT0lEQ0F1dGhlbnRpY2F0b3I", diff --git a/features/admin.connections.v1/constants/local-authenticator-constants.ts b/features/admin.connections.v1/constants/local-authenticator-constants.ts index 7c6736fc636..a1098abe54c 100644 --- a/features/admin.connections.v1/constants/local-authenticator-constants.ts +++ b/features/admin.connections.v1/constants/local-authenticator-constants.ts @@ -35,13 +35,25 @@ export class LocalAuthenticatorConstants { * Authenticator IDs for the local authenticators. */ public static readonly AUTHENTICATOR_IDS: { + ACTIVE_SESSION_LIMIT_HANDLER_AUTHENTICATOR_ID: string; + BACKUP_CODE_AUTHENTICATOR_ID: string; BASIC_AUTHENTICATOR_ID: string; + EMAIL_OTP_AUTHENTICATOR_ID: string; + FIDO_AUTHENTICATOR_ID: string; IDENTIFIER_FIRST_AUTHENTICATOR_ID: string; MAGIC_LINK_AUTHENTICATOR_ID: string; + TOTP_AUTHENTICATOR_ID: string; + X509_CERTIFICATE_AUTHENTICATOR_ID: string; } = { + ACTIVE_SESSION_LIMIT_HANDLER_AUTHENTICATOR_ID: "U2Vzc2lvbkV4ZWN1dG9y", + BACKUP_CODE_AUTHENTICATOR_ID: "YmFja3VwLWNvZGUtYXV0aGVudGljYXRvcg", BASIC_AUTHENTICATOR_ID: "QmFzaWNBdXRoZW50aWNhdG9y", - IDENTIFIER_FIRST_AUTHENTICATOR_ID: "Qml0cmljdF9hdXRoZW50aWNhdG9y", - MAGIC_LINK_AUTHENTICATOR_ID: "TWFnaWNMaW5rQXV0aGVudGljYXRvcg" + EMAIL_OTP_AUTHENTICATOR_ID: "ZW1haWwtb3RwLWF1dGhlbnRpY2F0b3I", + FIDO_AUTHENTICATOR_ID: "RklET0F1dGhlbnRpY2F0b3I", + IDENTIFIER_FIRST_AUTHENTICATOR_ID: "SWRlbnRpZmllckV4ZWN1dG9y", + MAGIC_LINK_AUTHENTICATOR_ID: "TWFnaWNMaW5rQXV0aGVudGljYXRvcg", + TOTP_AUTHENTICATOR_ID: "dG90cA", + X509_CERTIFICATE_AUTHENTICATOR_ID: "eDUwOUNlcnRpZmljYXRlQXV0aGVudGljYXRvcg" }; // FIDO authenticator constants. diff --git a/features/admin.identity-providers.v1/components/forms/factories/authenticator-form-factory.tsx b/features/admin.identity-providers.v1/components/forms/factories/authenticator-form-factory.tsx index 67413079096..ff3b1186062 100644 --- a/features/admin.identity-providers.v1/components/forms/factories/authenticator-form-factory.tsx +++ b/features/admin.identity-providers.v1/components/forms/factories/authenticator-form-factory.tsx @@ -1,5 +1,5 @@ /** - * Copyright (c) 2020, WSO2 LLC. (https://www.wso2.com). + * Copyright (c) 2020-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 @@ -20,6 +20,7 @@ import { ConnectionManagementConstants } from "@wso2is/admin.connections.v1"; import { FederatedAuthenticatorConstants } from "@wso2is/admin.connections.v1/constants/federated-authenticator-constants"; +import { LocalAuthenticatorConstants } from "@wso2is/admin.connections.v1/constants/local-authenticator-constants"; import { identityProviderConfig } from "@wso2is/admin.extensions.v1/configs/identity-provider"; import MicrosoftIDPTemplate from "@wso2is/admin.identity-providers.v1/data/identity-provider-templates/templates/microsoft/microsoft.json"; @@ -173,7 +174,7 @@ export const AuthenticatorFormFactory: FunctionComponent ); - case IdentityProviderManagementConstants.EMAIL_OTP_AUTHENTICATOR_ID: + case LocalAuthenticatorConstants.AUTHENTICATOR_IDS.EMAIL_OTP_AUTHENTICATOR_ID: return ( ); - case IdentityProviderManagementConstants.FIDO_AUTHENTICATOR_ID: + case LocalAuthenticatorConstants.AUTHENTICATOR_IDS.FIDO_AUTHENTICATOR_ID: return ( Date: Mon, 29 Jul 2024 14:39:41 +0530 Subject: [PATCH 08/18] Restructure identity-provider constants --- .../constants/local-authenticator-constants.ts | 2 ++ .../constants/identity-provider-management-constants.ts | 1 - .../admin.identity-providers.v1/meta/authenticator-meta.ts | 3 ++- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/features/admin.connections.v1/constants/local-authenticator-constants.ts b/features/admin.connections.v1/constants/local-authenticator-constants.ts index a1098abe54c..06057646674 100644 --- a/features/admin.connections.v1/constants/local-authenticator-constants.ts +++ b/features/admin.connections.v1/constants/local-authenticator-constants.ts @@ -41,6 +41,7 @@ export class LocalAuthenticatorConstants { EMAIL_OTP_AUTHENTICATOR_ID: string; FIDO_AUTHENTICATOR_ID: string; IDENTIFIER_FIRST_AUTHENTICATOR_ID: string; + JWT_BASIC_AUTHENTICATOR_ID: string; MAGIC_LINK_AUTHENTICATOR_ID: string; TOTP_AUTHENTICATOR_ID: string; X509_CERTIFICATE_AUTHENTICATOR_ID: string; @@ -51,6 +52,7 @@ export class LocalAuthenticatorConstants { EMAIL_OTP_AUTHENTICATOR_ID: "ZW1haWwtb3RwLWF1dGhlbnRpY2F0b3I", FIDO_AUTHENTICATOR_ID: "RklET0F1dGhlbnRpY2F0b3I", IDENTIFIER_FIRST_AUTHENTICATOR_ID: "SWRlbnRpZmllckV4ZWN1dG9y", + JWT_BASIC_AUTHENTICATOR_ID: "SldUQmFzaWNBdXRoZW50aWNhdG9y", MAGIC_LINK_AUTHENTICATOR_ID: "TWFnaWNMaW5rQXV0aGVudGljYXRvcg", TOTP_AUTHENTICATOR_ID: "dG90cA", X509_CERTIFICATE_AUTHENTICATOR_ID: "eDUwOUNlcnRpZmljYXRlQXV0aGVudGljYXRvcg" diff --git a/features/admin.identity-providers.v1/constants/identity-provider-management-constants.ts b/features/admin.identity-providers.v1/constants/identity-provider-management-constants.ts index 2d83ca09a92..39939fcbde2 100755 --- a/features/admin.identity-providers.v1/constants/identity-provider-management-constants.ts +++ b/features/admin.identity-providers.v1/constants/identity-provider-management-constants.ts @@ -38,7 +38,6 @@ export class IdentityProviderManagementConstants { public static readonly MAGIC_LINK_AUTHENTICATOR: string = "MagicLinkAuthenticator"; // Known Local Authenticator IDS. - public static readonly JWT_BASIC_AUTHENTICATOR_ID: string = "SldUQmFzaWNBdXRoZW50aWNhdG9y"; public static readonly SMS_OTP_AUTHENTICATOR_ID: string = authenticatorConfig?.overriddenAuthenticatorIds?. SMS_OTP_AUTHENTICATOR_ID ?? "U01TT1RQ"; diff --git a/features/admin.identity-providers.v1/meta/authenticator-meta.ts b/features/admin.identity-providers.v1/meta/authenticator-meta.ts index 592248fce12..f7f8bb22b53 100644 --- a/features/admin.identity-providers.v1/meta/authenticator-meta.ts +++ b/features/admin.identity-providers.v1/meta/authenticator-meta.ts @@ -134,7 +134,8 @@ export class AuthenticatorMeta { const icon: ReactNode = get({ [ LocalAuthenticatorConstants.AUTHENTICATOR_IDS .IDENTIFIER_FIRST_AUTHENTICATOR_ID ]: getAuthenticatorIcons()?.identifierFirst, - [ IdentityProviderManagementConstants.JWT_BASIC_AUTHENTICATOR_ID ]: getAuthenticatorIcons()?.jwtBasic, + [ LocalAuthenticatorConstants.AUTHENTICATOR_IDS + .JWT_BASIC_AUTHENTICATOR_ID ]: getAuthenticatorIcons()?.jwtBasic, [ LocalAuthenticatorConstants.AUTHENTICATOR_IDS.FIDO_AUTHENTICATOR_ID ]: getAuthenticatorIcons()?.fido, [ LocalAuthenticatorConstants.AUTHENTICATOR_IDS .X509_CERTIFICATE_AUTHENTICATOR_ID ]: getAuthenticatorIcons()?.x509, From 0b7ab1720dce119c19fd3b2df3fa2566fb83cf7e Mon Sep 17 00:00:00 2001 From: JayaShakthi97 Date: Mon, 29 Jul 2024 14:52:13 +0530 Subject: [PATCH 09/18] Move unnecessary extension config to constants --- .../settings/sign-on-methods/sign-in-method-landing.tsx | 2 +- .../constants/application-management.ts | 2 +- .../admin.applications.v1/utils/sign-in-method-utils.ts | 2 +- .../constants/local-authenticator-constants.ts | 2 ++ features/admin.extensions.v1/configs/authenticator.tsx | 3 --- .../admin.extensions.v1/configs/identity-provider.tsx | 4 ++-- .../admin.extensions.v1/configs/models/authenticator.ts | 3 --- .../forms/factories/authenticator-form-factory.tsx | 3 +-- .../constants/identity-provider-management-constants.ts | 4 ++-- .../meta/authenticator-meta.ts | 9 +++++---- 10 files changed, 15 insertions(+), 19 deletions(-) diff --git a/features/admin.applications.v1/components/settings/sign-on-methods/sign-in-method-landing.tsx b/features/admin.applications.v1/components/settings/sign-on-methods/sign-in-method-landing.tsx index 99d532e25a1..045f65eff62 100644 --- a/features/admin.applications.v1/components/settings/sign-on-methods/sign-in-method-landing.tsx +++ b/features/admin.applications.v1/components/settings/sign-on-methods/sign-in-method-landing.tsx @@ -323,7 +323,7 @@ export const SignInMethodLanding: FunctionComponent ); - case IdentityProviderManagementConstants.SMS_OTP_AUTHENTICATOR_ID: + case LocalAuthenticatorConstants.AUTHENTICATOR_IDS.SMS_OTP_AUTHENTICATOR_ID: return ( Date: Mon, 29 Jul 2024 15:10:00 +0530 Subject: [PATCH 10/18] Restructure authenticator names constants in identity-providers feature --- .../components/sign-on-methods-core.tsx | 5 ++-- .../step-based-flow/authentication-step.tsx | 7 +++--- .../step-based-flow/authenticators.tsx | 5 ++-- .../step-based-flow/step-based-flow.tsx | 8 ++++--- .../sign-in-box-node/sign-in-box-node.tsx | 15 +++++++----- ...e-social-authenticator-selection-modal.tsx | 9 ++++---- .../authentication-flow-provider.tsx | 8 ++++--- .../local-authenticator-constants.ts | 23 +++++++++++++++++++ .../identity-provider-management-constants.ts | 6 +---- .../api/use-available-authenticators.ts | 5 ++-- 10 files changed, 60 insertions(+), 31 deletions(-) diff --git a/features/admin.applications.v1/components/settings/sign-on-methods/components/sign-on-methods-core.tsx b/features/admin.applications.v1/components/settings/sign-on-methods/components/sign-on-methods-core.tsx index 65d27176195..3a8eaefe3a6 100644 --- a/features/admin.applications.v1/components/settings/sign-on-methods/components/sign-on-methods-core.tsx +++ b/features/admin.applications.v1/components/settings/sign-on-methods/components/sign-on-methods-core.tsx @@ -27,6 +27,7 @@ import { import { FederatedAuthenticatorConstants } from "@wso2is/admin.connections.v1/constants/federated-authenticator-constants"; +import { LocalAuthenticatorConstants } from "@wso2is/admin.connections.v1/constants/local-authenticator-constants"; import { ConnectionsManagementUtils } from "@wso2is/admin.connections.v1/utils/connection-utils"; import { AppConstants, EventPublisher, FeatureConfigInterface, history } from "@wso2is/admin.core.v1"; @@ -821,8 +822,8 @@ export const SignOnMethodsCore: FunctionComponent { - return authenticator.name !== IdentityProviderManagementConstants - .BACKUP_CODE_AUTHENTICATOR; + return authenticator.name !== LocalAuthenticatorConstants.AUTHENTICATOR_NAMES + .BACKUP_CODE_AUTHENTICATOR_NAME; }) .map((authenticator: GenericAuthenticatorInterface, index: number) => ( { if ([ IdentityProviderManagementConstants.TOTP_AUTHENTICATOR, - IdentityProviderManagementConstants.BACKUP_CODE_AUTHENTICATOR, + LocalAuthenticatorConstants.AUTHENTICATOR_NAMES.BACKUP_CODE_AUTHENTICATOR_NAME, IdentityProviderManagementConstants.SESSION_EXECUTOR_AUTHENTICATOR ] .includes(option.authenticator)) { setShowSubjectIdentifierCheckbox(false); @@ -179,7 +179,7 @@ export const AuthenticationStep: FunctionComponent { - if (option.authenticator === IdentityProviderManagementConstants.BACKUP_CODE_AUTHENTICATOR) { + if (option.authenticator === LocalAuthenticatorConstants.AUTHENTICATOR_NAMES + .BACKUP_CODE_AUTHENTICATOR_NAME) { isBackupCodesEnabled = true; setBackupCodeIndex(optionIndex); } diff --git a/features/admin.applications.v1/components/settings/sign-on-methods/step-based-flow/authenticators.tsx b/features/admin.applications.v1/components/settings/sign-on-methods/step-based-flow/authenticators.tsx index 46e4f7006b1..f5903b36f45 100644 --- a/features/admin.applications.v1/components/settings/sign-on-methods/step-based-flow/authenticators.tsx +++ b/features/admin.applications.v1/components/settings/sign-on-methods/step-based-flow/authenticators.tsx @@ -148,7 +148,7 @@ export const Authenticators: FunctionComponent = ( ); } - if (authenticator.name === IdentityProviderManagementConstants.BACKUP_CODE_AUTHENTICATOR) { + if (authenticator.name === LocalAuthenticatorConstants.AUTHENTICATOR_NAMES.BACKUP_CODE_AUTHENTICATOR_NAME) { // If there is only one step in the flow, backup code authenticator shouldn't be allowed. if (currentStep === 0) { return false; @@ -240,7 +240,8 @@ export const Authenticators: FunctionComponent = ( ) } ); - } else if (authenticator.name === IdentityProviderManagementConstants.BACKUP_CODE_AUTHENTICATOR) { + } else if (authenticator.name === LocalAuthenticatorConstants.AUTHENTICATOR_NAMES + .BACKUP_CODE_AUTHENTICATOR_NAME) { return ( <> { currentStep === 0 ? ( diff --git a/features/admin.applications.v1/components/settings/sign-on-methods/step-based-flow/step-based-flow.tsx b/features/admin.applications.v1/components/settings/sign-on-methods/step-based-flow/step-based-flow.tsx index a0c7c5c6151..475d108efab 100644 --- a/features/admin.applications.v1/components/settings/sign-on-methods/step-based-flow/step-based-flow.tsx +++ b/features/admin.applications.v1/components/settings/sign-on-methods/step-based-flow/step-based-flow.tsx @@ -17,6 +17,7 @@ */ import { AuthenticatorManagementConstants } from "@wso2is/admin.connections.v1/constants/autheticator-constants"; +import { LocalAuthenticatorConstants } from "@wso2is/admin.connections.v1/constants/local-authenticator-constants"; import { AppState, EventPublisher, FeatureConfigInterface } from "@wso2is/admin.core.v1"; import { applicationConfig } from "@wso2is/admin.extensions.v1"; import { @@ -165,7 +166,7 @@ export const StepBasedFlow: FunctionComponent const recoveryAuth: GenericAuthenticatorInterface[] = []; localAuthenticators.forEach((authenticator: GenericAuthenticatorInterface) => { - if (authenticator.name === IdentityProviderManagementConstants.BACKUP_CODE_AUTHENTICATOR) { + if (authenticator.name === LocalAuthenticatorConstants.AUTHENTICATOR_NAMES.BACKUP_CODE_AUTHENTICATOR_NAME) { recoveryAuth.push(authenticator); } else if (ApplicationManagementConstants.SECOND_FACTOR_AUTHENTICATORS.includes(authenticator.id)) { secondFactorAuth.push(authenticator); @@ -451,12 +452,13 @@ export const StepBasedFlow: FunctionComponent // check whether the current step has the backup code authenticator if(SignInMethodUtils.hasSpecificAuthenticatorInCurrentStep( - IdentityProviderManagementConstants.BACKUP_CODE_AUTHENTICATOR, stepIndex, steps + LocalAuthenticatorConstants.AUTHENTICATOR_NAMES.BACKUP_CODE_AUTHENTICATOR_NAME, stepIndex, steps )) { // if there is only one 2FA in the step, prompt delete confirmation modal if(SignInMethodUtils.countTwoFactorAuthenticatorsInCurrentStep(stepIndex, steps) < 2) { currentStep.options.map((option: AuthenticatorInterface, optionIndex: number) => { - if (option.authenticator === IdentityProviderManagementConstants.BACKUP_CODE_AUTHENTICATOR) { + if (option.authenticator === LocalAuthenticatorConstants.AUTHENTICATOR_NAMES + .BACKUP_CODE_AUTHENTICATOR_NAME) { setBackupCodeRemoveIndex(optionIndex); } }); diff --git a/features/admin.authentication-flow-builder.v1/components/nodes/sign-in-box-node/sign-in-box-node.tsx b/features/admin.authentication-flow-builder.v1/components/nodes/sign-in-box-node/sign-in-box-node.tsx index ea7a05a9fc4..b85eb1b22ad 100644 --- a/features/admin.authentication-flow-builder.v1/components/nodes/sign-in-box-node/sign-in-box-node.tsx +++ b/features/admin.authentication-flow-builder.v1/components/nodes/sign-in-box-node/sign-in-box-node.tsx @@ -206,7 +206,7 @@ export const SignInBoxNode: FunctionComponent = ( * No need to show Basic Auth, Identifier first, Backup Code authenticator .etc, as a Sign In option button. */ const getAuthenticatorsToNotShowAsOptions: string[] = useMemo( - () => [ IdentityProviderManagementConstants.BACKUP_CODE_AUTHENTICATOR ], + () => [ LocalAuthenticatorConstants.AUTHENTICATOR_NAMES.BACKUP_CODE_AUTHENTICATOR_NAME ], [] ); @@ -464,7 +464,8 @@ export const SignInBoxNode: FunctionComponent = ( let isBackupCodesEnabled: boolean = false; authenticationSequence?.steps?.[stepIndex]?.options.map((option: AuthenticatorInterface) => { - if (option.authenticator === IdentityProviderManagementConstants.BACKUP_CODE_AUTHENTICATOR) { + if (option.authenticator === LocalAuthenticatorConstants.AUTHENTICATOR_NAMES + .BACKUP_CODE_AUTHENTICATOR_NAME) { isBackupCodesEnabled = true; } }); @@ -485,7 +486,7 @@ export const SignInBoxNode: FunctionComponent = ( if ( [ IdentityProviderManagementConstants.TOTP_AUTHENTICATOR, - IdentityProviderManagementConstants.BACKUP_CODE_AUTHENTICATOR, + LocalAuthenticatorConstants.AUTHENTICATOR_NAMES.BACKUP_CODE_AUTHENTICATOR_NAME, IdentityProviderManagementConstants.SESSION_EXECUTOR_AUTHENTICATOR ].includes(option.authenticator) ) { @@ -501,7 +502,7 @@ export const SignInBoxNode: FunctionComponent = ( IdentityProviderManagementConstants.TOTP_AUTHENTICATOR, IdentityProviderManagementConstants.EMAIL_OTP_AUTHENTICATOR, IdentityProviderManagementConstants.SMS_OTP_AUTHENTICATOR, - IdentityProviderManagementConstants.BACKUP_CODE_AUTHENTICATOR + LocalAuthenticatorConstants.AUTHENTICATOR_NAMES.BACKUP_CODE_AUTHENTICATOR_NAME ].includes(option.authenticator) ) { shouldShowBackupCodesEnableCheck = true; @@ -626,12 +627,14 @@ export const SignInBoxNode: FunctionComponent = ( if (e.target.checked) { onSignInOptionAdd(e, { stepIndex, - toAdd: IdentityProviderManagementConstants.BACKUP_CODE_AUTHENTICATOR + toAdd: LocalAuthenticatorConstants.AUTHENTICATOR_NAMES + .BACKUP_CODE_AUTHENTICATOR_NAME }); } else { onSignInOptionRemove(e, { stepIndex, - toRemove: IdentityProviderManagementConstants.BACKUP_CODE_AUTHENTICATOR + toRemove: LocalAuthenticatorConstants.AUTHENTICATOR_NAMES + .BACKUP_CODE_AUTHENTICATOR_NAME }); } } } diff --git a/features/admin.authentication-flow-builder.v1/components/predefined-flows-side-panel/duplicate-social-authenticator-selection-modal.tsx b/features/admin.authentication-flow-builder.v1/components/predefined-flows-side-panel/duplicate-social-authenticator-selection-modal.tsx index 92878dad13a..5a159832266 100644 --- a/features/admin.authentication-flow-builder.v1/components/predefined-flows-side-panel/duplicate-social-authenticator-selection-modal.tsx +++ b/features/admin.authentication-flow-builder.v1/components/predefined-flows-side-panel/duplicate-social-authenticator-selection-modal.tsx @@ -1,5 +1,5 @@ /** - * Copyright (c) 2023, WSO2 LLC. (https://www.wso2.com). + * Copyright (c) 2023-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 @@ -16,9 +16,7 @@ * under the License. */ -import { - IdentityProviderManagementConstants -} from "@wso2is/admin.identity-providers.v1/constants/identity-provider-management-constants"; +import { LocalAuthenticatorConstants } from "@wso2is/admin.connections.v1/constants/local-authenticator-constants"; import { GenericAuthenticatorInterface } from "@wso2is/admin.identity-providers.v1/models/identity-provider"; import { IdentifiableComponentInterface } from "@wso2is/core/models"; import { Code, ConfirmationModal, ConfirmationModalPropsInterface, LabeledCard, Text } from "@wso2is/react-components"; @@ -132,7 +130,8 @@ const DuplicateSocialAuthenticatorSelectionModal: FunctionComponent<
{ authenticators .filter((authenticator: GenericAuthenticatorInterface) => { - return authenticator.name !== IdentityProviderManagementConstants.BACKUP_CODE_AUTHENTICATOR; + return authenticator.name !== LocalAuthenticatorConstants.AUTHENTICATOR_NAMES + .BACKUP_CODE_AUTHENTICATOR_NAME; }) .map((authenticator: GenericAuthenticatorInterface, index: number) => ( { - if (authenticator.name === IdentityProviderManagementConstants.BACKUP_CODE_AUTHENTICATOR) { + if (authenticator.name === LocalAuthenticatorConstants.AUTHENTICATOR_NAMES.BACKUP_CODE_AUTHENTICATOR_NAME) { recoveryAuthenticators.push(authenticator); } else if (ApplicationManagementConstants.SECOND_FACTOR_AUTHENTICATORS.includes(authenticator.id)) { secondFactorAuthenticators.push(authenticator); @@ -553,12 +554,13 @@ const AuthenticationFlowProvider = (props: PropsWithChildren { - if (option.authenticator === IdentityProviderManagementConstants.BACKUP_CODE_AUTHENTICATOR) { + if (option.authenticator === LocalAuthenticatorConstants.AUTHENTICATOR_NAMES + .BACKUP_CODE_AUTHENTICATOR_NAME) { backupCodeAuthenticatorIndex = optionIndex; } }); diff --git a/features/admin.connections.v1/constants/local-authenticator-constants.ts b/features/admin.connections.v1/constants/local-authenticator-constants.ts index 17e523f50b2..7d8af050c36 100644 --- a/features/admin.connections.v1/constants/local-authenticator-constants.ts +++ b/features/admin.connections.v1/constants/local-authenticator-constants.ts @@ -60,6 +60,29 @@ export class LocalAuthenticatorConstants { X509_CERTIFICATE_AUTHENTICATOR_ID: "eDUwOUNlcnRpZmljYXRlQXV0aGVudGljYXRvcg" }; + /** + * Authenticator names for the local authenticators. + */ + public static readonly AUTHENTICATOR_NAMES: { + BACKUP_CODE_AUTHENTICATOR_NAME: string; + BASIC_AUTHENTICATOR_NAME: string; + EMAIL_OTP_AUTHENTICATOR_NAME: string; + FIDO_AUTHENTICATOR_NAME: string; + IDENTIFIER_FIRST_AUTHENTICATOR_NAME: string; + MAGIC_LINK_AUTHENTICATOR_NAME: string; + SMS_OTP_AUTHENTICATOR_NAME: string; + TOTP_AUTHENTICATOR_NAME: string; + } = { + BACKUP_CODE_AUTHENTICATOR_NAME: "backup-code-authenticator", + BASIC_AUTHENTICATOR_NAME: "BasicAuthenticator", + EMAIL_OTP_AUTHENTICATOR_NAME: "email-otp-authenticator", + FIDO_AUTHENTICATOR_NAME: "FIDOAuthenticator", + IDENTIFIER_FIRST_AUTHENTICATOR_NAME: "IdentifierExecutor", + MAGIC_LINK_AUTHENTICATOR_NAME: "MagicLinkAuthenticator", + SMS_OTP_AUTHENTICATOR_NAME: "sms-otp-authenticator", + TOTP_AUTHENTICATOR_NAME: "totp" + }; + // FIDO authenticator constants. /** * Separator for the FIDO trusted apps. diff --git a/features/admin.identity-providers.v1/constants/identity-provider-management-constants.ts b/features/admin.identity-providers.v1/constants/identity-provider-management-constants.ts index 4a2435c76af..fbcf7e972d8 100755 --- a/features/admin.identity-providers.v1/constants/identity-provider-management-constants.ts +++ b/features/admin.identity-providers.v1/constants/identity-provider-management-constants.ts @@ -34,13 +34,9 @@ export class IdentityProviderManagementConstants { public static readonly SMS_OTP_AUTHENTICATOR: string = authenticatorConfig?.overriddenAuthenticatorNames?. SMS_OTP_AUTHENTICATOR ?? "sms-otp"; - public static readonly BACKUP_CODE_AUTHENTICATOR: string = "backup-code-authenticator"; + // public static readonly BACKUP_CODE_AUTHENTICATOR: string = "backup-code-authenticator"; public static readonly MAGIC_LINK_AUTHENTICATOR: string = "MagicLinkAuthenticator"; - // Known Local Authenticator IDS. - // public static readonly SMS_OTP_AUTHENTICATOR_ID: string = authenticatorConfig?.overriddenAuthenticatorIds?. - // SMS_OTP_AUTHENTICATOR_ID ?? "U01TT1RQ"; - // Keys for the initial values of Email OTP Authenticator public static readonly AUTHENTICATOR_INIT_VALUES_EMAIL_OTP_EXPIRY_TIME_KEY: string = "EmailOTP_ExpiryTime"; diff --git a/features/admin.login-flow.ai.v1/api/use-available-authenticators.ts b/features/admin.login-flow.ai.v1/api/use-available-authenticators.ts index c3d10aebd07..8dbc3dbb9f1 100644 --- a/features/admin.login-flow.ai.v1/api/use-available-authenticators.ts +++ b/features/admin.login-flow.ai.v1/api/use-available-authenticators.ts @@ -18,12 +18,12 @@ import { ApplicationManagementConstants } from "@wso2is/admin.applications.v1/constants"; import useUIConfig from "@wso2is/admin.core.v1/hooks/use-ui-configs"; -import { IdentityProviderManagementConstants } from "@wso2is/admin.identity-providers.v1/constants"; import { GenericAuthenticatorInterface } from "@wso2is/admin.identity-providers.v1/models"; import { IdentityProviderManagementUtils } from "@wso2is/admin.identity-providers.v1/utils/identity-provider-management-utils"; import { useEffect, useState } from "react"; +import { LocalAuthenticatorConstants } from "../../admin.connections.v1/constants/local-authenticator-constants"; import AuthenticatorsRecord from "../models/authenticators-record"; const useAvailableAuthenticators = (): { @@ -81,7 +81,8 @@ const useAvailableAuthenticators = (): { return; } - if (authenticator.name === IdentityProviderManagementConstants.BACKUP_CODE_AUTHENTICATOR) { + if (authenticator.name === LocalAuthenticatorConstants.AUTHENTICATOR_NAMES + .BACKUP_CODE_AUTHENTICATOR_NAME) { recoveryAuthenticators.push({ description: authenticator.description, idp: authenticator.idp, From 2e201ac3fcdbfe80c8a5b80dca059758699b9eae Mon Sep 17 00:00:00 2001 From: JayaShakthi97 Date: Mon, 29 Jul 2024 15:15:12 +0530 Subject: [PATCH 11/18] Migrate to `useRequiredScopes` hook --- .../sign-on-methods/step-based-flow/step-based-flow.tsx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/features/admin.applications.v1/components/settings/sign-on-methods/step-based-flow/step-based-flow.tsx b/features/admin.applications.v1/components/settings/sign-on-methods/step-based-flow/step-based-flow.tsx index 475d108efab..24a0e9490b6 100644 --- a/features/admin.applications.v1/components/settings/sign-on-methods/step-based-flow/step-based-flow.tsx +++ b/features/admin.applications.v1/components/settings/sign-on-methods/step-based-flow/step-based-flow.tsx @@ -16,6 +16,7 @@ * under the License. */ +import { useRequiredScopes } from "@wso2is/access-control"; import { AuthenticatorManagementConstants } from "@wso2is/admin.connections.v1/constants/autheticator-constants"; import { LocalAuthenticatorConstants } from "@wso2is/admin.connections.v1/constants/local-authenticator-constants"; import { AppState, EventPublisher, FeatureConfigInterface } from "@wso2is/admin.core.v1"; @@ -28,7 +29,6 @@ import { GenericAuthenticatorInterface, SupportedAuthenticators } from "@wso2is/admin.identity-providers.v1/models"; -import { hasRequiredScopes } from "@wso2is/core/helpers"; import { AlertLevels, IdentifiableComponentInterface } from "@wso2is/core/models"; import { addAlert } from "@wso2is/core/store"; import { ConfirmationModal, GenericIcon, Popup } from "@wso2is/react-components"; @@ -144,9 +144,11 @@ export const StepBasedFlow: FunctionComponent const eventPublisher: EventPublisher = EventPublisher.getInstance(); - const allowedScopes: string = useSelector((state: AppState) => state?.auth?.allowedScopes); const featureConfig: FeatureConfigInterface = useSelector((state: AppState) => state?.config?.ui?.features); + const hasConnectionsCreatePermissions: boolean = useRequiredScopes( + featureConfig?.identityProviders?.scopes?.create); + /** * Separates out the different authenticators to their relevant categories. */ @@ -860,8 +862,7 @@ export const StepBasedFlow: FunctionComponent return ( { From f7d250f138e920584e039f144a9b6ca24898e467 Mon Sep 17 00:00:00 2001 From: JayaShakthi97 Date: Mon, 29 Jul 2024 15:25:06 +0530 Subject: [PATCH 12/18] Restructure authenticator name constants in identity-providers feature --- .../sign-on-methods/sign-in-method-landing.tsx | 2 +- .../step-based-flow/authentication-step.tsx | 2 +- .../step-based-flow/authenticators.tsx | 9 ++++----- .../constants/application-management.ts | 2 +- .../fragments/active-sessions-limit-fragment.tsx | 9 ++++----- .../nodes/sign-in-box-node/sign-in-box-node.tsx | 14 +++++++++----- .../constants/local-authenticator-constants.ts | 2 ++ .../identity-provider-management-constants.ts | 5 +---- 8 files changed, 23 insertions(+), 22 deletions(-) diff --git a/features/admin.applications.v1/components/settings/sign-on-methods/sign-in-method-landing.tsx b/features/admin.applications.v1/components/settings/sign-on-methods/sign-in-method-landing.tsx index 045f65eff62..e178ed657a7 100644 --- a/features/admin.applications.v1/components/settings/sign-on-methods/sign-in-method-landing.tsx +++ b/features/admin.applications.v1/components/settings/sign-on-methods/sign-in-method-landing.tsx @@ -263,7 +263,7 @@ export const SignInMethodLanding: FunctionComponent { if ([ IdentityProviderManagementConstants.TOTP_AUTHENTICATOR, LocalAuthenticatorConstants.AUTHENTICATOR_NAMES.BACKUP_CODE_AUTHENTICATOR_NAME, - IdentityProviderManagementConstants.SESSION_EXECUTOR_AUTHENTICATOR ] + LocalAuthenticatorConstants.AUTHENTICATOR_NAMES.ACTIVE_SESSION_LIMIT_HANDLER_AUTHENTICATOR_NAME ] .includes(option.authenticator)) { setShowSubjectIdentifierCheckbox(false); } else { diff --git a/features/admin.applications.v1/components/settings/sign-on-methods/step-based-flow/authenticators.tsx b/features/admin.applications.v1/components/settings/sign-on-methods/step-based-flow/authenticators.tsx index f5903b36f45..c586946554f 100644 --- a/features/admin.applications.v1/components/settings/sign-on-methods/step-based-flow/authenticators.tsx +++ b/features/admin.applications.v1/components/settings/sign-on-methods/step-based-flow/authenticators.tsx @@ -25,9 +25,6 @@ import { AppState } from "@wso2is/admin.core.v1"; import useUIConfig from "@wso2is/admin.core.v1/hooks/use-ui-configs"; import { applicationConfig } from "@wso2is/admin.extensions.v1"; import FeatureStatusLabel from "@wso2is/admin.extensions.v1/components/feature-gate/models/feature-gate"; -import { - IdentityProviderManagementConstants -} from "@wso2is/admin.identity-providers.v1/constants/identity-provider-management-constants"; import { AuthenticatorCategories, GenericAuthenticatorInterface @@ -168,7 +165,8 @@ export const Authenticators: FunctionComponent = ( return SignInMethodUtils.isFirstFactorValid(currentStep, authenticationSteps); } - if (authenticator.name === IdentityProviderManagementConstants.SESSION_EXECUTOR_AUTHENTICATOR) { + if (authenticator.name === LocalAuthenticatorConstants.AUTHENTICATOR_NAMES + .ACTIVE_SESSION_LIMIT_HANDLER_AUTHENTICATOR_NAME) { if (authenticationSteps[currentStep]?.options?.length !== 0) { return false; } @@ -298,7 +296,8 @@ export const Authenticators: FunctionComponent = ( ); - } else if (authenticator.name === IdentityProviderManagementConstants.SESSION_EXECUTOR_AUTHENTICATOR) { + } else if (authenticator.name === LocalAuthenticatorConstants.AUTHENTICATOR_NAMES + .ACTIVE_SESSION_LIMIT_HANDLER_AUTHENTICATOR_NAME) { return ( { InfoLabel } diff --git a/features/admin.applications.v1/constants/application-management.ts b/features/admin.applications.v1/constants/application-management.ts index ab2df168152..a28c69aa351 100644 --- a/features/admin.applications.v1/constants/application-management.ts +++ b/features/admin.applications.v1/constants/application-management.ts @@ -387,7 +387,7 @@ export class ApplicationManagementConstants { public static readonly TOTP_HANDLERS: string[] = [ ...ApplicationManagementConstants.FIRST_FACTOR_AUTHENTICATORS, ...ApplicationManagementConstants.SOCIAL_AUTHENTICATORS, - IdentityProviderManagementConstants.MAGIC_LINK_AUTHENTICATOR, + LocalAuthenticatorConstants.AUTHENTICATOR_NAMES.MAGIC_LINK_AUTHENTICATOR_NAME, FederatedAuthenticatorConstants.AUTHENTICATOR_IDS.OIDC_AUTHENTICATOR_ID, FederatedAuthenticatorConstants.AUTHENTICATOR_NAMES.OIDC_AUTHENTICATOR_NAME, ConnectionManagementConstants.SAML_AUTHENTICATOR_ID, diff --git a/features/admin.authentication-flow-builder.v1/components/nodes/sign-in-box-node/fragments/active-sessions-limit-fragment.tsx b/features/admin.authentication-flow-builder.v1/components/nodes/sign-in-box-node/fragments/active-sessions-limit-fragment.tsx index 6964b92d655..2089d3527a7 100644 --- a/features/admin.authentication-flow-builder.v1/components/nodes/sign-in-box-node/fragments/active-sessions-limit-fragment.tsx +++ b/features/admin.authentication-flow-builder.v1/components/nodes/sign-in-box-node/fragments/active-sessions-limit-fragment.tsx @@ -1,5 +1,5 @@ /** - * Copyright (c) 2023, WSO2 LLC. (https://www.wso2.com). + * Copyright (c) 2023-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 @@ -18,9 +18,7 @@ import Checkbox from "@oxygen-ui/react/Checkbox"; import Typography from "@oxygen-ui/react/Typography"; -import { - IdentityProviderManagementConstants -} from "@wso2is/admin.identity-providers.v1/constants/identity-provider-management-constants"; +import { LocalAuthenticatorConstants } from "@wso2is/admin.connections.v1/constants/local-authenticator-constants"; import { IdentifiableComponentInterface } from "@wso2is/core/models"; import React, { MouseEvent, ReactElement } from "react"; import { useTranslation } from "react-i18next"; @@ -118,7 +116,8 @@ const ActiveSessionsLimitFragment = (props: ActiveSessionsLimitFragmentPropsInte ) => { onOptionRemove(event, { - toRemove: IdentityProviderManagementConstants.SESSION_EXECUTOR_AUTHENTICATOR + toRemove: LocalAuthenticatorConstants.AUTHENTICATOR_NAMES + .ACTIVE_SESSION_LIMIT_HANDLER_AUTHENTICATOR_NAME }); } } optionRemoveTooltipContent={ t("authenticationFlow:nodes.signIn.controls.optionRemoveTooltipContent") } diff --git a/features/admin.authentication-flow-builder.v1/components/nodes/sign-in-box-node/sign-in-box-node.tsx b/features/admin.authentication-flow-builder.v1/components/nodes/sign-in-box-node/sign-in-box-node.tsx index b85eb1b22ad..fa24dcc3db4 100644 --- a/features/admin.authentication-flow-builder.v1/components/nodes/sign-in-box-node/sign-in-box-node.tsx +++ b/features/admin.authentication-flow-builder.v1/components/nodes/sign-in-box-node/sign-in-box-node.tsx @@ -241,8 +241,10 @@ export const SignInBoxNode: FunctionComponent = ( basicSignInOption = IdentityProviderManagementConstants.BASIC_AUTHENTICATOR; } else if (option.authenticator === IdentityProviderManagementConstants.IDENTIFIER_FIRST_AUTHENTICATOR) { basicSignInOption = IdentityProviderManagementConstants.IDENTIFIER_FIRST_AUTHENTICATOR; - } else if (option.authenticator === IdentityProviderManagementConstants.SESSION_EXECUTOR_AUTHENTICATOR) { - basicSignInOption = IdentityProviderManagementConstants.SESSION_EXECUTOR_AUTHENTICATOR; + } else if (option.authenticator === LocalAuthenticatorConstants.AUTHENTICATOR_NAMES + .ACTIVE_SESSION_LIMIT_HANDLER_AUTHENTICATOR_NAME) { + basicSignInOption = LocalAuthenticatorConstants.AUTHENTICATOR_NAMES + .ACTIVE_SESSION_LIMIT_HANDLER_AUTHENTICATOR_NAME; } if (filteredOptions.length === 1) { @@ -427,7 +429,8 @@ export const SignInBoxNode: FunctionComponent = ( ); } - if (activeBasicSignInOption === IdentityProviderManagementConstants.SESSION_EXECUTOR_AUTHENTICATOR) { + if (activeBasicSignInOption === LocalAuthenticatorConstants.AUTHENTICATOR_NAMES + .ACTIVE_SESSION_LIMIT_HANDLER_AUTHENTICATOR_NAME) { return ( <> = ( [ IdentityProviderManagementConstants.TOTP_AUTHENTICATOR, LocalAuthenticatorConstants.AUTHENTICATOR_NAMES.BACKUP_CODE_AUTHENTICATOR_NAME, - IdentityProviderManagementConstants.SESSION_EXECUTOR_AUTHENTICATOR + LocalAuthenticatorConstants.AUTHENTICATOR_NAMES.ACTIVE_SESSION_LIMIT_HANDLER_AUTHENTICATOR_NAME ].includes(option.authenticator) ) { shouldShowSubjectIdentifierCheck = false; @@ -553,7 +556,8 @@ export const SignInBoxNode: FunctionComponent = ( ) } { (getBasicSignInOption() !== - IdentityProviderManagementConstants.SESSION_EXECUTOR_AUTHENTICATOR) + LocalAuthenticatorConstants.AUTHENTICATOR_NAMES + .ACTIVE_SESSION_LIMIT_HANDLER_AUTHENTICATOR_NAME) && (