From 9d167e25a17b6037d92639409db9bedbe91d5707 Mon Sep 17 00:00:00 2001 From: Ankita Kinger Date: Mon, 31 Mar 2025 18:33:11 +0530 Subject: [PATCH] chore: Updating google authentication config to support Multi Org flow on EE (#39985) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Description Updating google authentication config to support Multi Organization flow on EE for an instance. Fixes # ## Automation /ok-to-test tags="@tag.Settings" ### :mag: Cypress test results > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: > Commit: 006c20438f26bbc2015dab51be610f42c4b9f0c3 > Cypress dashboard. > Tags: `@tag.Settings` > Spec: >
Mon, 31 Mar 2025 12:22:20 UTC ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [ ] No ## Summary by CodeRabbit - **Style** - Updated authentication messaging to use “organization” instead of “workspace” for clearer communication. - **New Features** - Streamlined Google authentication configuration in the admin settings for a more modular setup. - Adjusted the admin interface to conditionally display disconnect options based on the current billing configuration. --- app/client/src/ce/constants/messages.ts | 10 +- .../AdminSettings/config/authentication.tsx | 115 +++++++++--------- .../src/hooks/useIsCloudBillingEnabled.ts | 6 +- .../src/pages/AdminSettings/SettingsForm.tsx | 4 +- 4 files changed, 69 insertions(+), 66 deletions(-) diff --git a/app/client/src/ce/constants/messages.ts b/app/client/src/ce/constants/messages.ts index a39290d43c..66d03e0491 100644 --- a/app/client/src/ce/constants/messages.ts +++ b/app/client/src/ce/constants/messages.ts @@ -1492,15 +1492,15 @@ export const DISCONNECT_AUTH_ERROR = () => "Cannot disconnect the only connected authentication method."; export const MANDATORY_FIELDS_ERROR = () => "Mandatory fields cannot be empty"; export const FORM_LOGIN_DESC = () => - "Enable your workspace to sign in with Appsmith Form."; + "Enable your organization to sign in with Appsmith Form."; export const GOOGLE_AUTH_DESC = () => - "Enable your workspace to sign in with Google (OAuth 2.0) single sign-on (SSO)."; + "Enable your organization to sign in with Google (OAuth 2.0) single sign-on (SSO)."; export const GITHUB_AUTH_DESC = () => - "Enable your workspace to sign in with GitHub (OAuth 2.0) single sign-on (SSO)."; + "Enable your organization to sign in with GitHub (OAuth 2.0) single sign-on (SSO)."; export const SAML_AUTH_DESC = () => - "Enable your workspace to sign in with your preferred SAML2 compliant provider."; + "Enable your organization to sign in with your preferred SAML2 compliant provider."; export const OIDC_AUTH_DESC = () => - "Enable your workspace to sign in with your preferred OIDC compliant provider."; + "Enable your organization to sign in with your preferred OIDC compliant provider."; export const SAVE_BUTTON = () => "Save"; export const SAVE_AND_RESTART_BUTTON = () => "Save & Restart"; export const SAVE_AND_REFRESH_BUTTON = () => "Save & Refresh"; diff --git a/app/client/src/ce/pages/AdminSettings/config/authentication.tsx b/app/client/src/ce/pages/AdminSettings/config/authentication.tsx index b7fbb2a3f6..947c6ae348 100644 --- a/app/client/src/ce/pages/AdminSettings/config/authentication.tsx +++ b/app/client/src/ce/pages/AdminSettings/config/authentication.tsx @@ -37,9 +37,10 @@ import store from "store"; const featureFlags = selectFeatureFlags(store.getState()); import { getAppsmithConfigs } from "ee/configs"; +import type { Setting } from "./types"; const { mailEnabled } = getAppsmithConfigs(); -const FormAuth: AdminConfigType = { +export const FormAuth: AdminConfigType = { type: SettingCategories.FORM_AUTH, categoryType: CategoryType.GENERAL, controlType: SettingTypes.GROUP, @@ -141,6 +142,62 @@ const FormAuth: AdminConfigType = { ], }; +export const SingleOrgGoogleAuthSettings: Setting[] = [ + { + id: "APPSMITH_OAUTH2_GOOGLE_READ_MORE", + category: SettingCategories.GOOGLE_AUTH, + controlType: SettingTypes.CALLOUT, + label: "How to configure?", + url: GOOGLE_SIGNUP_SETUP_DOC, + }, + { + id: "APPSMITH_OAUTH2_GOOGLE_JS_ORIGIN_URL", + category: SettingCategories.GOOGLE_AUTH, + controlType: SettingTypes.UNEDITABLEFIELD, + label: "JavaScript origin URL", + fieldName: "js-origin-url-form", + value: "", + tooltip: + "This URL will be used while configuring the Google OAuth Client ID's authorized JavaScript origins", + helpText: "Paste this URL in your Google developer console.", + }, + { + id: "APPSMITH_OAUTH2_GOOGLE_REDIRECT_URL", + category: SettingCategories.GOOGLE_AUTH, + controlType: SettingTypes.UNEDITABLEFIELD, + label: "Redirect URL", + fieldName: "redirect-url-form", + value: "/login/oauth2/code/google", + tooltip: + "This URL will be used while configuring the Google OAuth Client ID's authorized redirect URIs", + helpText: "Paste this URL in your Google developer console.", + }, + { + id: "APPSMITH_OAUTH2_GOOGLE_CLIENT_ID", + category: SettingCategories.GOOGLE_AUTH, + controlType: SettingTypes.TEXTINPUT, + controlSubType: SettingSubtype.TEXT, + label: "Client ID", + isRequired: true, + }, + { + id: "APPSMITH_OAUTH2_GOOGLE_CLIENT_SECRET", + category: SettingCategories.GOOGLE_AUTH, + controlType: SettingTypes.TEXTINPUT, + controlSubType: SettingSubtype.TEXT, + label: "Client secret", + isRequired: true, + }, + { + id: "APPSMITH_SIGNUP_ALLOWED_DOMAINS", + category: SettingCategories.GOOGLE_AUTH, + controlType: SettingTypes.TEXTINPUT, + controlSubType: SettingSubtype.TEXT, + label: "Allowed domains", + placeholder: "domain1.com, domain2.com", + }, +]; + export const GoogleAuth: AdminConfigType = { type: SettingCategories.GOOGLE_AUTH, categoryType: CategoryType.GENERAL, @@ -148,61 +205,7 @@ export const GoogleAuth: AdminConfigType = { title: "Google authentication", subText: createMessage(GOOGLE_AUTH_DESC), canSave: true, - settings: [ - { - id: "APPSMITH_OAUTH2_GOOGLE_READ_MORE", - category: SettingCategories.GOOGLE_AUTH, - controlType: SettingTypes.CALLOUT, - label: "How to configure?", - url: GOOGLE_SIGNUP_SETUP_DOC, - }, - { - id: "APPSMITH_OAUTH2_GOOGLE_JS_ORIGIN_URL", - category: SettingCategories.GOOGLE_AUTH, - controlType: SettingTypes.UNEDITABLEFIELD, - label: "JavaScript origin URL", - fieldName: "js-origin-url-form", - value: "", - tooltip: - "This URL will be used while configuring the Google OAuth Client ID's authorized JavaScript origins", - helpText: "Paste this URL in your Google developer console.", - }, - { - id: "APPSMITH_OAUTH2_GOOGLE_REDIRECT_URL", - category: SettingCategories.GOOGLE_AUTH, - controlType: SettingTypes.UNEDITABLEFIELD, - label: "Redirect URL", - fieldName: "redirect-url-form", - value: "/login/oauth2/code/google", - tooltip: - "This URL will be used while configuring the Google OAuth Client ID's authorized redirect URIs", - helpText: "Paste this URL in your Google developer console.", - }, - { - id: "APPSMITH_OAUTH2_GOOGLE_CLIENT_ID", - category: SettingCategories.GOOGLE_AUTH, - controlType: SettingTypes.TEXTINPUT, - controlSubType: SettingSubtype.TEXT, - label: "Client ID", - isRequired: true, - }, - { - id: "APPSMITH_OAUTH2_GOOGLE_CLIENT_SECRET", - category: SettingCategories.GOOGLE_AUTH, - controlType: SettingTypes.TEXTINPUT, - controlSubType: SettingSubtype.TEXT, - label: "Client secret", - isRequired: true, - }, - { - id: "APPSMITH_SIGNUP_ALLOWED_DOMAINS", - category: SettingCategories.GOOGLE_AUTH, - controlType: SettingTypes.TEXTINPUT, - controlSubType: SettingSubtype.TEXT, - label: "Allowed domains", - placeholder: "domain1.com, domain2.com", - }, - ], + settings: SingleOrgGoogleAuthSettings, }; export const GithubAuth: AdminConfigType = { diff --git a/app/client/src/hooks/useIsCloudBillingEnabled.ts b/app/client/src/hooks/useIsCloudBillingEnabled.ts index 370e5e2df5..bbdf7ff232 100644 --- a/app/client/src/hooks/useIsCloudBillingEnabled.ts +++ b/app/client/src/hooks/useIsCloudBillingEnabled.ts @@ -1,15 +1,13 @@ import { useSelector } from "react-redux"; - -import { getAppsmithConfigs } from "ee/configs"; import { getIsCloudBillingFeatureFlagEnabled } from "selectors/cloudBillingSelectors"; const useIsCloudBillingEnabled = () => { - const { cloudHosting } = getAppsmithConfigs(); const isCloudBillingFeatureFlagEnabled = useSelector( getIsCloudBillingFeatureFlagEnabled, ); - return isCloudBillingFeatureFlagEnabled && cloudHosting; + return isCloudBillingFeatureFlagEnabled; }; +// add cloudHosting check later: Ankita export { useIsCloudBillingEnabled }; diff --git a/app/client/src/pages/AdminSettings/SettingsForm.tsx b/app/client/src/pages/AdminSettings/SettingsForm.tsx index bec37d5745..386222b971 100644 --- a/app/client/src/pages/AdminSettings/SettingsForm.tsx +++ b/app/client/src/pages/AdminSettings/SettingsForm.tsx @@ -50,6 +50,7 @@ import { } from "ee/selectors/organizationSelectors"; import { updateOrganizationConfig } from "ee/actions/organizationActions"; import { organizationConfigConnection } from "ee/constants/organizationConstants"; +import { useIsCloudBillingEnabled } from "hooks"; interface FormProps { settings: Record; @@ -91,6 +92,7 @@ export function SettingsForm( const socialLoginList = useSelector(getThirdPartyAuths); const [initialFormLoginEnabled, setInitialFormLoginEnabled] = useState(isFormLoginEnabled); + const isMultiOrgEnabled = useIsCloudBillingEnabled(); const updatedOrganizationSettings = useMemo( () => Object.keys(props.settings).filter((s) => isOrganizationConfig(s)), @@ -339,7 +341,7 @@ export function SettingsForm( valid={props.valid} /> )} - {details?.isConnected && ( + {details?.isConnected && !isMultiOrgEnabled && ( disconnect(settingsDetails)} subHeader={createMessage(DISCONNECT_SERVICE_SUBHEADER)}