From 74fa84dea502a4fe10b071488e10a1204cff74c8 Mon Sep 17 00:00:00 2001 From: edalex-yinzi Date: Wed, 4 Dec 2024 14:54:07 +1100 Subject: [PATCH 1/2] fix: validate API secret field for other platform if the initial platform is OKTA --- .../settings/Integrations/oidc/OidcSettings.tsx | 3 ++- .../Integrations/oidc/OidcSettingsHelper.tsx | 14 +++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/react-front-end/tsrc/settings/Integrations/oidc/OidcSettings.tsx b/react-front-end/tsrc/settings/Integrations/oidc/OidcSettings.tsx index 1e3e1fd9b2..082c95d416 100644 --- a/react-front-end/tsrc/settings/Integrations/oidc/OidcSettings.tsx +++ b/react-front-end/tsrc/settings/Integrations/oidc/OidcSettings.tsx @@ -317,7 +317,8 @@ const OidcSettings = ({ apiDetails, onApiDetailsChange, showValidationErrors, - serverHasConfiguration, + // OKTA platform doesn't have client secret field which means there is no secret configuration in the server. + serverHasConfiguration && initialIdpDetails.platform !== "OKTA", ); const handleOnSave = async () => { diff --git a/react-front-end/tsrc/settings/Integrations/oidc/OidcSettingsHelper.tsx b/react-front-end/tsrc/settings/Integrations/oidc/OidcSettingsHelper.tsx index 8056a57513..c7c3351f1a 100644 --- a/react-front-end/tsrc/settings/Integrations/oidc/OidcSettingsHelper.tsx +++ b/react-front-end/tsrc/settings/Integrations/oidc/OidcSettingsHelper.tsx @@ -309,7 +309,7 @@ const commonApiDetails = ( onChange: (key: string, value: unknown) => void, showValidationErrors: boolean, apiDetails: ApiDetails, - isConfigured: boolean, + isSecreteConfigured: boolean, ): Record => { const { platform, apiUrl, apiClientId } = apiDetails; // apiClientSecret is not exist in OktaApiDetails. @@ -353,7 +353,7 @@ const commonApiDetails = ( desc: apiClientSecretDesc, required: true, // Validation is not required for updating but required for the initial creation. - validate: isConfigured ? constTrue : isNonEmptyString, + validate: isSecreteConfigured ? constTrue : isNonEmptyString, component: passwordTextFiled({ name: apiClientSecretLabel, value: apiClientSecret, @@ -361,9 +361,9 @@ const commonApiDetails = ( required: true, onChange: (value) => onChange("apiClientSecret", value), showValidationErrors, - validate: isConfigured ? constTrue : isNonEmptyString, + validate: isSecreteConfigured ? constTrue : isNonEmptyString, errorMessage: missingValue, - placeholder: isConfigured ? passwordMask : undefined, + placeholder: isSecreteConfigured ? passwordMask : undefined, }), }, }; @@ -393,13 +393,13 @@ export const generatePlatform = ( * @param apiDetails The value of the platform specific details. * @param apiDetailsOnChange Function to be called when a platform specific field is changed. * @param showValidationErrors Whether to show validation errors for each field. - * @param isConfigured Whether the server already has the API details. + * @param isSecreteConfigured Whether the server already has the API secrete. */ export const generateApiDetails = ( apiDetails: ApiDetails, apiDetailsOnChange: (key: string, value: unknown) => void, showValidationErrors: boolean, - isConfigured: boolean, + isSecreteConfigured: boolean, ): Record => { const platform = apiDetails.platform; @@ -407,7 +407,7 @@ export const generateApiDetails = ( apiDetailsOnChange, showValidationErrors, apiDetails, - isConfigured, + isSecreteConfigured, ); const { apiUrl, apiClientId, apiClientSecret } = apiCommonFields; From 38730ae8d51b04906d1b343b3f7eba49f5e36767 Mon Sep 17 00:00:00 2001 From: edalex-yinzi Date: Wed, 4 Dec 2024 15:04:40 +1100 Subject: [PATCH 2/2] chore: fix typo secret --- .../Integrations/oidc/OidcSettingsHelper.tsx | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/react-front-end/tsrc/settings/Integrations/oidc/OidcSettingsHelper.tsx b/react-front-end/tsrc/settings/Integrations/oidc/OidcSettingsHelper.tsx index c7c3351f1a..baf45865ee 100644 --- a/react-front-end/tsrc/settings/Integrations/oidc/OidcSettingsHelper.tsx +++ b/react-front-end/tsrc/settings/Integrations/oidc/OidcSettingsHelper.tsx @@ -309,7 +309,7 @@ const commonApiDetails = ( onChange: (key: string, value: unknown) => void, showValidationErrors: boolean, apiDetails: ApiDetails, - isSecreteConfigured: boolean, + isSecretConfigured: boolean, ): Record => { const { platform, apiUrl, apiClientId } = apiDetails; // apiClientSecret is not exist in OktaApiDetails. @@ -353,7 +353,7 @@ const commonApiDetails = ( desc: apiClientSecretDesc, required: true, // Validation is not required for updating but required for the initial creation. - validate: isSecreteConfigured ? constTrue : isNonEmptyString, + validate: isSecretConfigured ? constTrue : isNonEmptyString, component: passwordTextFiled({ name: apiClientSecretLabel, value: apiClientSecret, @@ -361,9 +361,9 @@ const commonApiDetails = ( required: true, onChange: (value) => onChange("apiClientSecret", value), showValidationErrors, - validate: isSecreteConfigured ? constTrue : isNonEmptyString, + validate: isSecretConfigured ? constTrue : isNonEmptyString, errorMessage: missingValue, - placeholder: isSecreteConfigured ? passwordMask : undefined, + placeholder: isSecretConfigured ? passwordMask : undefined, }), }, }; @@ -393,13 +393,13 @@ export const generatePlatform = ( * @param apiDetails The value of the platform specific details. * @param apiDetailsOnChange Function to be called when a platform specific field is changed. * @param showValidationErrors Whether to show validation errors for each field. - * @param isSecreteConfigured Whether the server already has the API secrete. + * @param isSecretConfigured Whether the server already has the API secrete. */ export const generateApiDetails = ( apiDetails: ApiDetails, apiDetailsOnChange: (key: string, value: unknown) => void, showValidationErrors: boolean, - isSecreteConfigured: boolean, + isSecretConfigured: boolean, ): Record => { const platform = apiDetails.platform; @@ -407,7 +407,7 @@ export const generateApiDetails = ( apiDetailsOnChange, showValidationErrors, apiDetails, - isSecreteConfigured, + isSecretConfigured, ); const { apiUrl, apiClientId, apiClientSecret } = apiCommonFields;