Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

feat(frontend): migrate IDPs page to React (#19775)

Danny Xud88566dfb5ed
diff --git a/frontend/src/components/IdentityProvider/IdentityProviderCreateWizard.vue b/frontend/src/components/IdentityProvider/IdentityProviderCreateWizard.vue
deleted file mode 100644
index 1c1093cc72..0000000000
--- a/frontend/src/components/IdentityProvider/IdentityProviderCreateWizard.vue
+++ /dev/null
@@ -1,1000 +0,0 @@
-<template>
- <Drawer :show="props.show" @update:show="$emit('update:show', $event)">
- <DrawerContent
- :title="$t('settings.sso.create')"
- class="w-5xl max-w-[100vw]"
- :closable="true"
- >
- <div class="w-full mx-auto flex flex-col gap-y-6">
- <!-- Steps Navigation -->
- <NSteps :current="currentStep" size="medium">
- <NStep :title="$t('settings.sso.form.type')" />
- <NStep
- v-if="selectedType === IdentityProviderType.OAUTH2"
- :title="$t('settings.sso.form.use-template')"
- />
- <NStep :title="$t('common.general')" />
- <NStep :title="$t('settings.sso.form.configuration')" />
- <NStep :title="$t('settings.sso.form.user-information-mapping')" />
- </NSteps>
- <!-- Step Content -->
- <div
- class="bg-white rounded-lg border border-gray-200 px-2 sm:px-6 pt-6 pb-10"
- >
- <!-- Step 1: Select Provider Type -->
- <div v-if="currentStep === 1" class="flex flex-col gap-y-6">
- <div class="text-center flex flex-col gap-y-2">
- <h2 class="text-2xl font-bold text-gray-900">
- {{ $t("settings.sso.form.type") }}
- </h2>
- <p class="text-gray-600">
- {{ $t("settings.sso.form.type-description") }}
- </p>
- </div>
-
- <div class="max-w-2xl mx-auto">
- <NRadioGroup
- v-model:value="selectedType"
- size="large"
- class="flex flex-col w-full"
- >
- <div
- v-for="item in identityProviderTypeList"
- :key="item.type"
- class="border border-gray-200 rounded-lg mb-4 p-4 hover:border-gray-300 transition-colors"
- :class="{
- 'border-blue-500 bg-blue-50': selectedType === item.type,
- }"
- >
- <NRadio
- :value="item.type"
- :disabled="!subscriptionStore.hasFeature(item.feature)"
- class="w-full"
- >
- <div class="flex items-start gap-x-3 w-full">
- <component
- :is="getProviderIcon(item.type)"
- class="w-6 h-6 mt-1 shrink-0"
- :stroke-width="1.5"
- />
- <div class="flex-1">
- <div class="flex items-center gap-x-2">
- <span class="text-lg font-medium text-gray-900">
- {{ identityProviderTypeToString(item.type) }}
- </span>
- <FeatureBadge :feature="item.feature" />
- </div>
- <p class="text-sm text-gray-600 mt-1">
- {{ getProviderDescription(item.type) }}
- </p>
- </div>
- </div>
- </NRadio>
- </div>
- </NRadioGroup>
-
- <!-- External URL Warning -->
- <MissingExternalURLAttention
- v-if="
- selectedType === IdentityProviderType.OAUTH2 ||
- selectedType === IdentityProviderType.OIDC
- "
- class="mt-6"
- />
- </div>
- </div>
-
- <!-- Step 2: Select OAuth2 Template (only for OAuth2) -->
- <div
- v-else-if="
- currentStep === 2 && selectedType === IdentityProviderType.OAUTH2
- "
- class="flex flex-col gap-y-6"
- >
- <div class="text-center flex flex-col gap-y-2">
- <h2 class="text-2xl font-bold text-gray-900">
- {{ $t("settings.sso.form.use-template") }}
- </h2>
- <p class="text-gray-600">
- {{ $t("settings.sso.form.template-description") }}
- </p>
- </div>
-
- <div class="max-w-3xl mx-auto">
- <NRadioGroup
- :value="selectedTemplate?.title"
- @update:value="
- (value) => {
- const template = templateList.find(
- (t) => t.title === value
- );
- if (template) handleTemplateSelect(template);
- }
- "
- size="large"
- class="grid! grid-cols-1 sm:grid-cols-2 gap-4"
- >
- <div
- v-for="template in templateList"
- :key="template.title"
- class="border border-gray-200 rounded-lg p-4 hover:border-gray-300 transition-colors"
- :class="{
- 'border-blue-500 bg-blue-50':
- selectedTemplate?.title === template.title,
- }"
- >
- <NRadio
- :value="template.title"
- :disabled="!subscriptionStore.hasFeature(template.feature)"
- class="w-full"
- >
- <div class="flex items-center gap-x-3">
- <component
- :is="getTemplateIcon(template.title)"
- class="w-8 h-8 shrink-0"
- :stroke-width="1"
- />
- <div class="flex-1">
- <div class="flex items-center gap-x-2">
- <span class="text-base font-medium text-gray-900">
- {{ template.title }}
- </span>
- <FeatureBadge :feature="template.feature" />
- </div>
- <p class="text-sm text-gray-600">
- {{ getTemplateDescription(template.title) }}
- </p>
- </div>
- </div>
- </NRadio>
- </div>
- </NRadioGroup>
- </div>
- </div>
-
- <!-- Step 3: Basic Information -->
- <div
- v-else-if="
- currentStep ===
- (selectedType === IdentityProviderType.OAUTH2 ? 3 : 2)
- "
- class="flex flex-col gap-y-6"
- >
- <div class="text-center flex flex-col gap-y-2">
- <h2 class="text-2xl font-bold text-gray-900">
- {{ $t("common.general") }}
- </h2>
- <p class="text-gray-600">
- {{ $t("settings.sso.form.general-setting-description") }}
- </p>
- </div>
-
- <div class="max-w-2xl mx-auto flex flex-col gap-y-6">
- <div>
- <label class="block text-base font-semibold text-gray-800 mb-2">
- {{ $t("settings.sso.form.name") }}
- <RequiredStar />
- </label>
- <BBTextField
- v-model:value="identityProvider.title"
- required
- size="large"
- class="w-full text-base mb-2"
- :placeholder="$t('settings.sso.form.name-description')"
- />
- <ResourceIdField
- ref="resourceIdField"
- resource-type="idp"
- v-model:value="resourceIdValue"
- :suffix="true"
- :resource-title="identityProvider.title"
- :fetch-resource="
- (id) =>
- identityProviderStore.getOrFetchIdentityProviderByName(
- `${idpNamePrefix}${id}`,
- true /* silent */
- )
- "
- />
- </div>
-
- <div>
- <label class="block text-base font-semibold text-gray-800 mb-2">
- {{ $t("settings.sso.form.domain") }}
- </label>
- <BBTextField
- v-model:value="identityProvider.domain"
- :disabled="selectedTemplate?.domainDisabled"
- size="large"
- class="w-full text-base"
- :placeholder="$t('settings.sso.form.domain-description')"
- />
- <p class="text-sm text-gray-600 mt-1">
- {{ $t("settings.sso.form.domain-optional-hint") }}
- </p>
- </div>
- </div>
- </div>
-
- <!-- Step 4: Provider Configuration -->
- <div
- v-else-if="
- currentStep ===
- (selectedType === IdentityProviderType.OAUTH2 ? 4 : 3)
- "
- class="flex flex-col gap-y-6"
- >
- <div class="text-center flex flex-col gap-y-2">
- <h2 class="text-2xl font-bold text-gray-900">
- {{ $t("settings.sso.form.configuration") }}
- </h2>
- <p class="text-gray-600">
- {{ $t("settings.sso.form.configuration-description") }}
- </p>
- </div>
-
- <div class="max-w-3xl mx-auto">
- <!-- External URL Info -->
- <IdentityProviderExternalURL
- v-if="
- selectedType === IdentityProviderType.OAUTH2 ||
- selectedType === IdentityProviderType.OIDC
- "
- :type="selectedType"
- class="mb-6"
- />
-
- <!-- Configuration Form based on type -->
- <IdentityProviderForm
- :identity-provider="identityProvider"
- :provider-type="selectedType"
- :config-for-oauth2="configForOAuth2"
- :config-for-oidc="configForOIDC"
- :config-for-ldap="configForLDAP"
- :scopes-string="scopesStringOfConfig"
- @update:config-for-oauth2="configForOAuth2 = $event"
- @update:config-for-oidc="configForOIDC = $event"
- @update:config-for-ldap="configForLDAP = $event"
- @update:scopes-string="scopesStringOfConfig = $event"
- />
- </div>
- </div>
-
- <!-- Step 5: User Information Mapping -->
- <div
- v-else-if="
- currentStep ===
- (selectedType === IdentityProviderType.OAUTH2 ? 5 : 4)
- "
- class="flex flex-col gap-y-6"
- >
- <div class="text-center flex flex-col gap-y-2">
- <h2 class="text-2xl font-bold text-gray-900">
- {{ $t("settings.sso.form.user-information-mapping") }}
- </h2>
- <p class="text-gray-600">
- {{
- $t("settings.sso.form.user-information-mapping-description")
- }}
- <LearnMoreLink
- class="ml-1"
- url="https://docs.bytebase.com/administration/sso/oauth2#user-information-field-mapping?source=console"
- />
- </p>
- </div>
-
- <div class="max-w-2xl mx-auto flex flex-col gap-y-6">
- <div class="grid grid-cols-[256px_1fr] gap-4 items-center">
- <BBTextField
- v-model:value="fieldMapping.identifier"
- size="large"
- class="w-full text-base"
- :placeholder="$t('settings.sso.form.identifier-placeholder')"
- />
- <div class="flex flex-row justify-start items-center text-base">
- <ArrowRightIcon class="mx-2 h-auto w-5 text-gray-400" />
- <p
- class="flex flex-row justify-start items-center font-semibold text-gray-800"
- >
- {{ $t("settings.sso.form.identifier") }}
- <RequiredStar />
- <NTooltip>
- <template #trigger>
- <InfoIcon class="ml-1 w-4 h-auto text-blue-500" />
- </template>
- {{ $t("settings.sso.form.identifier-tips") }}
- </NTooltip>
- </p>
- </div>
- </div>
-
- <div class="grid grid-cols-[256px_1fr] gap-4 items-center">
- <BBTextField
- v-model:value="fieldMapping.displayName"
- size="large"
- class="w-full text-base"
- :placeholder="
- $t('settings.sso.form.display-name-placeholder')
- "
- />
- <div class="flex flex-row justify-start items-center text-base">
- <ArrowRightIcon class="mx-2 h-auto w-5 text-gray-400" />
- <p class="font-semibold text-gray-800">
- {{ $t("settings.sso.form.display-name") }}
- </p>
- </div>
- </div>
-
- <div class="grid grid-cols-[256px_1fr] gap-4 items-center">
- <BBTextField
- v-model:value="fieldMapping.phone"
- size="large"
- class="w-full text-base"
- :placeholder="$t('settings.sso.form.phone-placeholder')"
- />
- <div class="flex flex-row justify-start items-center text-base">
- <ArrowRightIcon class="mx-2 h-auto w-5 text-gray-400" />
- <p class="font-semibold text-gray-800">
- {{ $t("settings.sso.form.phone") }}
- </p>
- </div>
- </div>
-
- <div
- v-if="selectedType === IdentityProviderType.OIDC"
- class="grid grid-cols-[256px_1fr] gap-4 items-center"
- >
- <BBTextField
- v-model:value="fieldMapping.groups"
- size="large"
- class="w-full text-base"
- :placeholder="$t('settings.sso.form.groups-placeholder')"
- />
- <div class="flex flex-row justify-start items-center text-base">
- <ArrowRightIcon class="mx-2 h-auto w-5 text-gray-400" />
- <p class="font-semibold text-gray-800">
- {{ $t("settings.sso.form.groups") }}
- </p>
- </div>
- </div>
-
- <div v-if="selectedType === IdentityProviderType.OIDC">
- <p class="text-sm text-gray-600">
- {{ $t("settings.sso.form.groups-description") }}
- </p>
- </div>
-
- <div>
- <TestConnection
- :disabled="!allowTestConnection"
- :size="'large'"
- :is-creating="true"
- :idp="idpToCreate"
- />
- </div>
- </div>
- </div>
- </div>
- </div>
-
- <template #footer>
- <div class="flex items-center justify-end gap-x-3">
- <NButton
- v-if="currentStep === 1"
- @click="$emit('update:show', false)"
- >
- {{ $t("common.cancel") }}
- </NButton>
- <NButton v-if="currentStep > 1" @click="handlePrevStep">
- {{ $t("common.back") }}
- </NButton>
- <NButton
- v-if="!isLastStep"
- type="primary"
- :disabled="!canProceedToNextStep"
- @click="handleNextStep"
- >
- {{ $t("common.next") }}
- </NButton>
- <NButton
- v-else
- type="primary"
- :disabled="!canCreate"
- :loading="isCreating"
- @click="handleCreate"
- >
- {{ $t("common.create") }}
- </NButton>
- </div>
- </template>
- </DrawerContent>
- </Drawer>
-</template>
-
-<script setup lang="ts">
-import { create as createProto } from "@bufbuild/protobuf";
-import { Code, ConnectError } from "@connectrpc/connect";
-import { head } from "lodash-es";
-import {
- ArrowRightIcon,
- BuildingIcon,
- ChromeIcon,
- DatabaseIcon,
- GithubIcon,
- GitlabIcon,
- InfoIcon,
- KeyIcon,
- ShieldCheckIcon,
-} from "lucide-vue-next";
-import {
- NButton,
- NRadio,
- NRadioGroup,
- NStep,
- NSteps,
- NTooltip,
-} from "naive-ui";
-import { computed, reactive, ref, watch } from "vue";
-import { useI18n } from "vue-i18n";
-import { BBTextField } from "@/bbkit";
-import { FeatureBadge } from "@/components/FeatureGuard";
-import LearnMoreLink from "@/components/LearnMoreLink.vue";
-import RequiredStar from "@/components/RequiredStar.vue";
-import { Drawer, DrawerContent } from "@/components/v2";
-import { MissingExternalURLAttention } from "@/components/v2/Form";
-import ResourceIdField from "@/components/v2/Form/ResourceIdField.vue";
-import { hasFeature, pushNotification, useSubscriptionV1Store } from "@/store";
-import { useIdentityProviderStore } from "@/store/modules/idp";
-import { idpNamePrefix } from "@/store/modules/v1/common";
-import type {
- FieldMapping,
- IdentityProvider,
- LDAPIdentityProviderConfig,
- OAuth2IdentityProviderConfig,
- OIDCIdentityProviderConfig,
-} from "@/types/proto-es/v1/idp_service_pb";
-import {
- FieldMappingSchema,
- IdentityProviderConfigSchema,
- IdentityProviderSchema,
- IdentityProviderType,
- LDAPIdentityProviderConfigSchema,
- OAuth2AuthStyle,
- OAuth2IdentityProviderConfigSchema,
- OIDCIdentityProviderConfigSchema,
-} from "@/types/proto-es/v1/idp_service_pb";
-import { PlanFeature } from "@/types/proto-es/v1/subscription_service_pb";
-import type { OAuth2IdentityProviderTemplate } from "@/utils";
-import { identityProviderTypeToString } from "@/utils";
-import IdentityProviderExternalURL from "./IdentityProviderExternalURL.vue";
-import IdentityProviderForm from "./IdentityProviderForm.vue";
-import TestConnection from "./TestConnection.vue";
-
-interface IdentityProviderTemplate extends OAuth2IdentityProviderTemplate {
- feature: PlanFeature;
- domainDisabled?: boolean;
-}
-
-const props = defineProps<{
- show: boolean;
-}>();
-
-const emit = defineEmits<{
- (e: "created", provider: IdentityProvider): void;
- (e: "update:show", show: boolean): void;
-}>();
-
-const { t } = useI18n();
-const identityProviderStore = useIdentityProviderStore();
-const subscriptionStore = useSubscriptionV1Store();
-
-// State
-const currentStep = ref(1);
-const selectedType = ref<IdentityProviderType>(IdentityProviderType.OAUTH2);
-const selectedTemplate = ref<IdentityProviderTemplate>();
-const isCreating = ref(false);
-
-const identityProvider = ref<IdentityProvider>(
- createProto(IdentityProviderSchema, {})
-);
-const configForOAuth2 = ref<OAuth2IdentityProviderConfig>(
- createProto(OAuth2IdentityProviderConfigSchema, {
- authStyle: OAuth2AuthStyle.IN_PARAMS,
- })
-);
-const configForOIDC = ref<OIDCIdentityProviderConfig>(
- createProto(OIDCIdentityProviderConfigSchema, {
- authStyle: OAuth2AuthStyle.IN_PARAMS,
- })
-);
-const configForLDAP = ref<LDAPIdentityProviderConfig>(
- createProto(LDAPIdentityProviderConfigSchema, {
- port: 389,
- })
-);
-const scopesStringOfConfig = ref<string>("");
-const fieldMapping = reactive<FieldMapping>(
- createProto(FieldMappingSchema, {})
-);
-
-const resourceIdField = ref<InstanceType<typeof ResourceIdField>>();
-const resourceIdValue = ref<string>("");
-
-// Computed
-const idpToCreate = computed((): IdentityProvider => {
- const base = createProto(IdentityProviderSchema, {
- name: resourceIdField.value?.resourceId || resourceIdValue.value,
- title: identityProvider.value.title,
- domain: identityProvider.value.domain,
- type: selectedType.value,
- });
-
- if (selectedType.value === IdentityProviderType.OAUTH2) {
- base.config = createProto(IdentityProviderConfigSchema, {
- config: {
- case: "oauth2Config",
- value: createProto(OAuth2IdentityProviderConfigSchema, {
- ...configForOAuth2.value,
- scopes: scopesStringOfConfig.value.split(" ").filter(Boolean),
- fieldMapping: createProto(FieldMappingSchema, fieldMapping),
- }),
- },
- });
- } else if (selectedType.value === IdentityProviderType.OIDC) {
- base.config = createProto(IdentityProviderConfigSchema, {
- config: {
- case: "oidcConfig",
- value: createProto(OIDCIdentityProviderConfigSchema, {
- ...configForOIDC.value,
- scopes: scopesStringOfConfig.value.split(" ").filter(Boolean),
- fieldMapping: createProto(FieldMappingSchema, fieldMapping),
- }),
- },
- });
- } else if (selectedType.value === IdentityProviderType.LDAP) {
- base.config = createProto(IdentityProviderConfigSchema, {
- config: {
- case: "ldapConfig",
- value: createProto(LDAPIdentityProviderConfigSchema, {
- ...configForLDAP.value,
- fieldMapping: createProto(FieldMappingSchema, fieldMapping),
- }),
- },
- });
- }
-
- return base;
-});
-
-const resourceId = computed(() => {
- return resourceIdField.value?.resourceId || resourceIdValue.value || "";
-});
-
-const identityProviderTypeList = computed(() => {
- return [
- {
- type: IdentityProviderType.OAUTH2,
- feature: PlanFeature.FEATURE_GOOGLE_AND_GITHUB_SSO,
- },
- {
- type: IdentityProviderType.OIDC,
- feature: PlanFeature.FEATURE_ENTERPRISE_SSO,
- },
- {
- type: IdentityProviderType.LDAP,
- feature: PlanFeature.FEATURE_ENTERPRISE_SSO,
- },
- ];
-});
-
-const templateList = computed((): IdentityProviderTemplate[] => {
- return [
- {
- title: "Google",
- name: "",
- domain: "google.com",
- domainDisabled: !hasFeature(PlanFeature.FEATURE_ENTERPRISE_SSO),
- type: IdentityProviderType.OAUTH2,
- feature: PlanFeature.FEATURE_GOOGLE_AND_GITHUB_SSO,
- config: createProto(OAuth2IdentityProviderConfigSchema, {
- clientId: "",
- clientSecret: "",
- authUrl: "https://accounts.google.com/o/oauth2/v2/auth",
- tokenUrl: "https://oauth2.googleapis.com/token",
- userInfoUrl: "https://www.googleapis.com/oauth2/v2/userinfo",
- scopes: [
- "https://www.googleapis.com/auth/userinfo.email",
- "https://www.googleapis.com/auth/userinfo.profile",
- ],
- skipTlsVerify: false,
- authStyle: OAuth2AuthStyle.IN_PARAMS,
- fieldMapping: createProto(FieldMappingSchema, {
- identifier: "email",
- displayName: "name",
- phone: "",
- groups: "",
- }),
- }),
- },
- {
- title: "GitHub",
- name: "",
- domain: "github.com",
- domainDisabled: !hasFeature(PlanFeature.FEATURE_ENTERPRISE_SSO),
- type: IdentityProviderType.OAUTH2,
- feature: PlanFeature.FEATURE_GOOGLE_AND_GITHUB_SSO,
- config: createProto(OAuth2IdentityProviderConfigSchema, {
- clientId: "",
- clientSecret: "",
- authUrl: "https://github.com/login/oauth/authorize",
- tokenUrl: "https://github.com/login/oauth/access_token",
- userInfoUrl: "https://api.github.com/user",
- scopes: ["user"],
- skipTlsVerify: false,
- authStyle: OAuth2AuthStyle.IN_PARAMS,
- fieldMapping: createProto(FieldMappingSchema, {
- identifier: "email",
- displayName: "name",
- phone: "",
- groups: "",
- }),
- }),
- },
- {
- title: "GitLab",
- name: "",
- domain: "gitlab.com",
- type: IdentityProviderType.OAUTH2,
- feature: PlanFeature.FEATURE_ENTERPRISE_SSO,
- config: createProto(OAuth2IdentityProviderConfigSchema, {
- clientId: "",
- clientSecret: "",
- authUrl: "https://gitlab.com/oauth/authorize",
- tokenUrl: "https://gitlab.com/oauth/token",
- userInfoUrl: "https://gitlab.com/api/v4/user",
- scopes: ["read_user"],
- skipTlsVerify: false,
- authStyle: OAuth2AuthStyle.IN_PARAMS,
- fieldMapping: createProto(FieldMappingSchema, {
- identifier: "email",
- displayName: "name",
- phone: "",
- groups: "",
- }),
- }),
- },
- {
- title: "Microsoft Entra",
- name: "",
- domain: "",
- type: IdentityProviderType.OAUTH2,
- feature: PlanFeature.FEATURE_ENTERPRISE_SSO,
- config: createProto(OAuth2IdentityProviderConfigSchema, {
- clientId: "",
- clientSecret: "",
- authUrl:
- "https://login.microsoftonline.com/{uuid}/oauth2/v2.0/authorize",
- tokenUrl: "https://login.microsoftonline.com/{uuid}/oauth2/v2.0/token",
- userInfoUrl: "https://graph.microsoft.com/v1.0/me",
- scopes: ["user.read"],
- skipTlsVerify: false,
- authStyle: OAuth2AuthStyle.IN_PARAMS,
- fieldMapping: createProto(FieldMappingSchema, {
- identifier: "userPrincipalName",
- displayName: "displayName",
- phone: "",
- groups: "",
- }),
- }),
- },
- {
- title: "Custom",
- name: "",
- domain: "",
- type: IdentityProviderType.OAUTH2,
- feature: PlanFeature.FEATURE_ENTERPRISE_SSO,
- config: createProto(OAuth2IdentityProviderConfigSchema, {
- clientId: "",
- clientSecret: "",
- authUrl: "",
- tokenUrl: "",
- userInfoUrl: "",
- scopes: [],
- skipTlsVerify: false,
- authStyle: OAuth2AuthStyle.IN_PARAMS,
- fieldMapping: createProto(FieldMappingSchema, {
- identifier: "",
- displayName: "",
- phone: "",
- groups: "",
- }),
- }),
- },
- ];
-});
-
-const maxSteps = computed(() => {
- return selectedType.value === IdentityProviderType.OAUTH2 ? 5 : 4;
-});
-
-const isLastStep = computed(() => {
- return currentStep.value === maxSteps.value;
-});
-
-const canProceedToNextStep = computed(() => {
- switch (currentStep.value) {
- case 1:
- return !!selectedType.value;
- case 2:
- if (selectedType.value === IdentityProviderType.OAUTH2) {
- return !!selectedTemplate.value;
- }
- // For non-OAuth2, step 2 is basic info
- return !!(identityProvider.value.title && resourceId.value);
- case 3:
- if (selectedType.value === IdentityProviderType.OAUTH2) {
- // Basic info step for OAuth2
- return !!(identityProvider.value.title && resourceId.value);
- }
- // Configuration step for non-OAuth2
- return isConfigurationValid.value;
- case 4:
- if (selectedType.value === IdentityProviderType.OAUTH2) {
- // Configuration step for OAuth2
- return isConfigurationValid.value;
- }
- // Mapping step for non-OAuth2
- return !!fieldMapping.identifier;
- case 5:
- // Mapping step for OAuth2
- return !!fieldMapping.identifier;
- default:
- return false;
- }
-});
-
-const isConfigurationValid = computed(() => {
- if (selectedType.value === IdentityProviderType.OAUTH2) {
- return !!(
- configForOAuth2.value.clientId &&
- configForOAuth2.value.clientSecret &&
- configForOAuth2.value.authUrl &&
- configForOAuth2.value.tokenUrl &&
- configForOAuth2.value.userInfoUrl &&
- scopesStringOfConfig.value
- );
- } else if (selectedType.value === IdentityProviderType.OIDC) {
- return !!(
- configForOIDC.value.clientId &&
- configForOIDC.value.clientSecret &&
- configForOIDC.value.issuer &&
- scopesStringOfConfig.value
- );
- } else if (selectedType.value === IdentityProviderType.LDAP) {
- return !!(
- configForLDAP.value.host &&
- configForLDAP.value.port &&
- configForLDAP.value.bindDn &&
- configForLDAP.value.bindPassword &&
- configForLDAP.value.baseDn &&
- configForLDAP.value.userFilter
- );
- }
- return false;
-});
-
-const canCreate = computed(() => {
- return !!(
- identityProvider.value.title &&
- resourceId.value &&
- isConfigurationValid.value &&
- fieldMapping.identifier
- );
-});
-
-const allowTestConnection = computed(() => {
- return isConfigurationValid.value && fieldMapping.identifier;
-});
-
-// Methods
-const getProviderIcon = (type: IdentityProviderType) => {
- switch (type) {
- case IdentityProviderType.OAUTH2:
- return KeyIcon;
- case IdentityProviderType.OIDC:
- return ShieldCheckIcon;
- case IdentityProviderType.LDAP:
- return DatabaseIcon;
- default:
- return KeyIcon;
- }
-};
-
-const getProviderDescription = (type: IdentityProviderType) => {
- switch (type) {
- case IdentityProviderType.OAUTH2:
- return t("settings.sso.form.oauth2-description");
- case IdentityProviderType.OIDC:
- return t("settings.sso.form.oidc-description");
- case IdentityProviderType.LDAP:
- return t("settings.sso.form.ldap-description");
- default:
- return "";
- }
-};
-
-const getTemplateIcon = (title: string) => {
- switch (title.toLowerCase()) {
- case "google":
- return ChromeIcon;
- case "github":
- return GithubIcon;
- case "gitlab":
- return GitlabIcon;
- case "microsoft entra":
- return BuildingIcon;
- default:
- return KeyIcon;
- }
-};
-
-const getTemplateDescription = (title: string) => {
- switch (title.toLowerCase()) {
- case "google":
- return t("settings.sso.form.google-template-description");
- case "github":
- return t("settings.sso.form.github-template-description");
- case "gitlab":
- return t("settings.sso.form.gitlab-template-description");
- case "microsoft entra":
- return t("settings.sso.form.microsoft-entra-template-description");
- case "custom":
- return t("settings.sso.form.custom-template-description");
- default:
- return "";
- }
-};
-
-const handleTemplateSelect = (template: IdentityProviderTemplate) => {
- selectedTemplate.value = template;
- // Update title and domain from template
- identityProvider.value.title = template.title;
- identityProvider.value.domain = template.domain;
-
- if (template.type === IdentityProviderType.OAUTH2) {
- // Create a completely new object to ensure reactivity
- const newConfig = createProto(OAuth2IdentityProviderConfigSchema, {
- clientId: template.config.clientId || "",
- clientSecret: template.config.clientSecret || "",
- authUrl: template.config.authUrl || "",
- tokenUrl: template.config.tokenUrl || "",
- userInfoUrl: template.config.userInfoUrl || "",
- scopes: template.config.scopes || [],
- skipTlsVerify: template.config.skipTlsVerify || false,
- authStyle: template.config.authStyle || OAuth2AuthStyle.IN_PARAMS,
- fieldMapping:
- template.config.fieldMapping || createProto(FieldMappingSchema, {}),
- });
- configForOAuth2.value = newConfig;
-
- // Clear existing field mapping and assign new values
- Object.keys(fieldMapping).forEach((key) => {
- delete fieldMapping[key as keyof FieldMapping];
- });
- Object.assign(fieldMapping, template.config.fieldMapping || {});
-
- scopesStringOfConfig.value = template.config.scopes.join(" ");
- }
-};
-
-const handlePrevStep = () => {
- if (currentStep.value > 1) {
- currentStep.value--;
- }
-};
-
-const handleNextStep = () => {
- if (currentStep.value < maxSteps.value && canProceedToNextStep.value) {
- // Ensure resource ID is captured before moving to next step
- if (resourceIdField.value?.resourceId) {
- resourceIdValue.value = resourceIdField.value.resourceId;
- }
- currentStep.value++;
- }
-};
-
-const handleCreate = async () => {
- if (!canCreate.value) return;
-
- isCreating.value = true;
- try {
- const finalResourceId =
- resourceIdField.value?.resourceId || resourceIdValue.value;
- if (!finalResourceId) {
- throw new Error("Resource ID is required");
- }
-
- const createdProvider = await identityProviderStore.createIdentityProvider(
- idpToCreate.value
- );
-
- pushNotification({
- module: "bytebase",
- style: "SUCCESS",
- title: t("identity-provider.identity-provider-created"),
- });
-
- emit("created", createdProvider);
- } catch (error) {
- if (error instanceof ConnectError && error.code === Code.AlreadyExists) {
- resourceIdField.value?.addValidationError(error.message);
- } else {
- console.error("Failed to create identity provider:", error);
- pushNotification({
- module: "bytebase",
- style: "CRITICAL",
- title: t("identity-provider.identity-provider-create-failed"),
- });
- }
- } finally {
- isCreating.value = false;
- }
-};
-
-// Watchers
-watch(
- selectedType,
- (newType, oldType) => {
- // Only process if type actually changed, not on initial mount
- if (oldType === undefined) {
- // Initial mount - set up OAuth2 defaults if needed
- if (newType === IdentityProviderType.OAUTH2) {
- if (!selectedTemplate.value) {
- selectedTemplate.value = head(templateList.value);
- }
- if (selectedTemplate.value) {
- handleTemplateSelect(selectedTemplate.value);
- }
- }
- return;
- }
-
- if (newType !== oldType) {
- // Type changed - reset form but preserve resource ID
- if (newType === IdentityProviderType.OAUTH2) {
- // Switching to OAuth2
- if (!selectedTemplate.value) {
- selectedTemplate.value = head(templateList.value);
- }
- if (selectedTemplate.value) {
- handleTemplateSelect(selectedTemplate.value);
- }
- } else {
- // Switching to OIDC or LDAP
- identityProvider.value.title = "";
- identityProvider.value.domain = "";
-
- // Clear field mapping
- Object.keys(fieldMapping).forEach((key) => {
- delete fieldMapping[key as keyof FieldMapping];
- });
- scopesStringOfConfig.value = "";
- }
- }
- },
- {
- immediate: true,
- }
-);
-
-// Watch for template changes to ensure form is updated
-watch(
- selectedTemplate,
- (newTemplate) => {
- if (newTemplate && selectedType.value === IdentityProviderType.OAUTH2) {
- handleTemplateSelect(newTemplate);
- }
- },
- { deep: true }
-);
-</script>
diff --git a/frontend/src/components/IdentityProvider/IdentityProviderEditForm.vue b/frontend/src/components/IdentityProvider/IdentityProviderEditForm.vue
deleted file mode 100644
index 56995ce65a..0000000000
--- a/frontend/src/components/IdentityProvider/IdentityProviderEditForm.vue
+++ /dev/null
@@ -1,590 +0,0 @@
-<template>
- <div class="w-full flex flex-col gap-y-0 pt-4">
- <div class="divide-y divide-block-border">
- <!-- Basic Information Section -->
- <div class="pb-6 lg:flex">
- <div class="text-left lg:w-1/4">
- <h1 class="text-3xl font-bold text-gray-900">
- {{ $t("common.general") }}
- </h1>
- </div>
- <div class="flex-1 mt-4 lg:px-4 lg:mt-0 flex flex-col gap-y-6">
- <div>
- <p class="text-base font-semibold text-gray-800 mb-2">
- {{ $t("common.type") }}
- </p>
- <div class="flex items-center gap-x-3 p-3 bg-gray-50 rounded-md">
- <component
- :is="getProviderIcon(localIdentityProvider.type)"
- class="w-5 h-5 text-gray-600"
- />
- <span class="text-base font-medium text-gray-800">
- {{ identityProviderTypeToString(localIdentityProvider.type) }}
- </span>
- </div>
- <p class="text-sm text-gray-600 mt-1">
- {{ $t("settings.sso.form.provider-type-readonly-hint") }}
- </p>
- </div>
-
- <div>
- <p class="text-base font-semibold text-gray-800 mb-2">
- {{ $t("settings.sso.form.name") }}
- <RequiredStar />
- </p>
- <BBTextField
- v-model:value="localIdentityProvider.title"
- required
- :disabled="!allowEdit"
- size="large"
- class="w-full text-base"
- :placeholder="$t('settings.sso.form.name-description')"
- :maxlength="200"
- />
- <ResourceIdField
- resource-type="idp"
- :readonly="true"
- :value="resourceId"
- class="mt-1"
- />
- </div>
-
- <div>
- <p class="text-base font-semibold text-gray-800 mb-2">
- {{ $t("settings.sso.form.domain") }}
- </p>
- <BBTextField
- v-model:value="localIdentityProvider.domain"
- :disabled="!allowEdit"
- size="large"
- class="w-full text-base"
- :placeholder="$t('settings.sso.form.domain-description')"
- />
- <p class="text-sm text-gray-600 mt-1">
- {{ $t("settings.sso.form.domain-optional-hint") }}
- </p>
- </div>
- </div>
- </div>
-
- <!-- Configuration Section -->
- <div class="py-6 lg:flex">
- <div class="text-left lg:w-1/4">
- <h1 class="text-3xl font-bold text-gray-900">
- {{ $t("settings.sso.form.configuration") }}
- </h1>
- <p class="text-base text-gray-600 mt-3">
- {{ $t("settings.sso.form.configuration-description") }}
- </p>
- </div>
- <div class="flex-1 mt-4 lg:px-4 lg:mt-0">
- <IdentityProviderForm
- :identity-provider="localIdentityProvider"
- :provider-type="localIdentityProvider.type"
- :config-for-oauth2="configForOAuth2"
- :config-for-oidc="configForOIDC"
- :config-for-ldap="configForLDAP"
- :scopes-string="scopesStringOfConfig"
- :is-edit-mode="true"
- @update:config-for-oauth2="configForOAuth2 = $event"
- @update:config-for-oidc="configForOIDC = $event"
- @update:config-for-ldap="configForLDAP = $event"
- @update:scopes-string="scopesStringOfConfig = $event"
- />
- </div>
- </div>
-
- <!-- User Information Mapping Section -->
- <div class="py-6 lg:flex">
- <div class="text-left lg:w-1/4">
- <h1 class="text-3xl font-bold text-gray-900">
- {{ $t("settings.sso.form.user-information-mapping") }}
- </h1>
- <p class="text-base text-gray-600 mt-3">
- {{ $t("settings.sso.form.user-information-mapping-description") }}
- <LearnMoreLink
- class="ml-1"
- url="https://docs.bytebase.com/administration/sso/oauth2#user-information-field-mapping?source=console"
- />
- </p>
- </div>
- <div class="flex-1 mt-4 lg:px-4 lg:mt-0 flex flex-col gap-y-6">
- <div class="grid grid-cols-[256px_1fr] gap-4 items-center">
- <BBTextField
- v-model:value="fieldMapping.identifier"
- :disabled="!allowEdit"
- size="large"
- class="w-full text-base"
- :placeholder="$t('settings.sso.form.identifier-placeholder')"
- />
- <div class="flex flex-row justify-start items-center text-base">
- <ArrowRightIcon class="mx-2 h-auto w-5 text-gray-400" />
- <p
- class="flex flex-row justify-start items-center font-semibold text-gray-800"
- >
- {{ $t("settings.sso.form.identifier") }}
- <RequiredStar />
- <NTooltip>
- <template #trigger>
- <InfoIcon class="ml-1 w-4 h-auto text-blue-500" />
- </template>
- {{ $t("settings.sso.form.identifier-tips") }}
- </NTooltip>
- </p>
- </div>
- </div>
-
- <div class="grid grid-cols-[256px_1fr] gap-4 items-center">
- <BBTextField
- v-model:value="fieldMapping.displayName"
- :disabled="!allowEdit"
- size="large"
- class="w-full text-base"
- :placeholder="$t('settings.sso.form.display-name-placeholder')"
- />
- <div class="flex flex-row justify-start items-center text-base">
- <ArrowRightIcon class="mx-2 h-auto w-5 text-gray-400" />
- <p class="font-semibold text-gray-800">
- {{ $t("settings.sso.form.display-name") }}
- </p>
- </div>
- </div>
-
- <div class="grid grid-cols-[256px_1fr] gap-4 items-center">
- <BBTextField
- v-model:value="fieldMapping.phone"
- :disabled="!allowEdit"
- size="large"
- class="w-full text-base"
- :placeholder="$t('settings.sso.form.phone-placeholder')"
- />
- <div class="flex flex-row justify-start items-center text-base">
- <ArrowRightIcon class="mx-2 h-auto w-5 text-gray-400" />
- <p class="font-semibold text-gray-800">
- {{ $t("settings.sso.form.phone") }}
- </p>
- </div>
- </div>
-
- <div
- v-if="localIdentityProvider.type === IdentityProviderType.OIDC"
- class="grid grid-cols-[256px_1fr] gap-4 items-center"
- >
- <BBTextField
- v-model:value="fieldMapping.groups"
- :disabled="!allowEdit"
- size="large"
- class="w-full text-base"
- :placeholder="$t('settings.sso.form.groups-placeholder')"
- />
- <div class="flex flex-row justify-start items-center text-base">
- <ArrowRightIcon class="mx-2 h-auto w-5 text-gray-400" />
- <p class="font-semibold text-gray-800">
- {{ $t("settings.sso.form.groups") }}
- </p>
- </div>
- </div>
-
- <div>
- <TestConnection
- :disabled="!allowTestConnection"
- :size="'large'"
- :is-creating="false"
- :idp="buildUpdatedIdentityProvider()"
- />
- </div>
- </div>
- </div>
-
- <!-- Actions Section -->
- <div class="py-6">
- <div class="flex flex-row justify-between items-center">
- <BBButtonConfirm
- :type="'DELETE'"
- :button-text="$t('settings.sso.delete')"
- :ok-text="$t('common.delete')"
- :confirm-title="$t('settings.sso.delete')"
- :confirm-description="t('identity-provider.delete-warning')"
- :require-confirm="true"
- @confirm="handleDelete"
- />
- <div class="gap-x-3 flex flex-row justify-end items-center">
- <NButton v-if="hasChanges" @click="handleDiscard" class="text-base">
- {{ $t("common.discard-changes") }}
- </NButton>
- <NButton
- type="primary"
- :disabled="!canUpdate"
- :loading="isUpdating"
- @click="handleUpdate"
- class="text-base"
- >
- {{ $t("common.update") }}
- </NButton>
- </div>
- </div>
- </div>
- </div>
- </div>
-</template>
-
-<script setup lang="ts">
-import { create as createProto } from "@bufbuild/protobuf";
-import { cloneDeep, isEqual } from "lodash-es";
-import {
- ArrowRightIcon,
- DatabaseIcon,
- InfoIcon,
- KeyIcon,
- ShieldCheckIcon,
-} from "lucide-vue-next";
-import { NButton, NTooltip } from "naive-ui";
-import { computed, reactive, ref, watch } from "vue";
-import { useI18n } from "vue-i18n";
-import { useRouter } from "vue-router";
-import { BBButtonConfirm, BBTextField } from "@/bbkit";
-import LearnMoreLink from "@/components/LearnMoreLink.vue";
-import RequiredStar from "@/components/RequiredStar.vue";
-import { ResourceIdField } from "@/components/v2";
-import { WORKSPACE_ROUTE_IDENTITY_PROVIDERS } from "@/router/dashboard/workspaceRoutes";
-import { pushNotification } from "@/store";
-import { useIdentityProviderStore } from "@/store/modules/idp";
-import { getIdentityProviderResourceId } from "@/store/modules/v1/common";
-import type {
- FieldMapping,
- IdentityProvider,
- LDAPIdentityProviderConfig,
- OAuth2IdentityProviderConfig,
- OIDCIdentityProviderConfig,
-} from "@/types/proto-es/v1/idp_service_pb";
-import {
- FieldMappingSchema,
- IdentityProviderConfigSchema,
- IdentityProviderSchema,
- IdentityProviderType,
- LDAPIdentityProviderConfigSchema,
- OAuth2IdentityProviderConfigSchema,
- OIDCIdentityProviderConfigSchema,
-} from "@/types/proto-es/v1/idp_service_pb";
-import {
- hasWorkspacePermissionV2,
- identityProviderTypeToString,
-} from "@/utils";
-import IdentityProviderForm from "./IdentityProviderForm.vue";
-import TestConnection from "./TestConnection.vue";
-
-interface Props {
- identityProvider: IdentityProvider;
-}
-
-const props = defineProps<Props>();
-
-const emit = defineEmits<{
- (event: "updated", identityProvider: IdentityProvider): void;
- (event: "deleted"): void;
-}>();
-
-const { t } = useI18n();
-const router = useRouter();
-const identityProviderStore = useIdentityProviderStore();
-
-// State
-const isUpdating = ref(false);
-const localIdentityProvider = ref<IdentityProvider>(
- cloneDeep(props.identityProvider)
-);
-const configForOAuth2 = ref<OAuth2IdentityProviderConfig>(
- createProto(
- OAuth2IdentityProviderConfigSchema,
- props.identityProvider.config?.config?.case === "oauth2Config"
- ? props.identityProvider.config.config.value
- : {}
- )
-);
-const configForOIDC = ref<OIDCIdentityProviderConfig>(
- createProto(
- OIDCIdentityProviderConfigSchema,
- props.identityProvider.config?.config?.case === "oidcConfig"
- ? props.identityProvider.config.config.value
- : {}
- )
-);
-const configForLDAP = ref<LDAPIdentityProviderConfig>(
- createProto(
- LDAPIdentityProviderConfigSchema,
- props.identityProvider.config?.config?.case === "ldapConfig"
- ? props.identityProvider.config.config.value
- : {}
- )
-);
-const scopesStringOfConfig = ref<string>("");
-const fieldMapping = reactive<FieldMapping>(
- createProto(FieldMappingSchema, {})
-);
-
-// Computed
-const resourceId = computed(() => {
- return getIdentityProviderResourceId(localIdentityProvider.value.name);
-});
-
-const allowEdit = computed(() => {
- return hasWorkspacePermissionV2("bb.identityProviders.update");
-});
-
-const hasChanges = computed(() => {
- const current = buildUpdatedIdentityProvider();
- return !isEqual(current, props.identityProvider);
-});
-
-// Track if secrets have been modified
-const isClientSecretModified = ref(false);
-const isBindPasswordModified = ref(false);
-
-const isFormValid = computed(() => {
- if (!localIdentityProvider.value.title) return false;
- if (!fieldMapping.identifier) return false;
-
- if (localIdentityProvider.value.type === IdentityProviderType.OAUTH2) {
- // For edit mode, client secret is optional if not modified
- const isClientSecretValid = isClientSecretModified.value
- ? !!configForOAuth2.value.clientSecret
- : true;
-
- return !!(
- configForOAuth2.value.clientId &&
- isClientSecretValid &&
- configForOAuth2.value.authUrl &&
- configForOAuth2.value.tokenUrl &&
- configForOAuth2.value.userInfoUrl
- );
- } else if (localIdentityProvider.value.type === IdentityProviderType.OIDC) {
- // For edit mode, client secret is optional if not modified
- const isClientSecretValid = isClientSecretModified.value
- ? !!configForOIDC.value.clientSecret
- : true;
-
- return !!(
- configForOIDC.value.clientId &&
- isClientSecretValid &&
- configForOIDC.value.issuer
- );
- } else if (localIdentityProvider.value.type === IdentityProviderType.LDAP) {
- // For edit mode, bind password is optional if not modified
- const isBindPasswordValid = isBindPasswordModified.value
- ? !!configForLDAP.value.bindPassword
- : true;
-
- return !!(
- configForLDAP.value.host &&
- configForLDAP.value.port &&
- configForLDAP.value.bindDn &&
- isBindPasswordValid &&
- configForLDAP.value.baseDn &&
- configForLDAP.value.userFilter
- );
- }
-
- return false;
-});
-
-const canUpdate = computed(() => {
- return allowEdit.value && hasChanges.value && isFormValid.value;
-});
-
-const allowTestConnection = computed(() => {
- return isFormValid.value;
-});
-
-// Methods
-const getProviderIcon = (type: IdentityProviderType) => {
- switch (type) {
- case IdentityProviderType.OAUTH2:
- return KeyIcon;
- case IdentityProviderType.OIDC:
- return ShieldCheckIcon;
- case IdentityProviderType.LDAP:
- return DatabaseIcon;
- default:
- return KeyIcon;
- }
-};
-
-const buildUpdatedIdentityProvider = (): IdentityProvider => {
- const result = createProto(IdentityProviderSchema, {
- ...localIdentityProvider.value,
- config: createProto(IdentityProviderConfigSchema, {}),
- });
-
- if (localIdentityProvider.value.type === IdentityProviderType.OAUTH2) {
- const oauth2Config = {
- ...configForOAuth2.value,
- scopes: scopesStringOfConfig.value.split(" ").filter(Boolean),
- fieldMapping: createProto(FieldMappingSchema, fieldMapping),
- };
-
- result.config = createProto(IdentityProviderConfigSchema, {
- config: {
- case: "oauth2Config",
- value: oauth2Config,
- },
- });
- } else if (localIdentityProvider.value.type === IdentityProviderType.OIDC) {
- const oidcConfig = {
- ...configForOIDC.value,
- scopes: scopesStringOfConfig.value.split(" ").filter(Boolean),
- fieldMapping: createProto(FieldMappingSchema, fieldMapping),
- };
-
- result.config = createProto(IdentityProviderConfigSchema, {
- config: {
- case: "oidcConfig",
- value: oidcConfig,
- },
- });
- } else if (localIdentityProvider.value.type === IdentityProviderType.LDAP) {
- const ldapConfig = {
- ...configForLDAP.value,
- fieldMapping: createProto(FieldMappingSchema, fieldMapping),
- };
-
- result.config = createProto(IdentityProviderConfigSchema, {
- config: {
- case: "ldapConfig",
- value: ldapConfig,
- },
- });
- }
-
- return result;
-};
-
-const initializeFromProps = () => {
- localIdentityProvider.value = cloneDeep(props.identityProvider);
-
- // Reset secret modification flags
- isClientSecretModified.value = false;
- isBindPasswordModified.value = false;
-
- if (props.identityProvider.config?.config?.case === "oauth2Config") {
- const oauth2Config = props.identityProvider.config.config.value;
- configForOAuth2.value = createProto(
- OAuth2IdentityProviderConfigSchema,
- oauth2Config
- );
- Object.assign(fieldMapping, oauth2Config.fieldMapping || {});
- scopesStringOfConfig.value = (oauth2Config.scopes || []).join(" ");
- } else if (props.identityProvider.config?.config?.case === "oidcConfig") {
- const oidcConfig = props.identityProvider.config.config.value;
- configForOIDC.value = createProto(
- OIDCIdentityProviderConfigSchema,
- oidcConfig
- );
- Object.assign(fieldMapping, oidcConfig.fieldMapping || {});
- scopesStringOfConfig.value = (oidcConfig.scopes || []).join(" ");
- } else if (props.identityProvider.config?.config?.case === "ldapConfig") {
- const ldapConfig = props.identityProvider.config.config.value;
- configForLDAP.value = createProto(
- LDAPIdentityProviderConfigSchema,
- ldapConfig
- );
- Object.assign(fieldMapping, ldapConfig.fieldMapping || {});
- }
-};
-
-const handleUpdate = async () => {
- if (!canUpdate.value) return;
-
- isUpdating.value = true;
- try {
- const updatedProvider = await identityProviderStore.patchIdentityProvider(
- buildUpdatedIdentityProvider()
- );
-
- pushNotification({
- module: "bytebase",
- style: "SUCCESS",
- title: t("common.updated"),
- });
-
- emit("updated", updatedProvider);
- initializeFromProps();
- } catch {
- pushNotification({
- module: "bytebase",
- style: "CRITICAL",
- title: t("identity-provider.identity-provider-update-failed"),
- });
- } finally {
- isUpdating.value = false;
- }
-};
-
-const handleDiscard = () => {
- initializeFromProps();
-};
-
-const handleDelete = async () => {
- if (!hasWorkspacePermissionV2("bb.identityProviders.delete")) {
- pushNotification({
- module: "bytebase",
- style: "WARN",
- title: t("identity-provider.identity-provider-permission-denied"),
- });
- return;
- }
-
- try {
- await identityProviderStore.deleteIdentityProvider(
- props.identityProvider.name
- );
-
- pushNotification({
- module: "bytebase",
- style: "SUCCESS",
- title: t("identity-provider.identity-provider-deleted"),
- });
-
- emit("deleted");
- router.replace({
- name: WORKSPACE_ROUTE_IDENTITY_PROVIDERS,
- });
- } catch {
- pushNotification({
- module: "bytebase",
- style: "CRITICAL",
- title: t("identity-provider.identity-provider-delete-failed"),
- });
- }
-};
-
-// Initialize from props
-watch(() => props.identityProvider, initializeFromProps, { immediate: true });
-
-// Watch for secret field changes
-watch(
- () => configForOAuth2.value.clientSecret,
- (newVal, oldVal) => {
- if (oldVal !== undefined && newVal !== oldVal) {
- isClientSecretModified.value = true;
- }
- }
-);
-
-watch(
- () => configForOIDC.value.clientSecret,
- (newVal, oldVal) => {
- if (oldVal !== undefined && newVal !== oldVal) {
- isClientSecretModified.value = true;
- }
- }
-);
-
-watch(
- () => configForLDAP.value.bindPassword,
- (newVal, oldVal) => {
- if (oldVal !== undefined && newVal !== oldVal) {
- isBindPasswordModified.value = true;
- }
- }
-);
-</script>
diff --git a/frontend/src/components/IdentityProvider/IdentityProviderExternalURL.vue b/frontend/src/components/IdentityProvider/IdentityProviderExternalURL.vue
deleted file mode 100644
index c244e40894..0000000000
--- a/frontend/src/components/IdentityProvider/IdentityProviderExternalURL.vue
+++ /dev/null
@@ -1,63 +0,0 @@
-<template>
- <div class="p-4 rounded-lg border border-gray-200 bg-gray-50">
- <div class="flex items-start gap-x-3">
- <div class="shrink-0">
- <InfoIcon class="w-5 h-5 text-blue-500 mt-0.5" />
- </div>
- <div class="flex-1 min-w-0">
- <p class="text-sm font-medium text-gray-900 mb-2">
- {{ $t("settings.sso.form.identity-provider-needed-information") }}
- </p>
- <p class="text-sm text-gray-600 mb-3">
- {{ $t("settings.sso.form.redirect-url-description") }}
- </p>
-
- <div class="flex items-center gap-x-3">
- <div class="flex-1">
- <label class="block text-sm font-medium text-gray-700 mb-1">
- {{ $t("settings.sso.form.redirect-url") }}
- </label>
- <div class="relative">
- <input
- :value="redirectUrl"
- readonly
- class="block w-full px-3 py-2 border border-gray-300 rounded-md bg-white text-sm font-mono text-gray-700 pr-10"
- />
- <div class="absolute inset-y-0 right-2 top-2">
- <CopyButton :content="redirectUrl" />
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
-</template>
-
-<script setup lang="ts">
-import { InfoIcon } from "lucide-vue-next";
-import { computed } from "vue";
-import { CopyButton } from "@/components/v2";
-import { useActuatorV1Store } from "@/store";
-import { IdentityProviderType } from "@/types/proto-es/v1/idp_service_pb";
-
-const props = defineProps<{
- type: IdentityProviderType;
-}>();
-
-const externalUrl = computed(
- () => useActuatorV1Store().serverInfo?.externalUrl ?? ""
-);
-
-const redirectUrl = computed(() => {
- const url = externalUrl.value || window.origin;
- switch (props.type) {
- case IdentityProviderType.OAUTH2:
- return `${url}/oauth/callback`;
- case IdentityProviderType.OIDC:
- return `${url}/oidc/callback`;
- default:
- return "";
- }
-});
-</script>
diff --git a/frontend/src/components/IdentityProvider/IdentityProviderForm.vue b/frontend/src/components/IdentityProvider/IdentityProviderForm.vue
deleted file mode 100644
index f6b4326d6d..0000000000
--- a/frontend/src/components/IdentityProvider/IdentityProviderForm.vue
+++ /dev/null
@@ -1,568 +0,0 @@
-<template>
- <div class="flex flex-col gap-y-6">
- <!-- OAuth2 Configuration -->
- <div
- v-if="providerType === IdentityProviderType.OAUTH2"
- class="flex flex-col gap-y-6"
- >
- <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
- <div>
- <label class="block text-base font-semibold text-gray-800 mb-2">
- Client ID
- <RequiredStar />
- </label>
- <BBTextField
- :value="oauth2Config.clientId || ''"
- @update:value="updateOAuth2Config('clientId', $event)"
- required
- size="large"
- class="w-full text-base"
- placeholder="e.g. 6655asd77895265aa110ac0d3"
- />
- </div>
-
- <div>
- <label class="block text-base font-semibold text-gray-800 mb-2">
- Client Secret
- <RequiredStar v-if="!isEditMode" />
- </label>
- <BBTextField
- :value="oauth2Config.clientSecret || ''"
- @update:value="updateOAuth2Config('clientSecret', $event)"
- :required="!isEditMode"
- size="large"
- type="password"
- class="w-full text-base"
- :placeholder="
- isEditMode && !oauth2Config.clientSecret
- ? 'Leave empty to keep existing secret'
- : 'e.g. 5bbezxc3972ca304de70c5d70a6aa932asd8'
- "
- />
- </div>
- </div>
-
- <div>
- <label class="block text-base font-semibold text-gray-800 mb-2">
- {{ $t("settings.sso.form.auth-url") }}
- <RequiredStar />
- </label>
- <BBTextField
- :value="oauth2Config.authUrl || ''"
- @update:value="updateOAuth2Config('authUrl', $event)"
- required
- size="large"
- class="w-full text-base"
- :placeholder="$t('settings.sso.form.auth-url-placeholder')"
- />
- <p class="text-sm text-gray-600 mt-1">
- {{ $t("settings.sso.form.auth-url-description") }}
- </p>
- </div>
-
- <div>
- <label class="block text-base font-semibold text-gray-800 mb-2">
- {{ $t("settings.sso.form.token-url") }}
- <RequiredStar />
- </label>
- <BBTextField
- :value="oauth2Config.tokenUrl || ''"
- @update:value="updateOAuth2Config('tokenUrl', $event)"
- required
- size="large"
- class="w-full text-base"
- :placeholder="$t('settings.sso.form.token-url-placeholder')"
- />
- <p class="text-sm text-gray-600 mt-1">
- {{ $t("settings.sso.form.token-url-description") }}
- </p>
- </div>
-
- <div>
- <label class="block text-base font-semibold text-gray-800 mb-2">
- {{ $t("settings.sso.form.user-info-url") }}
- <RequiredStar />
- </label>
- <BBTextField
- :value="oauth2Config.userInfoUrl || ''"
- @update:value="updateOAuth2Config('userInfoUrl', $event)"
- required
- size="large"
- class="w-full text-base"
- :placeholder="$t('settings.sso.form.user-info-url-placeholder')"
- />
- <p class="text-sm text-gray-600 mt-1">
- {{ $t("settings.sso.form.user-info-url-description") }}
- </p>
- </div>
-
- <div>
- <label class="block text-base font-semibold text-gray-800 mb-2">
- {{ $t("settings.sso.form.scopes") }}
- <RequiredStar />
- </label>
- <BBTextField
- :value="scopesString || ''"
- @update:value="$emit('update:scopes-string', $event)"
- required
- size="large"
- class="w-full text-base"
- :placeholder="$t('settings.sso.form.scopes-placeholder')"
- />
- <p class="text-sm text-gray-600 mt-1">
- {{ $t("settings.sso.form.scopes-description") }}
- </p>
- </div>
-
- <div>
- <label class="block text-base font-semibold text-gray-800 mb-3">
- {{ $t("settings.sso.form.authentication-style") }}
- <RequiredStar />
- </label>
- <NRadioGroup
- :value="oauth2Config.authStyle"
- @update:value="updateOAuth2Config('authStyle', $event)"
- size="large"
- class="flex flex-col gap-y-3"
- >
- <NRadio
- :value="OAuth2AuthStyle.IN_PARAMS"
- class="text-base font-medium text-gray-800"
- >
- <div class="flex flex-col gap-y-1">
- <div class="font-medium">
- {{ $t("settings.sso.form.in-parameters") }}
- </div>
- <div class="text-sm text-gray-600">
- {{ $t("settings.sso.form.in-parameters-description") }}
- </div>
- </div>
- </NRadio>
- <NRadio
- :value="OAuth2AuthStyle.IN_HEADER"
- class="text-base font-medium text-gray-800"
- >
- <div class="flex flex-col gap-y-1">
- <div class="font-medium">
- {{ $t("settings.sso.form.in-header") }}
- </div>
- <div class="text-sm text-gray-600">
- {{ $t("settings.sso.form.in-header-description") }}
- </div>
- </div>
- </NRadio>
- </NRadioGroup>
- </div>
-
- <div>
- <label class="block text-base font-semibold text-gray-800 mb-3">
- {{ $t("settings.sso.form.security-options") }}
- </label>
- <NCheckbox
- :checked="oauth2Config.skipTlsVerify"
- @update:checked="updateOAuth2Config('skipTlsVerify', $event)"
- size="large"
- class="text-base font-medium text-gray-800"
- >
- {{ $t("settings.sso.form.skip-tls-verification") }}
- </NCheckbox>
- <p class="text-sm text-gray-600 mt-1 ml-6">
- {{ $t("settings.sso.form.skip-tls-warning") }}
- </p>
- </div>
- </div>
-
- <!-- OIDC Configuration -->
- <div
- v-else-if="providerType === IdentityProviderType.OIDC"
- class="flex flex-col gap-y-6"
- >
- <div>
- <label class="block text-base font-semibold text-gray-800 mb-2">
- Issuer URL
- <RequiredStar />
- </label>
- <BBTextField
- :value="oidcConfig.issuer || ''"
- @update:value="updateOIDCConfig('issuer', $event)"
- required
- size="large"
- class="w-full text-base"
- :placeholder="$t('settings.sso.form.issuer-url-placeholder')"
- />
- <p class="text-sm text-gray-600 mt-1">
- {{ $t("settings.sso.form.issuer-url-description") }}
- </p>
- </div>
-
- <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
- <div>
- <label class="block text-base font-semibold text-gray-800 mb-2">
- Client ID
- <RequiredStar />
- </label>
- <BBTextField
- :value="oidcConfig.clientId || ''"
- @update:value="updateOIDCConfig('clientId', $event)"
- required
- size="large"
- class="w-full text-base"
- placeholder="e.g. 6655asd77895265aa110ac0d3"
- />
- </div>
-
- <div>
- <label class="block text-base font-semibold text-gray-800 mb-2">
- Client Secret
- <RequiredStar v-if="!isEditMode" />
- </label>
- <BBTextField
- :value="oidcConfig.clientSecret || ''"
- @update:value="updateOIDCConfig('clientSecret', $event)"
- :required="!isEditMode"
- size="large"
- type="password"
- class="w-full text-base"
- :placeholder="
- isEditMode && !oidcConfig.clientSecret
- ? 'Leave empty to keep existing secret'
- : 'e.g. 5bbezxc3972ca304de70c5d70a6aa932asd8'
- "
- />
- </div>
- </div>
-
- <div>
- <label class="block text-base font-semibold text-gray-800 mb-2">
- {{ $t("settings.sso.form.scopes") }}
- <RequiredStar />
- </label>
- <BBTextField
- :value="scopesString"
- @update:value="$emit('update:scopes-string', $event)"
- required
- size="large"
- class="w-full text-base"
- :placeholder="$t('settings.sso.form.scopes-placeholder-oidc')"
- />
- <p class="text-sm text-gray-600 mt-1">
- {{ $t("settings.sso.form.openid-scopes-description") }}
- </p>
- </div>
-
- <div>
- <label class="block text-base font-semibold text-gray-800 mb-3">
- {{ $t("settings.sso.form.authentication-style") }}
- <RequiredStar />
- </label>
- <NRadioGroup
- :value="oidcConfig.authStyle"
- @update:value="updateOIDCConfig('authStyle', $event)"
- size="large"
- class="flex flex-col gap-y-3"
- >
- <NRadio
- :value="OAuth2AuthStyle.IN_PARAMS"
- class="text-base font-medium text-gray-800"
- >
- <div class="flex flex-col gap-y-1">
- <div class="font-medium">
- {{ $t("settings.sso.form.in-parameters") }}
- </div>
- <div class="text-sm text-gray-600">
- {{ $t("settings.sso.form.in-parameters-description") }}
- </div>
- </div>
- </NRadio>
- <NRadio
- :value="OAuth2AuthStyle.IN_HEADER"
- class="text-base font-medium text-gray-800"
- >
- <div class="flex flex-col gap-y-1">
- <div class="font-medium">
- {{ $t("settings.sso.form.in-header") }}
- </div>
- <div class="text-sm text-gray-600">
- {{ $t("settings.sso.form.in-header-description") }}
- </div>
- </div>
- </NRadio>
- </NRadioGroup>
- </div>
-
- <div>
- <label class="block text-base font-semibold text-gray-800 mb-3">
- {{ $t("settings.sso.form.security-options") }}
- </label>
- <NCheckbox
- :checked="oidcConfig.skipTlsVerify"
- @update:checked="updateOIDCConfig('skipTlsVerify', $event)"
- size="large"
- class="text-base font-medium text-gray-800"
- >
- {{ $t("settings.sso.form.skip-tls-verification") }}
- </NCheckbox>
- <p class="text-sm text-gray-600 mt-1 ml-6">
- {{ $t("settings.sso.form.skip-tls-warning") }}
- </p>
- </div>
- </div>
-
- <!-- LDAP Configuration -->
- <div
- v-else-if="providerType === IdentityProviderType.LDAP"
- class="flex flex-col gap-y-6"
- >
- <div class="grid grid-cols-1 md:grid-cols-3 gap-6">
- <div class="md:col-span-2">
- <label class="block text-base font-semibold text-gray-800 mb-2">
- Host
- <RequiredStar />
- </label>
- <BBTextField
- :value="ldapConfig.host || ''"
- @update:value="updateLDAPConfig('host', $event)"
- required
- size="large"
- class="w-full text-base"
- :placeholder="$t('settings.sso.form.host-placeholder')"
- />
- </div>
-
- <div>
- <label class="block text-base font-semibold text-gray-800 mb-2">
- Port
- <RequiredStar />
- </label>
- <NInputNumber
- :value="ldapConfig.port"
- @update:value="updateLDAPConfig('port', $event)"
- size="large"
- class="w-full text-base"
- placeholder="389"
- :min="1"
- :max="65535"
- />
- </div>
- </div>
-
- <div>
- <label class="block text-base font-semibold text-gray-800 mb-2">
- {{ $t("settings.sso.form.bind-dn") }}
- <RequiredStar />
- </label>
- <BBTextField
- :value="ldapConfig.bindDn || ''"
- @update:value="updateLDAPConfig('bindDn', $event)"
- required
- size="large"
- class="w-full text-base"
- :placeholder="$t('settings.sso.form.bind-dn-placeholder')"
- />
- <p class="text-sm text-gray-600 mt-1">
- {{ $t("settings.sso.form.bind-dn-description") }}
- </p>
- </div>
-
- <div>
- <label class="block text-base font-semibold text-gray-800 mb-2">
- {{ $t("settings.sso.form.bind-password") }}
- <RequiredStar />
- </label>
- <BBTextField
- :value="ldapConfig.bindPassword || ''"
- @update:value="updateLDAPConfig('bindPassword', $event)"
- required
- size="large"
- type="password"
- class="w-full text-base"
- placeholder="••••••••"
- />
- </div>
-
- <div>
- <label class="block text-base font-semibold text-gray-800 mb-2">
- {{ $t("settings.sso.form.base-dn") }}
- <RequiredStar />
- </label>
- <BBTextField
- :value="ldapConfig.baseDn || ''"
- @update:value="updateLDAPConfig('baseDn', $event)"
- required
- size="large"
- class="w-full text-base"
- :placeholder="$t('settings.sso.form.base-dn-placeholder')"
- />
- <p class="text-sm text-gray-600 mt-1">
- {{ $t("settings.sso.form.base-dn-description") }}
- </p>
- </div>
-
- <div>
- <label class="block text-base font-semibold text-gray-800 mb-2">
- {{ $t("settings.sso.form.user-filter") }}
- <RequiredStar />
- </label>
- <BBTextField
- :value="ldapConfig.userFilter || ''"
- @update:value="updateLDAPConfig('userFilter', $event)"
- required
- size="large"
- class="w-full text-base"
- :placeholder="$t('settings.sso.form.user-filter-placeholder')"
- />
- <p class="text-sm text-gray-600 mt-1">
- {{ $t("settings.sso.form.user-filter-description") }}
- </p>
- </div>
-
- <div>
- <label class="block text-base font-semibold text-gray-800 mb-3">
- {{ $t("settings.sso.form.security-protocol") }}
- <RequiredStar />
- </label>
- <NRadioGroup
- :value="ldapConfig.securityProtocol"
- @update:value="updateLDAPConfig('securityProtocol', $event)"
- size="large"
- class="flex flex-col gap-y-3"
- >
- <NRadio
- :value="LDAPIdentityProviderConfig_SecurityProtocol.START_TLS"
- class="text-base font-medium text-gray-800"
- >
- <div class="flex flex-col gap-y-1">
- <div class="font-medium">
- {{ $t("settings.sso.form.starttls") }}
- </div>
- <div class="text-sm text-gray-600">
- {{ $t("settings.sso.form.starttls-description") }}
- </div>
- </div>
- </NRadio>
- <NRadio
- :value="LDAPIdentityProviderConfig_SecurityProtocol.LDAPS"
- class="text-base font-medium text-gray-800"
- >
- <div class="flex flex-col gap-y-1">
- <div class="font-medium">{{ $t("settings.sso.form.ldaps") }}</div>
- <div class="text-sm text-gray-600">
- {{ $t("settings.sso.form.ldaps-description") }}
- </div>
- </div>
- </NRadio>
- <NRadio
- :value="
- LDAPIdentityProviderConfig_SecurityProtocol.SECURITY_PROTOCOL_UNSPECIFIED
- "
- class="text-base font-medium text-gray-800"
- >
- <div class="flex flex-col gap-y-1">
- <div class="font-medium">{{ $t("settings.sso.form.none") }}</div>
- <div class="text-sm text-gray-600">
- {{ $t("settings.sso.form.none-description") }}
- </div>
- </div>
- </NRadio>
- </NRadioGroup>
- </div>
-
- <div>
- <label class="block text-base font-semibold text-gray-800 mb-3">
- {{ $t("settings.sso.form.security-options") }}
- </label>
- <NCheckbox
- :checked="ldapConfig.skipTlsVerify"
- @update:checked="updateLDAPConfig('skipTlsVerify', $event)"
- size="large"
- class="text-base font-medium text-gray-800"
- >
- {{ $t("settings.sso.form.skip-tls-verification") }}
- </NCheckbox>
- <p class="text-sm text-gray-600 mt-1 ml-6">
- {{ $t("settings.sso.form.skip-tls-warning") }}
- </p>
- </div>
- </div>
- </div>
-</template>
-
-<script setup lang="ts">
-import { NCheckbox, NInputNumber, NRadio, NRadioGroup } from "naive-ui";
-import { computed, watch } from "vue";
-import { BBTextField } from "@/bbkit";
-import RequiredStar from "@/components/RequiredStar.vue";
-import {
- type IdentityProvider,
- IdentityProviderType,
- type LDAPIdentityProviderConfig,
- LDAPIdentityProviderConfig_SecurityProtocol,
- OAuth2AuthStyle,
- type OAuth2IdentityProviderConfig,
- type OIDCIdentityProviderConfig,
-} from "@/types/proto-es/v1/idp_service_pb";
-
-interface Props {
- identityProvider: IdentityProvider;
- providerType: IdentityProviderType;
- configForOauth2: OAuth2IdentityProviderConfig;
- configForOidc: OIDCIdentityProviderConfig;
- configForLdap: LDAPIdentityProviderConfig;
- scopesString: string;
- isEditMode?: boolean;
-}
-
-const props = defineProps<Props>();
-
-const emit = defineEmits<{
- "update:config-for-oauth2": [config: OAuth2IdentityProviderConfig];
- "update:config-for-oidc": [config: OIDCIdentityProviderConfig];
- "update:config-for-ldap": [config: LDAPIdentityProviderConfig];
- "update:scopes-string": [scopes: string];
-}>();
-
-// Create computed properties to ensure reactivity
-const oauth2Config = computed(() => props.configForOauth2);
-const oidcConfig = computed(() => props.configForOidc);
-const ldapConfig = computed(() => props.configForLdap);
-
-// Watch for OAuth2 config changes to ensure reactivity
-watch(
- () => props.configForOauth2,
- () => {
- // Trigger reactivity when props change
- },
- { deep: true }
-);
-
-// Helper methods to update configurations
-const updateOAuth2Config = <T extends keyof OAuth2IdentityProviderConfig>(
- key: T,
- value: OAuth2IdentityProviderConfig[T]
-) => {
- emit("update:config-for-oauth2", {
- ...props.configForOauth2,
- [key]: value,
- });
-};
-
-const updateOIDCConfig = <T extends keyof OIDCIdentityProviderConfig>(
- key: T,
- value: OIDCIdentityProviderConfig[T]
-) => {
- emit("update:config-for-oidc", {
- ...props.configForOidc,
- [key]: value,
- });
-};
-
-const updateLDAPConfig = <T extends keyof LDAPIdentityProviderConfig>(
- key: T,
- value: LDAPIdentityProviderConfig[T] | null
-) => {
- emit("update:config-for-ldap", {
- ...props.configForLdap,
- [key]: value,
- });
-};
-</script>
diff --git a/frontend/src/components/IdentityProvider/IdentityProviderTable.vue b/frontend/src/components/IdentityProvider/IdentityProviderTable.vue
deleted file mode 100644
index f505facf84..0000000000
--- a/frontend/src/components/IdentityProvider/IdentityProviderTable.vue
+++ /dev/null
@@ -1,73 +0,0 @@
-<template>
- <NDataTable
- key="idp-table"
- v-bind="$attrs"
- :columns="columnList"
- :data="identityProviderList"
- :striped="true"
- :row-key="(idp: IdentityProvider) => idp.name"
- :row-props="rowProps"
- :paginate-single-page="false"
- />
-</template>
-
-<script lang="ts" setup>
-import { type DataTableColumn, NDataTable } from "naive-ui";
-import { computed } from "vue";
-import { useI18n } from "vue-i18n";
-import { useRouter } from "vue-router";
-import { WORKSPACE_ROUTE_IDENTITY_PROVIDER_DETAIL } from "@/router/dashboard/workspaceRoutes";
-import { getIdentityProviderResourceId } from "@/store/modules/v1/common";
-import type { IdentityProvider } from "@/types/proto-es/v1/idp_service_pb";
-import { identityProviderTypeToString } from "@/utils";
-
-withDefaults(
- defineProps<{
- identityProviderList: IdentityProvider[];
- }>(),
- {}
-);
-
-const router = useRouter();
-const { t } = useI18n();
-
-const columnList = computed((): DataTableColumn<IdentityProvider>[] => {
- return [
- {
- key: "id",
- title: t("common.id"),
- width: "164px",
- render: (idp) => getIdentityProviderResourceId(idp.name),
- },
- {
- key: "title",
- title: t("common.name"),
- render: (idp) => idp.title,
- },
- {
- key: "type",
- title: t("common.type"),
- render: (idp) => identityProviderTypeToString(idp.type),
- },
- {
- key: "domain",
- title: t("settings.sso.form.domain"),
- render: (idp) => idp.domain || "-",
- },
- ];
-});
-
-const rowProps = (identityProvider: IdentityProvider) => {
- return {
- style: "cursor: pointer;",
- onClick: (_: MouseEvent) => {
- router.push({
- name: WORKSPACE_ROUTE_IDENTITY_PROVIDER_DETAIL,
- params: {
- idpId: getIdentityProviderResourceId(identityProvider.name),
- },
- });
- },
- };
-};
-</script>
diff --git a/frontend/src/components/IdentityProvider/TestConnection.vue b/frontend/src/components/IdentityProvider/TestConnection.vue
deleted file mode 100644
index dc91f121ee..0000000000
--- a/frontend/src/components/IdentityProvider/TestConnection.vue
+++ /dev/null
@@ -1,286 +0,0 @@
-<template>
- <NButton
- @click="testConnection"
- :loading="isTestingInProgress"
- :disabled="isTestingInProgress"
- v-bind="$attrs"
- >
- {{ $t("identity-provider.test-connection") }}
- </NButton>
-
- <!-- Claims Dialog -->
- <NModal
- v-model:show="showClaimsDialog"
- preset="dialog"
- class="w-128!"
- :show-icon="false"
- >
- <template #header>
- <div class="flex items-center gap-x-2">
- <heroicons:check-circle class="w-6 h-6 text-success" />
- <span>{{ $t("identity-provider.test-connection-success") }}</span>
- </div>
- </template>
- <div v-if="testIdentityProviderResponse" class="flex flex-col gap-y-4">
- <p class="text-sm text-control-light">
- {{ $t("identity-provider.userinfo-description") }}
- </p>
- <div class="bg-gray-50 dark:bg-gray-800 rounded-lg p-4">
- <div class="flex flex-col gap-y-2">
- <div
- v-for="[key, value] in Object.entries(
- testIdentityProviderResponse.userInfo
- )"
- :key="key"
- class="grid grid-cols-3 gap-2 py-1 border-b border-gray-200 dark:border-gray-600 last:border-b-0"
- >
- <div class="text-sm font-medium text-control truncate" :title="key">
- {{ key }}
- </div>
- <div class="col-span-2 text-sm text-main break-all" :title="value">
- {{ value }}
- </div>
- </div>
- </div>
- </div>
- <p class="text-sm text-control-light">
- {{ $t("identity-provider.claims-description") }}
- </p>
- <div class="bg-gray-50 dark:bg-gray-800 rounded-lg p-4">
- <div class="flex flex-col gap-y-2">
- <div
- v-if="Object.keys(testIdentityProviderResponse.claims).length === 0"
- class="text-sm text-control-light italic"
- >
- {{ $t("identity-provider.no-claims") }}
- </div>
- <template v-else>
- <div
- v-for="[key, value] in Object.entries(
- testIdentityProviderResponse.claims
- )"
- :key="key"
- class="grid grid-cols-3 gap-2 py-1 border-b border-gray-200 dark:border-gray-600 last:border-b-0"
- >
- <div
- class="text-sm font-medium text-control truncate"
- :title="key"
- >
- {{ key }}
- </div>
- <div
- class="col-span-2 text-sm text-main break-all"
- :title="value"
- >
- {{ value }}
- </div>
- </div>
- </template>
- </div>
- </div>
- </div>
- <div v-else>
- <p class="text-sm text-control-light">
- No user info or claims available for this identity provider.
- </p>
- </div>
- </NModal>
-</template>
-
-<script lang="ts" setup>
-import { create } from "@bufbuild/protobuf";
-import type { ConnectError } from "@connectrpc/connect";
-import { NButton, NModal } from "naive-ui";
-import { onUnmounted, ref, watch } from "vue";
-import { identityProviderServiceClientConnect } from "@/connect";
-import { pushNotification } from "@/store";
-import type { OAuthWindowEventPayload } from "@/types";
-import type {
- IdentityProvider,
- TestIdentityProviderResponse,
-} from "@/types/proto-es/v1/idp_service_pb";
-import {
- CreateIdentityProviderRequestSchema,
- IdentityProviderType,
- TestIdentityProviderRequestSchema,
-} from "@/types/proto-es/v1/idp_service_pb";
-import { openWindowForSSO } from "@/utils";
-
-const props = defineProps<{
- idp: IdentityProvider;
- isCreating?: boolean;
-}>();
-
-// Reactive state for the claims dialog
-const showClaimsDialog = ref(false);
-const testIdentityProviderResponse = ref<TestIdentityProviderResponse | null>(
- null
-);
-
-// Track current event listener to prevent duplicates
-const currentEventName = ref<string>("");
-
-// Track if test is in progress to prevent multiple calls
-const isTestingInProgress = ref(false);
-
-const loginWithIdentityProviderEventListener = async (event: Event) => {
- // Prevent multiple concurrent API calls
- if (isTestingInProgress.value) {
- return;
- }
-
- const payload = (event as CustomEvent).detail as OAuthWindowEventPayload;
- if (payload.error) {
- pushNotification({
- module: "bytebase",
- style: "CRITICAL",
- title: `Request error occurred`,
- description: payload.error,
- });
- return;
- }
-
- const code = payload.code;
- try {
- isTestingInProgress.value = true;
-
- // Send correct context type based on IdP type
- // OIDC providers use oidcContext, OAuth2 providers use oauth2Context
- const isOidc = props.idp.type === IdentityProviderType.OIDC;
-
- const request = create(TestIdentityProviderRequestSchema, {
- identityProvider: props.idp,
- context: isOidc
- ? {
- case: "oidcContext",
- value: {
- code: code,
- },
- }
- : {
- case: "oauth2Context",
- value: {
- code: code,
- },
- },
- });
- const response =
- await identityProviderServiceClientConnect.testIdentityProvider(request);
-
- testIdentityProviderResponse.value = response;
- showClaimsDialog.value = true;
- } catch (error) {
- pushNotification({
- module: "bytebase",
- style: "CRITICAL",
- title: `Request error occurred`,
- description: (error as ConnectError).message,
- });
- } finally {
- isTestingInProgress.value = false;
- }
-};
-
-const testConnection = async () => {
- // Prevent multiple test connections from running simultaneously
- if (isTestingInProgress.value) {
- return;
- }
-
- const { idp, isCreating } = props;
- if (
- idp.type === IdentityProviderType.OAUTH2 ||
- idp.type === IdentityProviderType.OIDC
- ) {
- let idpForTesting: IdentityProvider = idp;
- // For OIDC, we need to obtain the auth endpoint from the issuer in backend.
- if (isCreating && idp.type === IdentityProviderType.OIDC) {
- const request = create(CreateIdentityProviderRequestSchema, {
- identityProviderId: idp.name,
- identityProvider: idp,
- validateOnly: true,
- });
- const response =
- await identityProviderServiceClientConnect.createIdentityProvider(
- request
- );
- idpForTesting = response;
- }
-
- // Ensure event listener is set up for the correct IDP name
- const eventName = `bb.oauth.signin.${idpForTesting.name}`;
-
- // Remove any existing listener first.
- if (currentEventName.value) {
- window.removeEventListener(
- currentEventName.value,
- loginWithIdentityProviderEventListener,
- false
- );
- }
- // Add a new event listener.
- window.addEventListener(
- eventName,
- loginWithIdentityProviderEventListener,
- false
- );
- currentEventName.value = eventName;
-
- try {
- await openWindowForSSO(idpForTesting);
- } catch (error) {
- pushNotification({
- module: "bytebase",
- style: "CRITICAL",
- title: `Request error occurred`,
- description: (error as ConnectError).message,
- });
- }
- } else if (idp.type === IdentityProviderType.LDAP) {
- try {
- isTestingInProgress.value = true;
- const request = create(TestIdentityProviderRequestSchema, {
- identityProvider: idp,
- });
- const response =
- await identityProviderServiceClientConnect.testIdentityProvider(
- request
- );
-
- // Show claims in dialog (LDAP will have empty claims)
- testIdentityProviderResponse.value = response;
- showClaimsDialog.value = true;
- } catch (error) {
- pushNotification({
- module: "bytebase",
- style: "CRITICAL",
- title: `Request error occurred`,
- description: (error as ConnectError).message,
- });
- } finally {
- isTestingInProgress.value = false;
- }
- }
-};
-
-// Reset testing state when component unmounts
-onUnmounted(() => {
- if (currentEventName.value) {
- window.removeEventListener(
- currentEventName.value,
- loginWithIdentityProviderEventListener,
- false
- );
- currentEventName.value = "";
- }
- isTestingInProgress.value = false;
-});
-
-// Watch for dialog close to reset testing state if needed
-watch(showClaimsDialog, (newValue) => {
- if (!newValue) {
- // Reset testing state when dialog is closed
- isTestingInProgress.value = false;
- }
-});
-</script>
diff --git a/frontend/src/components/IdentityProvider/index.ts b/frontend/src/components/IdentityProvider/index.ts
deleted file mode 100644
index 5ace0dc8d5..0000000000
--- a/frontend/src/components/IdentityProvider/index.ts
+++ /dev/null
@@ -1,5 +0,0 @@
-export { default as IdentityProviderTable } from "./IdentityProviderTable.vue";
-export { default as IdentityProviderCreateWizard } from "./IdentityProviderCreateWizard.vue";
-export { default as IdentityProviderEditForm } from "./IdentityProviderEditForm.vue";
-export { default as IdentityProviderForm } from "./IdentityProviderForm.vue";
-export { default as IdentityProviderExternalURL } from "./IdentityProviderExternalURL.vue";
diff --git a/frontend/src/react/pages/settings/IDPDetailPage.tsx b/frontend/src/react/pages/settings/IDPDetailPage.tsx
new file mode 100644
index 0000000000..a1d0554811
--- /dev/null
+++ b/frontend/src/react/pages/settings/IDPDetailPage.tsx
@@ -0,0 +1,1646 @@
+import { create } from "@bufbuild/protobuf";
+import type { ConnectError } from "@connectrpc/connect";
+import { cloneDeep, isEqual } from "lodash-es";
+import { ArrowRight, Database, Info, Key, ShieldCheck, X } from "lucide-react";
+import { useCallback, useEffect, useMemo, useRef, useState } from "react";
+import { useTranslation } from "react-i18next";
+import { identityProviderServiceClientConnect } from "@/connect";
+import { ResourceIdField } from "@/react/components/ResourceIdField";
+import { Button } from "@/react/components/ui/button";
+import { Input } from "@/react/components/ui/input";
+import { useVueState } from "@/react/hooks/useVueState";
+import { router } from "@/router";
+import { WORKSPACE_ROUTE_IDENTITY_PROVIDERS } from "@/router/dashboard/workspaceRoutes";
+import { pushNotification } from "@/store";
+import { useIdentityProviderStore } from "@/store/modules/idp";
+import {
+ getIdentityProviderResourceId,
+ idpNamePrefix,
+} from "@/store/modules/v1/common";
+import type { OAuthWindowEventPayload } from "@/types";
+import type {
+ IdentityProvider,
+ LDAPIdentityProviderConfig,
+ OAuth2IdentityProviderConfig,
+ OIDCIdentityProviderConfig,
+ TestIdentityProviderResponse,
+} from "@/types/proto-es/v1/idp_service_pb";
+import {
+ FieldMappingSchema,
+ IdentityProviderConfigSchema,
+ IdentityProviderSchema,
+ IdentityProviderType,
+ LDAPIdentityProviderConfig_SecurityProtocol,
+ LDAPIdentityProviderConfigSchema,
+ OAuth2AuthStyle,
+ OAuth2IdentityProviderConfigSchema,
+ OIDCIdentityProviderConfigSchema,
+ TestIdentityProviderRequestSchema,
+} from "@/types/proto-es/v1/idp_service_pb";
+import {
+ hasWorkspacePermissionV2,
+ identityProviderTypeToString,
+ openWindowForSSO,
+} from "@/utils";
+
+// ============================================================
+// Types
+// ============================================================
+
+interface FieldMappingState {
+ identifier: string;
+ displayName: string;
+ phone: string;
+ groups: string;
+}
+
+// ============================================================
+// TestConnectionResultDialog
+// ============================================================
+
+function TestConnectionResultDialog({
+ response,
+ onClose,
+}: {
+ response: TestIdentityProviderResponse;
+ onClose: () => void;
+}) {
+ const { t } = useTranslation();
+
+ useEffect(() => {
+ const handler = (e: KeyboardEvent) => {
+ if (e.key === "Escape") onClose();
+ };
+ document.addEventListener("keydown", handler);
+ return () => document.removeEventListener("keydown", handler);
+ }, [onClose]);
+
+ return (
+ <div
+ className="fixed inset-0 z-[60] flex items-center justify-center bg-black/50"
+ onClick={(e) => {
+ if (e.target === e.currentTarget) onClose();
+ }}
+ >
+ <div className="bg-white rounded-lg shadow-lg w-[32rem] max-h-[80vh] overflow-auto p-6">
+ <div className="flex items-center justify-between mb-4">
+ <div className="flex items-center gap-x-2">
+ <div className="w-6 h-6 text-green-500">&#10003;</div>
+ <h3 className="text-lg font-medium">
+ {t("identity-provider.test-connection-success")}
+ </h3>
+ </div>
+ <Button variant="ghost" size="icon" onClick={onClose}>
+ <X className="h-4 w-4" />
+ </Button>
+ </div>
+
+ <div className="flex flex-col gap-y-4">
+ <p className="text-sm text-control-light">
+ {t("identity-provider.userinfo-description")}
+ </p>
+ <div className="bg-gray-50 rounded-lg p-4">
+ <div className="flex flex-col gap-y-1">
+ {Object.entries(response.userInfo).map(([key, value]) => (
+ <div
+ key={key}
+ className="grid grid-cols-3 gap-2 py-1 border-b border-gray-200 last:border-b-0"
+ >
+ <div
+ className="text-sm font-medium text-control truncate"
+ title={key}
+ >
+ {key}
+ </div>
+ <div
+ className="col-span-2 text-sm text-main break-all"
+ title={value}
+ >
+ {value}
+ </div>
+ </div>
+ ))}
+ </div>
+ </div>
+
+ <p className="text-sm text-control-light">
+ {t("identity-provider.claims-description")}
+ </p>
+ <div className="bg-gray-50 rounded-lg p-4">
+ {Object.keys(response.claims).length === 0 ? (
+ <div className="text-sm text-control-light italic">
+ {t("identity-provider.no-claims")}
+ </div>
+ ) : (
+ <div className="flex flex-col gap-y-1">
+ {Object.entries(response.claims).map(([key, value]) => (
+ <div
+ key={key}
+ className="grid grid-cols-3 gap-2 py-1 border-b border-gray-200 last:border-b-0"
+ >
+ <div
+ className="text-sm font-medium text-control truncate"
+ title={key}
+ >
+ {key}
+ </div>
+ <div
+ className="col-span-2 text-sm text-main break-all"
+ title={value}
+ >
+ {value}
+ </div>
+ </div>
+ ))}
+ </div>
+ )}
+ </div>
+ </div>
+
+ <div className="flex justify-end mt-4">
+ <Button onClick={onClose}>{t("common.close")}</Button>
+ </div>
+ </div>
+ </div>
+ );
+}
+
+// ============================================================
+// TestConnectionButton
+// ============================================================
+
+function TestConnectionButton({
+ idp,
+ disabled,
+}: {
+ idp: IdentityProvider;
+ disabled: boolean;
+}) {
+ const { t } = useTranslation();
+ const [testing, setTesting] = useState(false);
+ const [testResult, setTestResult] =
+ useState<TestIdentityProviderResponse | null>(null);
+ const currentEventNameRef = useRef("");
+ const idpRef = useRef(idp);
+ idpRef.current = idp;
+ const testingRef = useRef(false);
+
+ // Stable event handler that reads latest state via refs
+ const handleOAuthEventRef = useRef(async (event: Event) => {
+ if (testingRef.current) return;
+ const payload = (event as CustomEvent).detail as OAuthWindowEventPayload;
+ if (payload.error) {
+ pushNotification({
+ module: "bytebase",
+ style: "CRITICAL",
+ title: "Request error occurred",
+ description: payload.error,
+ });
+ return;
+ }
+
+ try {
+ testingRef.current = true;
+ setTesting(true);
+ const currentIdp = idpRef.current;
+ const isOidc = currentIdp.type === IdentityProviderType.OIDC;
+ const request = create(TestIdentityProviderRequestSchema, {
+ identityProvider: currentIdp,
+ context: isOidc
+ ? { case: "oidcContext", value: { code: payload.code } }
+ : { case: "oauth2Context", value: { code: payload.code } },
+ });
+ const response =
+ await identityProviderServiceClientConnect.testIdentityProvider(
+ request
+ );
+ setTestResult(response);
+ } catch (error) {
+ pushNotification({
+ module: "bytebase",
+ style: "CRITICAL",
+ title: "Request error occurred",
+ description: (error as ConnectError).message,
+ });
+ } finally {
+ testingRef.current = false;
+ setTesting(false);
+ }
+ });
+
+ useEffect(() => {
+ return () => {
+ if (currentEventNameRef.current) {
+ window.removeEventListener(
+ currentEventNameRef.current,
+ handleOAuthEventRef.current as EventListener,
+ false
+ );
+ }
+ };
+ }, []);
+
+ const testConnection = async () => {
+ if (testingRef.current) return;
+
+ if (
+ idp.type === IdentityProviderType.OAUTH2 ||
+ idp.type === IdentityProviderType.OIDC
+ ) {
+ const eventName = `bb.oauth.signin.${idp.name}`;
+ if (currentEventNameRef.current) {
+ window.removeEventListener(
+ currentEventNameRef.current,
+ handleOAuthEventRef.current as EventListener,
+ false
+ );
+ }
+ window.addEventListener(
+ eventName,
+ handleOAuthEventRef.current as EventListener,
+ false
+ );
+ currentEventNameRef.current = eventName;
+
+ try {
+ await openWindowForSSO(idp);
+ } catch (error) {
+ pushNotification({
+ module: "bytebase",
+ style: "CRITICAL",
+ title: "Request error occurred",
+ description: (error as ConnectError).message,
+ });
+ }
+ } else if (idp.type === IdentityProviderType.LDAP) {
+ try {
+ testingRef.current = true;
+ setTesting(true);
+ const request = create(TestIdentityProviderRequestSchema, {
+ identityProvider: idp,
+ });
+ const response =
+ await identityProviderServiceClientConnect.testIdentityProvider(
+ request
+ );
+ setTestResult(response);
+ } catch (error) {
+ pushNotification({
+ module: "bytebase",
+ style: "CRITICAL",
+ title: "Request error occurred",
+ description: (error as ConnectError).message,
+ });
+ } finally {
+ testingRef.current = false;
+ setTesting(false);
+ }
+ }
+ };
+
+ return (
+ <>
+ <Button
+ variant="outline"
+ disabled={disabled || testing}
+ onClick={testConnection}
+ >
+ {t("identity-provider.test-connection")}
+ </Button>
+ {testResult && (
+ <TestConnectionResultDialog
+ response={testResult}
+ onClose={() => setTestResult(null)}
+ />
+ )}
+ </>
+ );
+}
+
+// ============================================================
+// DeleteConfirmDialog
+// ============================================================
+
+function DeleteConfirmDialog({
+ onConfirm,
+ onCancel,
+}: {
+ onConfirm: () => void;
+ onCancel: () => void;
+}) {
+ const { t } = useTranslation();
+
+ useEffect(() => {
+ const handler = (e: KeyboardEvent) => {
+ if (e.key === "Escape") onCancel();
+ };
+ document.addEventListener("keydown", handler);
+ return () => document.removeEventListener("keydown", handler);
+ }, [onCancel]);
+
+ return (
+ <div
+ className="fixed inset-0 z-[60] flex items-center justify-center bg-black/50"
+ onClick={(e) => {
+ if (e.target === e.currentTarget) onCancel();
+ }}
+ >
+ <div className="bg-white rounded-lg shadow-lg w-96 p-6">
+ <h3 className="text-lg font-medium mb-2">{t("settings.sso.delete")}</h3>
+ <p className="text-sm text-gray-600 mb-6">
+ {t("identity-provider.delete-warning")}
+ </p>
+ <div className="flex justify-end gap-x-2">
+ <Button variant="outline" onClick={onCancel}>
+ {t("common.cancel")}
+ </Button>
+ <Button variant="destructive" onClick={onConfirm}>
+ {t("common.delete")}
+ </Button>
+ </div>
+ </div>
+ </div>
+ );
+}
+
+// ============================================================
+// ProviderConfigForm
+// ============================================================
+
+function ProviderConfigForm({
+ providerType,
+ configForOAuth2,
+ configForOIDC,
+ configForLDAP,
+ scopesString,
+ isEditMode,
+ onUpdateOAuth2,
+ onUpdateOIDC,
+ onUpdateLDAP,
+ onUpdateScopes,
+}: {
+ providerType: IdentityProviderType;
+ configForOAuth2: OAuth2IdentityProviderConfig;
+ configForOIDC: OIDCIdentityProviderConfig;
+ configForLDAP: LDAPIdentityProviderConfig;
+ scopesString: string;
+ isEditMode: boolean;
+ onUpdateOAuth2: (config: OAuth2IdentityProviderConfig) => void;
+ onUpdateOIDC: (config: OIDCIdentityProviderConfig) => void;
+ onUpdateLDAP: (config: LDAPIdentityProviderConfig) => void;
+ onUpdateScopes: (scopes: string) => void;
+}) {
+ const { t } = useTranslation();
+
+ if (providerType === IdentityProviderType.OAUTH2) {
+ return (
+ <div className="flex flex-col gap-y-6">
+ <div className="grid grid-cols-1 md:grid-cols-2 gap-6">
+ <div>
+ <label className="block text-base font-semibold text-gray-800 mb-2">
+ Client ID <span className="text-error">*</span>
+ </label>
+ <Input
+ value={configForOAuth2.clientId}
+ onChange={(e) =>
+ onUpdateOAuth2({
+ ...configForOAuth2,
+ clientId: e.target.value,
+ })
+ }
+ placeholder="e.g. 6655asd77895265aa110ac0d3"
+ />
+ </div>
+ <div>
+ <label className="block text-base font-semibold text-gray-800 mb-2">
+ Client Secret{" "}
+ {!isEditMode && <span className="text-error">*</span>}
+ </label>
+ <Input
+ type="password"
+ value={configForOAuth2.clientSecret}
+ onChange={(e) =>
+ onUpdateOAuth2({
+ ...configForOAuth2,
+ clientSecret: e.target.value,
+ })
+ }
+ placeholder={
+ isEditMode && !configForOAuth2.clientSecret
+ ? "Leave empty to keep existing secret"
+ : "e.g. 5bbezxc3972ca304de70c5d70a6aa932asd8"
+ }
+ />
+ </div>
+ </div>
+
+ <div>
+ <label className="block text-base font-semibold text-gray-800 mb-2">
+ {t("settings.sso.form.auth-url")}{" "}
+ <span className="text-error">*</span>
+ </label>
+ <Input
+ value={configForOAuth2.authUrl}
+ onChange={(e) =>
+ onUpdateOAuth2({ ...configForOAuth2, authUrl: e.target.value })
+ }
+ placeholder={t("settings.sso.form.auth-url-placeholder")}
+ />
+ <p className="text-sm text-gray-600 mt-1">
+ {t("settings.sso.form.auth-url-description")}
+ </p>
+ </div>
+
+ <div>
+ <label className="block text-base font-semibold text-gray-800 mb-2">
+ {t("settings.sso.form.token-url")}{" "}
+ <span className="text-error">*</span>
+ </label>
+ <Input
+ value={configForOAuth2.tokenUrl}
+ onChange={(e) =>
+ onUpdateOAuth2({ ...configForOAuth2, tokenUrl: e.target.value })
+ }
+ placeholder={t("settings.sso.form.token-url-placeholder")}
+ />
+ <p className="text-sm text-gray-600 mt-1">
+ {t("settings.sso.form.token-url-description")}
+ </p>
+ </div>
+
+ <div>
+ <label className="block text-base font-semibold text-gray-800 mb-2">
+ {t("settings.sso.form.user-info-url")}{" "}
+ <span className="text-error">*</span>
+ </label>
+ <Input
+ value={configForOAuth2.userInfoUrl}
+ onChange={(e) =>
+ onUpdateOAuth2({
+ ...configForOAuth2,
+ userInfoUrl: e.target.value,
+ })
+ }
+ placeholder={t("settings.sso.form.user-info-url-placeholder")}
+ />
+ <p className="text-sm text-gray-600 mt-1">
+ {t("settings.sso.form.user-info-url-description")}
+ </p>
+ </div>
+
+ <div>
+ <label className="block text-base font-semibold text-gray-800 mb-2">
+ {t("settings.sso.form.scopes")}{" "}
+ <span className="text-error">*</span>
+ </label>
+ <Input
+ value={scopesString}
+ onChange={(e) => onUpdateScopes(e.target.value)}
+ placeholder={t("settings.sso.form.scopes-placeholder")}
+ />
+ <p className="text-sm text-gray-600 mt-1">
+ {t("settings.sso.form.scopes-description")}
+ </p>
+ </div>
+
+ <div>
+ <label className="block text-base font-semibold text-gray-800 mb-3">
+ {t("settings.sso.form.authentication-style")}{" "}
+ <span className="text-error">*</span>
+ </label>
+ <div className="flex flex-col gap-y-3">
+ <label className="flex items-start gap-x-3 cursor-pointer">
+ <input
+ type="radio"
+ name="oauth2-auth-style"
+ checked={
+ configForOAuth2.authStyle === OAuth2AuthStyle.IN_PARAMS
+ }
+ onChange={() =>
+ onUpdateOAuth2({
+ ...configForOAuth2,
+ authStyle: OAuth2AuthStyle.IN_PARAMS,
+ })
+ }
+ className="mt-1"
+ />
+ <div>
+ <div className="font-medium">
+ {t("settings.sso.form.in-parameters")}
+ </div>
+ <div className="text-sm text-gray-600">
+ {t("settings.sso.form.in-parameters-description")}
+ </div>
+ </div>
+ </label>
+ <label className="flex items-start gap-x-3 cursor-pointer">
+ <input
+ type="radio"
+ name="oauth2-auth-style"
+ checked={
+ configForOAuth2.authStyle === OAuth2AuthStyle.IN_HEADER
+ }
+ onChange={() =>
+ onUpdateOAuth2({
+ ...configForOAuth2,
+ authStyle: OAuth2AuthStyle.IN_HEADER,
+ })
+ }
+ className="mt-1"
+ />
+ <div>
+ <div className="font-medium">
+ {t("settings.sso.form.in-header")}
+ </div>
+ <div className="text-sm text-gray-600">
+ {t("settings.sso.form.in-header-description")}
+ </div>
+ </div>
+ </label>
+ </div>
+ </div>
+
+ <div>
+ <label className="block text-base font-semibold text-gray-800 mb-3">
+ {t("settings.sso.form.security-options")}
+ </label>
+ <label className="flex items-center gap-x-2 cursor-pointer">
+ <input
+ type="checkbox"
+ checked={configForOAuth2.skipTlsVerify}
+ onChange={(e) =>
+ onUpdateOAuth2({
+ ...configForOAuth2,
+ skipTlsVerify: e.target.checked,
+ })
+ }
+ />
+ <span>{t("settings.sso.form.skip-tls-verification")}</span>
+ </label>
+ <p className="text-sm text-gray-600 mt-1 ml-6">
+ {t("settings.sso.form.skip-tls-warning")}
+ </p>
+ </div>
+ </div>
+ );
+ }
+
+ if (providerType === IdentityProviderType.OIDC) {
+ return (
+ <div className="flex flex-col gap-y-6">
+ <div>
+ <label className="block text-base font-semibold text-gray-800 mb-2">
+ Issuer URL <span className="text-error">*</span>
+ </label>
+ <Input
+ value={configForOIDC.issuer}
+ onChange={(e) =>
+ onUpdateOIDC({ ...configForOIDC, issuer: e.target.value })
+ }
+ placeholder={t("settings.sso.form.issuer-url-placeholder")}
+ />
+ <p className="text-sm text-gray-600 mt-1">
+ {t("settings.sso.form.issuer-url-description")}
+ </p>
+ </div>
+
+ <div className="grid grid-cols-1 md:grid-cols-2 gap-6">
+ <div>
+ <label className="block text-base font-semibold text-gray-800 mb-2">
+ Client ID <span className="text-error">*</span>
+ </label>
+ <Input
+ value={configForOIDC.clientId}
+ onChange={(e) =>
+ onUpdateOIDC({ ...configForOIDC, clientId: e.target.value })
+ }
+ placeholder="e.g. 6655asd77895265aa110ac0d3"
+ />
+ </div>
+ <div>
+ <label className="block text-base font-semibold text-gray-800 mb-2">
+ Client Secret{" "}
+ {!isEditMode && <span className="text-error">*</span>}
+ </label>
+ <Input
+ type="password"
+ value={configForOIDC.clientSecret}
+ onChange={(e) =>
+ onUpdateOIDC({
+ ...configForOIDC,
+ clientSecret: e.target.value,
+ })
+ }
+ placeholder={
+ isEditMode && !configForOIDC.clientSecret
+ ? "Leave empty to keep existing secret"
+ : "e.g. 5bbezxc3972ca304de70c5d70a6aa932asd8"
+ }
+ />
+ </div>
+ </div>
+
+ <div>
+ <label className="block text-base font-semibold text-gray-800 mb-2">
+ {t("settings.sso.form.scopes")}{" "}
+ <span className="text-error">*</span>
+ </label>
+ <Input
+ value={scopesString}
+ onChange={(e) => onUpdateScopes(e.target.value)}
+ placeholder={t("settings.sso.form.scopes-placeholder-oidc")}
+ />
+ <p className="text-sm text-gray-600 mt-1">
+ {t("settings.sso.form.openid-scopes-description")}
+ </p>
+ </div>
+
+ <div>
+ <label className="block text-base font-semibold text-gray-800 mb-3">
+ {t("settings.sso.form.authentication-style")}{" "}
+ <span className="text-error">*</span>
+ </label>
+ <div className="flex flex-col gap-y-3">
+ <label className="flex items-start gap-x-3 cursor-pointer">
+ <input
+ type="radio"
+ name="oidc-auth-style"
+ checked={configForOIDC.authStyle === OAuth2AuthStyle.IN_PARAMS}
+ onChange={() =>
+ onUpdateOIDC({
+ ...configForOIDC,
+ authStyle: OAuth2AuthStyle.IN_PARAMS,
+ })
+ }
+ className="mt-1"
+ />
+ <div>
+ <div className="font-medium">
+ {t("settings.sso.form.in-parameters")}
+ </div>
+ <div className="text-sm text-gray-600">
+ {t("settings.sso.form.in-parameters-description")}
+ </div>
+ </div>
+ </label>
+ <label className="flex items-start gap-x-3 cursor-pointer">
+ <input
+ type="radio"
+ name="oidc-auth-style"
+ checked={configForOIDC.authStyle === OAuth2AuthStyle.IN_HEADER}
+ onChange={() =>
+ onUpdateOIDC({
+ ...configForOIDC,
+ authStyle: OAuth2AuthStyle.IN_HEADER,
+ })
+ }
+ className="mt-1"
+ />
+ <div>
+ <div className="font-medium">
+ {t("settings.sso.form.in-header")}
+ </div>
+ <div className="text-sm text-gray-600">
+ {t("settings.sso.form.in-header-description")}
+ </div>
+ </div>
+ </label>
+ </div>
+ </div>
+
+ <div>
+ <label className="block text-base font-semibold text-gray-800 mb-3">
+ {t("settings.sso.form.security-options")}
+ </label>
+ <label className="flex items-center gap-x-2 cursor-pointer">
+ <input
+ type="checkbox"
+ checked={configForOIDC.skipTlsVerify}
+ onChange={(e) =>
+ onUpdateOIDC({
+ ...configForOIDC,
+ skipTlsVerify: e.target.checked,
+ })
+ }
+ />
+ <span>{t("settings.sso.form.skip-tls-verification")}</span>
+ </label>
+ <p className="text-sm text-gray-600 mt-1 ml-6">
+ {t("settings.sso.form.skip-tls-warning")}
+ </p>
+ </div>
+ </div>
+ );
+ }
+
+ if (providerType === IdentityProviderType.LDAP) {
+ return (
+ <div className="flex flex-col gap-y-6">
+ <div className="grid grid-cols-1 md:grid-cols-3 gap-6">
+ <div className="md:col-span-2">
+ <label className="block text-base font-semibold text-gray-800 mb-2">
+ Host <span className="text-error">*</span>
+ </label>
+ <Input
+ value={configForLDAP.host}
+ onChange={(e) =>
+ onUpdateLDAP({ ...configForLDAP, host: e.target.value })
+ }
+ placeholder={t("settings.sso.form.host-placeholder")}
+ />
+ </div>
+ <div>
+ <label className="block text-base font-semibold text-gray-800 mb-2">
+ Port <span className="text-error">*</span>
+ </label>
+ <input
+ type="number"
+ value={configForLDAP.port}
+ onChange={(e) =>
+ onUpdateLDAP({
+ ...configForLDAP,
+ port: parseInt(e.target.value, 10) || 0,
+ })
+ }
+ min={1}
+ max={65535}
+ placeholder="389"
+ className="flex h-9 w-full rounded-md border border-control-border bg-transparent px-3 py-1 text-sm"
+ />
+ </div>
+ </div>
+
+ <div>
+ <label className="block text-base font-semibold text-gray-800 mb-2">
+ {t("settings.sso.form.bind-dn")}{" "}
+ <span className="text-error">*</span>
+ </label>
+ <Input
+ value={configForLDAP.bindDn}
+ onChange={(e) =>
+ onUpdateLDAP({ ...configForLDAP, bindDn: e.target.value })
+ }
+ placeholder={t("settings.sso.form.bind-dn-placeholder")}
+ />
+ <p className="text-sm text-gray-600 mt-1">
+ {t("settings.sso.form.bind-dn-description")}
+ </p>
+ </div>
+
+ <div>
+ <label className="block text-base font-semibold text-gray-800 mb-2">
+ {t("settings.sso.form.bind-password")}{" "}
+ {!isEditMode && <span className="text-error">*</span>}
+ </label>
+ <Input
+ type="password"
+ value={configForLDAP.bindPassword}
+ onChange={(e) =>
+ onUpdateLDAP({
+ ...configForLDAP,
+ bindPassword: e.target.value,
+ })
+ }
+ placeholder={
+ isEditMode && !configForLDAP.bindPassword
+ ? "Leave empty to keep existing password"
+ : "••••••••"
+ }
+ />
+ </div>
+
+ <div>
+ <label className="block text-base font-semibold text-gray-800 mb-2">
+ {t("settings.sso.form.base-dn")}{" "}
+ <span className="text-error">*</span>
+ </label>
+ <Input
+ value={configForLDAP.baseDn}
+ onChange={(e) =>
+ onUpdateLDAP({ ...configForLDAP, baseDn: e.target.value })
+ }
+ placeholder={t("settings.sso.form.base-dn-placeholder")}
+ />
+ <p className="text-sm text-gray-600 mt-1">
+ {t("settings.sso.form.base-dn-description")}
+ </p>
+ </div>
+
+ <div>
+ <label className="block text-base font-semibold text-gray-800 mb-2">
+ {t("settings.sso.form.user-filter")}{" "}
+ <span className="text-error">*</span>
+ </label>
+ <Input
+ value={configForLDAP.userFilter}
+ onChange={(e) =>
+ onUpdateLDAP({ ...configForLDAP, userFilter: e.target.value })
+ }
+ placeholder={t("settings.sso.form.user-filter-placeholder")}
+ />
+ <p className="text-sm text-gray-600 mt-1">
+ {t("settings.sso.form.user-filter-description")}
+ </p>
+ </div>
+
+ <div>
+ <label className="block text-base font-semibold text-gray-800 mb-3">
+ {t("settings.sso.form.security-protocol")}{" "}
+ <span className="text-error">*</span>
+ </label>
+ <div className="flex flex-col gap-y-3">
+ <label className="flex items-start gap-x-3 cursor-pointer">
+ <input
+ type="radio"
+ name="ldap-security"
+ checked={
+ configForLDAP.securityProtocol ===
+ LDAPIdentityProviderConfig_SecurityProtocol.START_TLS
+ }
+ onChange={() =>
+ onUpdateLDAP({
+ ...configForLDAP,
+ securityProtocol:
+ LDAPIdentityProviderConfig_SecurityProtocol.START_TLS,
+ })
+ }
+ className="mt-1"
+ />
+ <div>
+ <div className="font-medium">
+ {t("settings.sso.form.starttls")}
+ </div>
+ <div className="text-sm text-gray-600">
+ {t("settings.sso.form.starttls-description")}
+ </div>
+ </div>
+ </label>
+ <label className="flex items-start gap-x-3 cursor-pointer">
+ <input
+ type="radio"
+ name="ldap-security"
+ checked={
+ configForLDAP.securityProtocol ===
+ LDAPIdentityProviderConfig_SecurityProtocol.LDAPS
+ }
+ onChange={() =>
+ onUpdateLDAP({
+ ...configForLDAP,
+ securityProtocol:
+ LDAPIdentityProviderConfig_SecurityProtocol.LDAPS,
+ })
+ }
+ className="mt-1"
+ />
+ <div>
+ <div className="font-medium">
+ {t("settings.sso.form.ldaps")}
+ </div>
+ <div className="text-sm text-gray-600">
+ {t("settings.sso.form.ldaps-description")}
+ </div>
+ </div>
+ </label>
+ <label className="flex items-start gap-x-3 cursor-pointer">
+ <input
+ type="radio"
+ name="ldap-security"
+ checked={
+ configForLDAP.securityProtocol ===
+ LDAPIdentityProviderConfig_SecurityProtocol.SECURITY_PROTOCOL_UNSPECIFIED
+ }
+ onChange={() =>
+ onUpdateLDAP({
+ ...configForLDAP,
+ securityProtocol:
+ LDAPIdentityProviderConfig_SecurityProtocol.SECURITY_PROTOCOL_UNSPECIFIED,
+ })
+ }
+ className="mt-1"
+ />
+ <div>
+ <div className="font-medium">{t("settings.sso.form.none")}</div>
+ <div className="text-sm text-gray-600">
+ {t("settings.sso.form.none-description")}
+ </div>
+ </div>
+ </label>
+ </div>
+ </div>
+
+ <div>
+ <label className="block text-base font-semibold text-gray-800 mb-3">
+ {t("settings.sso.form.security-options")}
+ </label>
+ <label className="flex items-center gap-x-2 cursor-pointer">
+ <input
+ type="checkbox"
+ checked={configForLDAP.skipTlsVerify}
+ onChange={(e) =>
+ onUpdateLDAP({
+ ...configForLDAP,
+ skipTlsVerify: e.target.checked,
+ })
+ }
+ />
+ <span>{t("settings.sso.form.skip-tls-verification")}</span>
+ </label>
+ <p className="text-sm text-gray-600 mt-1 ml-6">
+ {t("settings.sso.form.skip-tls-warning")}
+ </p>
+ </div>
+ </div>
+ );
+ }
+
+ return null;
+}
+
+// ============================================================
+// FieldMappingForm
+// ============================================================
+
+function FieldMappingForm({
+ providerType,
+ fieldMapping,
+ onChange,
+}: {
+ providerType: IdentityProviderType;
+ fieldMapping: FieldMappingState;
+ onChange: (mapping: FieldMappingState) => void;
+}) {
+ const { t } = useTranslation();
+
+ return (
+ <div className="flex flex-col gap-y-6">
+ <div className="grid grid-cols-[256px_1fr] gap-4 items-center">
+ <Input
+ value={fieldMapping.identifier}
+ onChange={(e) =>
+ onChange({ ...fieldMapping, identifier: e.target.value })
+ }
+ placeholder={t("settings.sso.form.identifier-placeholder")}
+ />
+ <div className="flex items-center text-base">
+ <ArrowRight className="mx-2 h-5 w-5 text-gray-400" />
+ <p className="flex items-center font-semibold text-gray-800">
+ {t("settings.sso.form.identifier")}
+ <span className="ml-0.5 text-error">*</span>
+ <span
+ className="ml-1"
+ title={t("settings.sso.form.identifier-tips")}
+ >
+ <Info className="w-4 h-4 text-blue-500" />
+ </span>
+ </p>
+ </div>
+ </div>
+
+ <div className="grid grid-cols-[256px_1fr] gap-4 items-center">
+ <Input
+ value={fieldMapping.displayName}
+ onChange={(e) =>
+ onChange({ ...fieldMapping, displayName: e.target.value })
+ }
+ placeholder={t("settings.sso.form.display-name-placeholder")}
+ />
+ <div className="flex items-center text-base">
+ <ArrowRight className="mx-2 h-5 w-5 text-gray-400" />
+ <p className="font-semibold text-gray-800">
+ {t("settings.sso.form.display-name")}
+ </p>
+ </div>
+ </div>
+
+ <div className="grid grid-cols-[256px_1fr] gap-4 items-center">
+ <Input
+ value={fieldMapping.phone}
+ onChange={(e) => onChange({ ...fieldMapping, phone: e.target.value })}
+ placeholder={t("settings.sso.form.phone-placeholder")}
+ />
+ <div className="flex items-center text-base">
+ <ArrowRight className="mx-2 h-5 w-5 text-gray-400" />
+ <p className="font-semibold text-gray-800">
+ {t("settings.sso.form.phone")}
+ </p>
+ </div>
+ </div>
+
+ {providerType === IdentityProviderType.OIDC && (
+ <>
+ <div className="grid grid-cols-[256px_1fr] gap-4 items-center">
+ <Input
+ value={fieldMapping.groups}
+ onChange={(e) =>
+ onChange({ ...fieldMapping, groups: e.target.value })
+ }
+ placeholder={t("settings.sso.form.groups-placeholder")}
+ />
+ <div className="flex items-center text-base">
+ <ArrowRight className="mx-2 h-5 w-5 text-gray-400" />
+ <p className="font-semibold text-gray-800">
+ {t("settings.sso.form.groups")}
+ </p>
+ </div>
+ </div>
+ <p className="text-sm text-gray-600">
+ {t("settings.sso.form.groups-description")}
+ </p>
+ </>
+ )}
+ </div>
+ );
+}
+
+// ============================================================
+// Helper functions
+// ============================================================
+
+function getProviderIcon(type: IdentityProviderType) {
+ switch (type) {
+ case IdentityProviderType.OAUTH2:
+ return Key;
+ case IdentityProviderType.OIDC:
+ return ShieldCheck;
+ case IdentityProviderType.LDAP:
+ return Database;
+ default:
+ return Key;
+ }
+}
+
+function extractConfigState(idp: IdentityProvider) {
+ let configForOAuth2 = create(OAuth2IdentityProviderConfigSchema, {});
+ let configForOIDC = create(OIDCIdentityProviderConfigSchema, {});
+ let configForLDAP = create(LDAPIdentityProviderConfigSchema, {});
+ let scopesString = "";
+ const fieldMapping: FieldMappingState = {
+ identifier: "",
+ displayName: "",
+ phone: "",
+ groups: "",
+ };
+
+ if (idp.config?.config?.case === "oauth2Config") {
+ const cfg = idp.config.config.value;
+ configForOAuth2 = create(OAuth2IdentityProviderConfigSchema, cfg);
+ scopesString = (cfg.scopes || []).join(" ");
+ if (cfg.fieldMapping) {
+ fieldMapping.identifier = cfg.fieldMapping.identifier;
+ fieldMapping.displayName = cfg.fieldMapping.displayName;
+ fieldMapping.phone = cfg.fieldMapping.phone;
+ fieldMapping.groups = cfg.fieldMapping.groups;
+ }
+ } else if (idp.config?.config?.case === "oidcConfig") {
+ const cfg = idp.config.config.value;
+ configForOIDC = create(OIDCIdentityProviderConfigSchema, cfg);
+ scopesString = (cfg.scopes || []).join(" ");
+ if (cfg.fieldMapping) {
+ fieldMapping.identifier = cfg.fieldMapping.identifier;
+ fieldMapping.displayName = cfg.fieldMapping.displayName;
+ fieldMapping.phone = cfg.fieldMapping.phone;
+ fieldMapping.groups = cfg.fieldMapping.groups;
+ }
+ } else if (idp.config?.config?.case === "ldapConfig") {
+ const cfg = idp.config.config.value;
+ configForLDAP = create(LDAPIdentityProviderConfigSchema, cfg);
+ if (cfg.fieldMapping) {
+ fieldMapping.identifier = cfg.fieldMapping.identifier;
+ fieldMapping.displayName = cfg.fieldMapping.displayName;
+ fieldMapping.phone = cfg.fieldMapping.phone;
+ fieldMapping.groups = cfg.fieldMapping.groups;
+ }
+ }
+
+ return {
+ configForOAuth2,
+ configForOIDC,
+ configForLDAP,
+ scopesString,
+ fieldMapping,
+ };
+}
+
+// ============================================================
+// IDPDetailPage
+// ============================================================
+
+export function IDPDetailPage() {
+ const { t } = useTranslation();
+ const identityProviderStore = useIdentityProviderStore();
+
+ // Reactively read idpId from Vue Router's current route params
+ const idpId = useVueState(
+ () => router.currentRoute.value.params.idpId as string | undefined
+ );
+
+ const [isLoading, setIsLoading] = useState(true);
+ const [isUpdating, setIsUpdating] = useState(false);
+ const [showDeleteConfirm, setShowDeleteConfirm] = useState(false);
+
+ // The original IDP from the store
+ const [originalIdp, setOriginalIdp] = useState<IdentityProvider | null>(null);
+
+ // Local editable state
+ const [localIdp, setLocalIdp] = useState<IdentityProvider | null>(null);
+ const [configForOAuth2, setConfigForOAuth2] =
+ useState<OAuth2IdentityProviderConfig>(
+ create(OAuth2IdentityProviderConfigSchema, {})
+ );
+ const [configForOIDC, setConfigForOIDC] =
+ useState<OIDCIdentityProviderConfig>(
+ create(OIDCIdentityProviderConfigSchema, {})
+ );
+ const [configForLDAP, setConfigForLDAP] =
+ useState<LDAPIdentityProviderConfig>(
+ create(LDAPIdentityProviderConfigSchema, {})
+ );
+ const [scopesString, setScopesString] = useState("");
+ const [fieldMapping, setFieldMapping] = useState<FieldMappingState>({
+ identifier: "",
+ displayName: "",
+ phone: "",
+ groups: "",
+ });
+
+ // Track whether secrets have been modified from the initial empty state
+ const initializedRef = useRef(false);
+ const [isClientSecretModified, setIsClientSecretModified] = useState(false);
+ const [isBindPasswordModified, setIsBindPasswordModified] = useState(false);
+
+ const idpName = useMemo(() => {
+ if (!idpId) return "";
+ return `${idpNamePrefix}${idpId}`;
+ }, [idpId]);
+
+ const initializeFromIdp = useCallback((idp: IdentityProvider) => {
+ setLocalIdp(cloneDeep(idp));
+ setIsClientSecretModified(false);
+ setIsBindPasswordModified(false);
+
+ const state = extractConfigState(idp);
+ setConfigForOAuth2(state.configForOAuth2);
+ setConfigForOIDC(state.configForOIDC);
+ setConfigForLDAP(state.configForLDAP);
+ setScopesString(state.scopesString);
+ setFieldMapping(state.fieldMapping);
+ initializedRef.current = true;
+ }, []);
+
+ // Fetch the IDP
+ useEffect(() => {
+ if (!idpName) {
+ setIsLoading(false);
+ return;
+ }
+
+ let cancelled = false;
+ setIsLoading(true);
+ setOriginalIdp(null);
+ setLocalIdp(null);
+ initializedRef.current = false;
+
+ identityProviderStore
+ .getOrFetchIdentityProviderByName(idpName)
+ .then((idp) => {
+ if (cancelled) return;
+ if (idp) {
+ setOriginalIdp(idp);
+ initializeFromIdp(idp);
+ }
+ })
+ .catch(() => {
+ if (cancelled) return;
+ setOriginalIdp(null);
+ setLocalIdp(null);
+ })
+ .finally(() => {
+ if (!cancelled) setIsLoading(false);
+ });
+
+ return () => {
+ cancelled = true;
+ };
+ }, [idpName, identityProviderStore, initializeFromIdp]);
+
+ const resourceId = useMemo(() => {
+ if (!localIdp) return "";
+ return getIdentityProviderResourceId(localIdp.name);
+ }, [localIdp]);
+
+ const allowEdit = hasWorkspacePermissionV2("bb.identityProviders.update");
+
+ const buildUpdatedIdentityProvider =
+ useCallback((): IdentityProvider | null => {
+ if (!localIdp) return null;
+
+ const result = create(IdentityProviderSchema, {
+ ...localIdp,
+ config: create(IdentityProviderConfigSchema, {}),
+ });
+
+ if (localIdp.type === IdentityProviderType.OAUTH2) {
+ result.config = create(IdentityProviderConfigSchema, {
+ config: {
+ case: "oauth2Config",
+ value: {
+ ...configForOAuth2,
+ scopes: scopesString.split(" ").filter(Boolean),
+ fieldMapping: create(FieldMappingSchema, fieldMapping),
+ },
+ },
+ });
+ } else if (localIdp.type === IdentityProviderType.OIDC) {
+ result.config = create(IdentityProviderConfigSchema, {
+ config: {
+ case: "oidcConfig",
+ value: {
+ ...configForOIDC,
+ scopes: scopesString.split(" ").filter(Boolean),
+ fieldMapping: create(FieldMappingSchema, fieldMapping),
+ },
+ },
+ });
+ } else if (localIdp.type === IdentityProviderType.LDAP) {
+ result.config = create(IdentityProviderConfigSchema, {
+ config: {
+ case: "ldapConfig",
+ value: {
+ ...configForLDAP,
+ fieldMapping: create(FieldMappingSchema, fieldMapping),
+ },
+ },
+ });
+ }
+
+ return result;
+ }, [
+ localIdp,
+ configForOAuth2,
+ configForOIDC,
+ configForLDAP,
+ scopesString,
+ fieldMapping,
+ ]);
+
+ const hasChanges = useMemo(() => {
+ if (!originalIdp) return false;
+ const current = buildUpdatedIdentityProvider();
+ if (!current) return false;
+ return !isEqual(current, originalIdp);
+ }, [originalIdp, buildUpdatedIdentityProvider]);
+
+ const isFormValid = useMemo(() => {
+ if (!localIdp) return false;
+ if (!localIdp.title) return false;
+ if (!fieldMapping.identifier) return false;
+
+ if (localIdp.type === IdentityProviderType.OAUTH2) {
+ const isClientSecretValid = isClientSecretModified
+ ? !!configForOAuth2.clientSecret
+ : true;
+ return !!(
+ configForOAuth2.clientId &&
+ isClientSecretValid &&
+ configForOAuth2.authUrl &&
+ configForOAuth2.tokenUrl &&
+ configForOAuth2.userInfoUrl
+ );
+ } else if (localIdp.type === IdentityProviderType.OIDC) {
+ const isClientSecretValid = isClientSecretModified
+ ? !!configForOIDC.clientSecret
+ : true;
+ return !!(
+ configForOIDC.clientId &&
+ isClientSecretValid &&
+ configForOIDC.issuer
+ );
+ } else if (localIdp.type === IdentityProviderType.LDAP) {
+ const isBindPasswordValid = isBindPasswordModified
+ ? !!configForLDAP.bindPassword
+ : true;
+ return !!(
+ configForLDAP.host &&
+ configForLDAP.port &&
+ configForLDAP.bindDn &&
+ isBindPasswordValid &&
+ configForLDAP.baseDn &&
+ configForLDAP.userFilter
+ );
+ }
+
+ return false;
+ }, [
+ localIdp,
+ fieldMapping.identifier,
+ configForOAuth2,
+ configForOIDC,
+ configForLDAP,
+ isClientSecretModified,
+ isBindPasswordModified,
+ ]);
+
+ const canUpdate = allowEdit && hasChanges && isFormValid;
+
+ const handleUpdate = async () => {
+ if (!canUpdate) return;
+ const updated = buildUpdatedIdentityProvider();
+ if (!updated) return;
+
+ setIsUpdating(true);
+ try {
+ const updatedProvider =
+ await identityProviderStore.patchIdentityProvider(updated);
+
+ pushNotification({
+ module: "bytebase",
+ style: "SUCCESS",
+ title: t("common.updated"),
+ });
+
+ setOriginalIdp(updatedProvider);
+ initializeFromIdp(updatedProvider);
+ } catch {
+ pushNotification({
+ module: "bytebase",
+ style: "CRITICAL",
+ title: t("identity-provider.identity-provider-update-failed"),
+ });
+ } finally {
+ setIsUpdating(false);
+ }
+ };
+
+ const handleDiscard = () => {
+ if (originalIdp) {
+ initializeFromIdp(originalIdp);
+ }
+ };
+
+ const handleDelete = async () => {
+ if (!hasWorkspacePermissionV2("bb.identityProviders.delete")) {
+ pushNotification({
+ module: "bytebase",
+ style: "WARN",
+ title: t("identity-provider.identity-provider-permission-denied"),
+ });
+ return;
+ }
+
+ if (!originalIdp) return;
+
+ try {
+ await identityProviderStore.deleteIdentityProvider(originalIdp.name);
+
+ pushNotification({
+ module: "bytebase",
+ style: "SUCCESS",
+ title: t("identity-provider.identity-provider-deleted"),
+ });
+
+ router.replace({
+ name: WORKSPACE_ROUTE_IDENTITY_PROVIDERS,
+ });
+ } catch {
+ pushNotification({
+ module: "bytebase",
+ style: "CRITICAL",
+ title: t("identity-provider.identity-provider-delete-failed"),
+ });
+ }
+
+ setShowDeleteConfirm(false);
+ };
+
+ const handleOAuth2Update = useCallback(
+ (config: OAuth2IdentityProviderConfig) => {
+ if (
+ initializedRef.current &&
+ config.clientSecret !== configForOAuth2.clientSecret
+ ) {
+ setIsClientSecretModified(true);
+ }
+ setConfigForOAuth2(config);
+ },
+ [configForOAuth2.clientSecret]
+ );
+
+ const handleOIDCUpdate = useCallback(
+ (config: OIDCIdentityProviderConfig) => {
+ if (
+ initializedRef.current &&
+ config.clientSecret !== configForOIDC.clientSecret
+ ) {
+ setIsClientSecretModified(true);
+ }
+ setConfigForOIDC(config);
+ },
+ [configForOIDC.clientSecret]
+ );
+
+ const handleLDAPUpdate = useCallback(
+ (config: LDAPIdentityProviderConfig) => {
+ if (
+ initializedRef.current &&
+ config.bindPassword !== configForLDAP.bindPassword
+ ) {
+ setIsBindPasswordModified(true);
+ }
+ setConfigForLDAP(config);
+ },
+ [configForLDAP.bindPassword]
+ );
+
+ const builtIdp = useMemo(
+ () => buildUpdatedIdentityProvider(),
+ [buildUpdatedIdentityProvider]
+ );
+
+ // Loading state
+ if (isLoading) {
+ return (
+ <div className="w-full h-64 flex items-center justify-center">
+ <div className="animate-spin rounded-full h-8 w-8 border-b-2 border-accent" />
+ </div>
+ );
+ }
+
+ if (!localIdp) {
+ return (
+ <div className="w-full h-64 flex items-center justify-center text-control-light">
+ {t("error-page.not-found")}
+ </div>
+ );
+ }
+
+ const ProviderIcon = getProviderIcon(localIdp.type);
+
+ return (
+ <div className="w-full px-4 py-4 flex flex-col gap-y-6">
+ <div className="textinfolabel">
+ {t("settings.sso.description")}{" "}
+ <a
+ href="https://docs.bytebase.com/administration/sso/overview?source=console"
+ target="_blank"
+ rel="noopener noreferrer"
+ className="text-accent hover:underline"
+ >
+ {t("common.learn-more")}
+ </a>
+ </div>
+
+ <div className="divide-y divide-block-border">
+ {/* General Section */}
+ <div className="pb-6 lg:flex">
+ <div className="text-left lg:w-1/4">
+ <h1 className="text-3xl font-bold text-gray-900">
+ {t("common.general")}
+ </h1>
+ </div>
+ <div className="flex-1 mt-4 lg:px-4 lg:mt-0 flex flex-col gap-y-6">
+ <div>
+ <p className="text-base font-semibold text-gray-800 mb-2">
+ {t("common.type")}
+ </p>
+ <div className="flex items-center gap-x-3 p-3 bg-gray-50 rounded-md">
+ <ProviderIcon className="w-5 h-5 text-gray-600" />
+ <span className="text-base font-medium text-gray-800">
+ {identityProviderTypeToString(localIdp.type)}
+ </span>
+ </div>
+ <p className="text-sm text-gray-600 mt-1">
+ {t("settings.sso.form.provider-type-readonly-hint")}
+ </p>
+ </div>
+
+ <div>
+ <p className="text-base font-semibold text-gray-800 mb-2">
+ {t("settings.sso.form.name")}{" "}
+ <span className="text-error">*</span>
+ </p>
+ <Input
+ value={localIdp.title}
+ disabled={!allowEdit}
+ onChange={(e) =>
+ setLocalIdp({ ...localIdp, title: e.target.value })
+ }
+ placeholder={t("settings.sso.form.name-description")}
+ maxLength={200}
+ />
+ <div className="mt-1">
+ <ResourceIdField
+ resourceType="idp"
+ readonly={true}
+ value={resourceId}
+ resourceName={localIdp.name}
+ />
+ </div>
+ </div>
+
+ <div>
+ <p className="text-base font-semibold text-gray-800 mb-2">
+ {t("settings.sso.form.domain")}
+ </p>
+ <Input
+ value={localIdp.domain}
+ disabled={!allowEdit}
+ onChange={(e) =>
+ setLocalIdp({ ...localIdp, domain: e.target.value })
+ }
+ placeholder={t("settings.sso.form.domain-description")}
+ />
+ <p className="text-sm text-gray-600 mt-1">
+ {t("settings.sso.form.domain-optional-hint")}
+ </p>
+ </div>
+ </div>
+ </div>
+
+ {/* Configuration Section */}
+ <div className="py-6 lg:flex">
+ <div className="text-left lg:w-1/4">
+ <h1 className="text-3xl font-bold text-gray-900">
+ {t("settings.sso.form.configuration")}
+ </h1>
+ <p className="text-base text-gray-600 mt-3">
+ {t("settings.sso.form.configuration-description")}
+ </p>
+ </div>
+ <div className="flex-1 mt-4 lg:px-4 lg:mt-0 flex flex-col gap-y-6">
+ <ProviderConfigForm
+ providerType={localIdp.type}
+ configForOAuth2={configForOAuth2}
+ configForOIDC={configForOIDC}
+ configForLDAP={configForLDAP}
+ scopesString={scopesString}
+ isEditMode={true}
+ onUpdateOAuth2={handleOAuth2Update}
+ onUpdateOIDC={handleOIDCUpdate}
+ onUpdateLDAP={handleLDAPUpdate}
+ onUpdateScopes={setScopesString}
+ />
+ </div>
+ </div>
+
+ {/* User Information Mapping Section */}
+ <div className="py-6 lg:flex">
+ <div className="text-left lg:w-1/4">
+ <h1 className="text-3xl font-bold text-gray-900">
+ {t("settings.sso.form.user-information-mapping")}
+ </h1>
+ <p className="text-base text-gray-600 mt-3">
+ {t("settings.sso.form.user-information-mapping-description")}
+ </p>
+ </div>
+ <div className="flex-1 mt-4 lg:px-4 lg:mt-0 flex flex-col gap-y-6">
+ <FieldMappingForm
+ providerType={localIdp.type}
+ fieldMapping={fieldMapping}
+ onChange={setFieldMapping}
+ />
+ <div>
+ {builtIdp && (
+ <TestConnectionButton idp={builtIdp} disabled={!isFormValid} />
+ )}
+ </div>
+ </div>
+ </div>
+
+ {/* Actions Section */}
+ <div className="py-6">
+ <div className="flex flex-row justify-between items-center">
+ <Button
+ variant="destructive"
+ onClick={() => setShowDeleteConfirm(true)}
+ disabled={
+ !hasWorkspacePermissionV2("bb.identityProviders.delete")
+ }
+ >
+ {t("settings.sso.delete")}
+ </Button>
+ <div className="gap-x-2 flex flex-row justify-end items-center">
+ {hasChanges && (
+ <Button variant="outline" onClick={handleDiscard}>
+ {t("common.discard-changes")}
+ </Button>
+ )}
+ <Button
+ disabled={!canUpdate || isUpdating}
+ onClick={handleUpdate}
+ >
+ {t("common.update")}
+ </Button>
+ </div>
+ </div>
+ </div>
+ </div>
+
+ {showDeleteConfirm && (
+ <DeleteConfirmDialog
+ onConfirm={handleDelete}
+ onCancel={() => setShowDeleteConfirm(false)}
+ />
+ )}
+ </div>
+ );
+}
diff --git a/frontend/src/react/pages/settings/IDPsPage.tsx b/frontend/src/react/pages/settings/IDPsPage.tsx
new file mode 100644
index 0000000000..326b63705f
--- /dev/null
+++ b/frontend/src/react/pages/settings/IDPsPage.tsx
@@ -0,0 +1,2107 @@
+import { create } from "@bufbuild/protobuf";
+import { Code, ConnectError } from "@connectrpc/connect";
+import {
+ ArrowRight,
+ Building,
+ Database,
+ GitBranch,
+ GitFork,
+ Globe,
+ Info,
+ Key,
+ Plus,
+ ShieldCheck,
+ X,
+} from "lucide-react";
+import { useCallback, useEffect, useMemo, useRef, useState } from "react";
+import { useTranslation } from "react-i18next";
+import { identityProviderServiceClientConnect } from "@/connect";
+import { FeatureAttention } from "@/react/components/FeatureAttention";
+import {
+ ResourceIdField,
+ type ResourceIdFieldRef,
+} from "@/react/components/ResourceIdField";
+import { Button } from "@/react/components/ui/button";
+import { Input } from "@/react/components/ui/input";
+import { useVueState } from "@/react/hooks/useVueState";
+import { router } from "@/router";
+import { WORKSPACE_ROUTE_IDENTITY_PROVIDER_DETAIL } from "@/router/dashboard/workspaceRoutes";
+import {
+ pushNotification,
+ useActuatorV1Store,
+ useSubscriptionV1Store,
+} from "@/store";
+import { useIdentityProviderStore } from "@/store/modules/idp";
+import {
+ getIdentityProviderResourceId,
+ idpNamePrefix,
+} from "@/store/modules/v1/common";
+import type { OAuthWindowEventPayload } from "@/types";
+import type {
+ IdentityProvider,
+ LDAPIdentityProviderConfig,
+ OAuth2IdentityProviderConfig,
+ OIDCIdentityProviderConfig,
+ TestIdentityProviderResponse,
+} from "@/types/proto-es/v1/idp_service_pb";
+import {
+ CreateIdentityProviderRequestSchema,
+ FieldMappingSchema,
+ IdentityProviderConfigSchema,
+ IdentityProviderSchema,
+ IdentityProviderType,
+ LDAPIdentityProviderConfig_SecurityProtocol,
+ LDAPIdentityProviderConfigSchema,
+ OAuth2AuthStyle,
+ OAuth2IdentityProviderConfigSchema,
+ OIDCIdentityProviderConfigSchema,
+ TestIdentityProviderRequestSchema,
+} from "@/types/proto-es/v1/idp_service_pb";
+import { PlanFeature } from "@/types/proto-es/v1/subscription_service_pb";
+import {
+ hasWorkspacePermissionV2,
+ identityProviderTypeToString,
+ openWindowForSSO,
+} from "@/utils";
+
+// ============================================================
+// Escape key stack
+// ============================================================
+
+const escapeStack: (() => void)[] = [];
+
+function useEscapeKey(onEscape: () => void) {
+ useEffect(() => {
+ escapeStack.push(onEscape);
+ const handler = (e: KeyboardEvent) => {
+ if (
+ e.key === "Escape" &&
+ escapeStack[escapeStack.length - 1] === onEscape
+ ) {
+ onEscape();
+ }
+ };
+ document.addEventListener("keydown", handler);
+ return () => {
+ document.removeEventListener("keydown", handler);
+ const idx = escapeStack.lastIndexOf(onEscape);
+ if (idx >= 0) escapeStack.splice(idx, 1);
+ };
+ }, [onEscape]);
+}
+
+// ============================================================
+// Types
+// ============================================================
+
+interface OAuth2Template {
+ title: string;
+ domain: string;
+ domainDisabled?: boolean;
+ feature: PlanFeature;
+ config: OAuth2IdentityProviderConfig;
+}
+
+interface FieldMappingState {
+ identifier: string;
+ displayName: string;
+ phone: string;
+ groups: string;
+}
+
+// ============================================================
+// ExternalURLInfo
+// ============================================================
+
+function ExternalURLInfo({ type }: { type: IdentityProviderType }) {
+ const { t } = useTranslation();
+ const actuatorStore = useActuatorV1Store();
+ const externalUrl = useVueState(
+ () => actuatorStore.serverInfo?.externalUrl ?? ""
+ );
+
+ const redirectUrl = useMemo(() => {
+ const url = externalUrl || window.origin;
+ if (type === IdentityProviderType.OAUTH2) {
+ return `${url}/oauth/callback`;
+ }
+ if (type === IdentityProviderType.OIDC) {
+ return `${url}/oidc/callback`;
+ }
+ return "";
+ }, [externalUrl, type]);
+
+ if (!redirectUrl) return null;
+
+ const handleCopy = () => {
+ navigator.clipboard.writeText(redirectUrl);
+ pushNotification({
+ module: "bytebase",
+ style: "SUCCESS",
+ title: t("common.copied"),
+ });
+ };
+
+ return (
+ <div className="p-4 rounded-lg border border-gray-200 bg-gray-50">
+ <div className="flex items-start gap-x-3">
+ <Info className="w-5 h-5 text-blue-500 mt-0.5 shrink-0" />
+ <div className="flex-1 min-w-0">
+ <p className="text-sm font-medium text-gray-900 mb-2">
+ {t("settings.sso.form.identity-provider-needed-information")}
+ </p>
+ <p className="text-sm text-gray-600 mb-3">
+ {t("settings.sso.form.redirect-url-description")}
+ </p>
+ <div>
+ <label className="block text-sm font-medium text-gray-700 mb-1">
+ {t("settings.sso.form.redirect-url")}
+ </label>
+ <div className="flex items-center gap-x-2">
+ <input
+ value={redirectUrl}
+ readOnly
+ className="flex-1 px-3 py-2 border border-gray-300 rounded-md bg-white text-sm font-mono text-gray-700"
+ />
+ <Button variant="outline" size="sm" onClick={handleCopy}>
+ {t("common.copy")}
+ </Button>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+ );
+}
+
+// ============================================================
+// TestConnectionResultDialog
+// ============================================================
+
+function TestConnectionResultDialog({
+ response,
+ onClose,
+}: {
+ response: TestIdentityProviderResponse;
+ onClose: () => void;
+}) {
+ const { t } = useTranslation();
+ useEscapeKey(onClose);
+
+ return (
+ <div
+ className="fixed inset-0 z-[60] flex items-center justify-center bg-black/50"
+ onClick={(e) => {
+ if (e.target === e.currentTarget) onClose();
+ }}
+ >
+ <div className="bg-white rounded-lg shadow-lg w-[32rem] max-h-[80vh] overflow-auto p-6">
+ <div className="flex items-center justify-between mb-4">
+ <div className="flex items-center gap-x-2">
+ <div className="w-6 h-6 text-green-500">&#10003;</div>
+ <h3 className="text-lg font-medium">
+ {t("identity-provider.test-connection-success")}
+ </h3>
+ </div>
+ <Button variant="ghost" size="icon" onClick={onClose}>
+ <X className="h-4 w-4" />
+ </Button>
+ </div>
+
+ <div className="flex flex-col gap-y-4">
+ <p className="text-sm text-control-light">
+ {t("identity-provider.userinfo-description")}
+ </p>
+ <div className="bg-gray-50 rounded-lg p-4">
+ <div className="flex flex-col gap-y-1">
+ {Object.entries(response.userInfo).map(([key, value]) => (
+ <div
+ key={key}
+ className="grid grid-cols-3 gap-2 py-1 border-b border-gray-200 last:border-b-0"
+ >
+ <div
+ className="text-sm font-medium text-control truncate"
+ title={key}
+ >
+ {key}
+ </div>
+ <div
+ className="col-span-2 text-sm text-main break-all"
+ title={value}
+ >
+ {value}
+ </div>
+ </div>
+ ))}
+ </div>
+ </div>
+
+ <p className="text-sm text-control-light">
+ {t("identity-provider.claims-description")}
+ </p>
+ <div className="bg-gray-50 rounded-lg p-4">
+ {Object.keys(response.claims).length === 0 ? (
+ <div className="text-sm text-control-light italic">
+ {t("identity-provider.no-claims")}
+ </div>
+ ) : (
+ <div className="flex flex-col gap-y-1">
+ {Object.entries(response.claims).map(([key, value]) => (
+ <div
+ key={key}
+ className="grid grid-cols-3 gap-2 py-1 border-b border-gray-200 last:border-b-0"
+ >
+ <div
+ className="text-sm font-medium text-control truncate"
+ title={key}
+ >
+ {key}
+ </div>
+ <div
+ className="col-span-2 text-sm text-main break-all"
+ title={value}
+ >
+ {value}
+ </div>
+ </div>
+ ))}
+ </div>
+ )}
+ </div>
+ </div>
+
+ <div className="flex justify-end mt-4">
+ <Button onClick={onClose}>{t("common.close")}</Button>
+ </div>
+ </div>
+ </div>
+ );
+}
+
+// ============================================================
+// TestConnectionButton
+// ============================================================
+
+function TestConnectionButton({
+ idp,
+ disabled,
+ isCreating,
+}: {
+ idp: IdentityProvider;
+ disabled: boolean;
+ isCreating?: boolean;
+}) {
+ const { t } = useTranslation();
+ const [testing, setTesting] = useState(false);
+ const [testResult, setTestResult] =
+ useState<TestIdentityProviderResponse | null>(null);
+ const currentEventNameRef = useRef("");
+ const idpRef = useRef(idp);
+ idpRef.current = idp;
+ const testingRef = useRef(false);
+
+ // Stable event handler that reads latest state via refs
+ const handleOAuthEventRef = useRef(async (event: Event) => {
+ if (testingRef.current) return;
+ const payload = (event as CustomEvent).detail as OAuthWindowEventPayload;
+ if (payload.error) {
+ pushNotification({
+ module: "bytebase",
+ style: "CRITICAL",
+ title: "Request error occurred",
+ description: payload.error,
+ });
+ return;
+ }
+
+ try {
+ testingRef.current = true;
+ setTesting(true);
+ const currentIdp = idpRef.current;
+ const isOidc = currentIdp.type === IdentityProviderType.OIDC;
+ const request = create(TestIdentityProviderRequestSchema, {
+ identityProvider: currentIdp,
+ context: isOidc
+ ? { case: "oidcContext", value: { code: payload.code } }
+ : { case: "oauth2Context", value: { code: payload.code } },
+ });
+ const response =
+ await identityProviderServiceClientConnect.testIdentityProvider(
+ request
+ );
+ setTestResult(response);
+ } catch (error) {
+ pushNotification({
+ module: "bytebase",
+ style: "CRITICAL",
+ title: "Request error occurred",
+ description: (error as ConnectError).message,
+ });
+ } finally {
+ testingRef.current = false;
+ setTesting(false);
+ }
+ });
+
+ useEffect(() => {
+ return () => {
+ if (currentEventNameRef.current) {
+ window.removeEventListener(
+ currentEventNameRef.current,
+ handleOAuthEventRef.current as EventListener,
+ false
+ );
+ }
+ };
+ }, []);
+
+ const testConnection = async () => {
+ if (testingRef.current) return;
+
+ if (
+ idp.type === IdentityProviderType.OAUTH2 ||
+ idp.type === IdentityProviderType.OIDC
+ ) {
+ let idpForTesting: IdentityProvider = idp;
+ if (isCreating && idp.type === IdentityProviderType.OIDC) {
+ const request = create(CreateIdentityProviderRequestSchema, {
+ identityProviderId: idp.name,
+ identityProvider: idp,
+ validateOnly: true,
+ });
+ const response =
+ await identityProviderServiceClientConnect.createIdentityProvider(
+ request
+ );
+ idpForTesting = response;
+ }
+
+ const eventName = `bb.oauth.signin.${idpForTesting.name}`;
+ if (currentEventNameRef.current) {
+ window.removeEventListener(
+ currentEventNameRef.current,
+ handleOAuthEventRef.current as EventListener,
+ false
+ );
+ }
+ window.addEventListener(
+ eventName,
+ handleOAuthEventRef.current as EventListener,
+ false
+ );
+ currentEventNameRef.current = eventName;
+
+ try {
+ await openWindowForSSO(idpForTesting);
+ } catch (error) {
+ pushNotification({
+ module: "bytebase",
+ style: "CRITICAL",
+ title: "Request error occurred",
+ description: (error as ConnectError).message,
+ });
+ }
+ } else if (idp.type === IdentityProviderType.LDAP) {
+ try {
+ testingRef.current = true;
+ setTesting(true);
+ const request = create(TestIdentityProviderRequestSchema, {
+ identityProvider: idp,
+ });
+ const response =
+ await identityProviderServiceClientConnect.testIdentityProvider(
+ request
+ );
+ setTestResult(response);
+ } catch (error) {
+ pushNotification({
+ module: "bytebase",
+ style: "CRITICAL",
+ title: "Request error occurred",
+ description: (error as ConnectError).message,
+ });
+ } finally {
+ testingRef.current = false;
+ setTesting(false);
+ }
+ }
+ };
+
+ return (
+ <>
+ <Button
+ variant="outline"
+ disabled={disabled || testing}
+ onClick={testConnection}
+ >
+ {t("identity-provider.test-connection")}
+ </Button>
+ {testResult && (
+ <TestConnectionResultDialog
+ response={testResult}
+ onClose={() => setTestResult(null)}
+ />
+ )}
+ </>
+ );
+}
+
+// ============================================================
+// ProviderConfigForm
+// ============================================================
+
+function ProviderConfigForm({
+ providerType,
+ configForOAuth2,
+ configForOIDC,
+ configForLDAP,
+ scopesString,
+ onUpdateOAuth2,
+ onUpdateOIDC,
+ onUpdateLDAP,
+ onUpdateScopes,
+}: {
+ providerType: IdentityProviderType;
+ configForOAuth2: OAuth2IdentityProviderConfig;
+ configForOIDC: OIDCIdentityProviderConfig;
+ configForLDAP: LDAPIdentityProviderConfig;
+ scopesString: string;
+ onUpdateOAuth2: (config: OAuth2IdentityProviderConfig) => void;
+ onUpdateOIDC: (config: OIDCIdentityProviderConfig) => void;
+ onUpdateLDAP: (config: LDAPIdentityProviderConfig) => void;
+ onUpdateScopes: (scopes: string) => void;
+}) {
+ const { t } = useTranslation();
+
+ if (providerType === IdentityProviderType.OAUTH2) {
+ return (
+ <div className="flex flex-col gap-y-6">
+ <div className="grid grid-cols-1 md:grid-cols-2 gap-6">
+ <div>
+ <label className="block text-base font-semibold text-gray-800 mb-2">
+ Client ID <span className="text-error">*</span>
+ </label>
+ <Input
+ value={configForOAuth2.clientId}
+ onChange={(e) =>
+ onUpdateOAuth2({
+ ...configForOAuth2,
+ clientId: e.target.value,
+ })
+ }
+ placeholder="e.g. 6655asd77895265aa110ac0d3"
+ />
+ </div>
+ <div>
+ <label className="block text-base font-semibold text-gray-800 mb-2">
+ Client Secret <span className="text-error">*</span>
+ </label>
+ <Input
+ type="password"
+ value={configForOAuth2.clientSecret}
+ onChange={(e) =>
+ onUpdateOAuth2({
+ ...configForOAuth2,
+ clientSecret: e.target.value,
+ })
+ }
+ placeholder="e.g. 5bbezxc3972ca304de70c5d70a6aa932asd8"
+ />
+ </div>
+ </div>
+
+ <div>
+ <label className="block text-base font-semibold text-gray-800 mb-2">
+ {t("settings.sso.form.auth-url")}{" "}
+ <span className="text-error">*</span>
+ </label>
+ <Input
+ value={configForOAuth2.authUrl}
+ onChange={(e) =>
+ onUpdateOAuth2({ ...configForOAuth2, authUrl: e.target.value })
+ }
+ placeholder={t("settings.sso.form.auth-url-placeholder")}
+ />
+ <p className="text-sm text-gray-600 mt-1">
+ {t("settings.sso.form.auth-url-description")}
+ </p>
+ </div>
+
+ <div>
+ <label className="block text-base font-semibold text-gray-800 mb-2">
+ {t("settings.sso.form.token-url")}{" "}
+ <span className="text-error">*</span>
+ </label>
+ <Input
+ value={configForOAuth2.tokenUrl}
+ onChange={(e) =>
+ onUpdateOAuth2({ ...configForOAuth2, tokenUrl: e.target.value })
+ }
+ placeholder={t("settings.sso.form.token-url-placeholder")}
+ />
+ <p className="text-sm text-gray-600 mt-1">
+ {t("settings.sso.form.token-url-description")}
+ </p>
+ </div>
+
+ <div>
+ <label className="block text-base font-semibold text-gray-800 mb-2">
+ {t("settings.sso.form.user-info-url")}{" "}
+ <span className="text-error">*</span>
+ </label>
+ <Input
+ value={configForOAuth2.userInfoUrl}
+ onChange={(e) =>
+ onUpdateOAuth2({
+ ...configForOAuth2,
+ userInfoUrl: e.target.value,
+ })
+ }
+ placeholder={t("settings.sso.form.user-info-url-placeholder")}
+ />
+ <p className="text-sm text-gray-600 mt-1">
+ {t("settings.sso.form.user-info-url-description")}
+ </p>
+ </div>
+
+ <div>
+ <label className="block text-base font-semibold text-gray-800 mb-2">
+ {t("settings.sso.form.scopes")}{" "}
+ <span className="text-error">*</span>
+ </label>
+ <Input
+ value={scopesString}
+ onChange={(e) => onUpdateScopes(e.target.value)}
+ placeholder={t("settings.sso.form.scopes-placeholder")}
+ />
+ <p className="text-sm text-gray-600 mt-1">
+ {t("settings.sso.form.scopes-description")}
+ </p>
+ </div>
+
+ <div>
+ <label className="block text-base font-semibold text-gray-800 mb-3">
+ {t("settings.sso.form.authentication-style")}{" "}
+ <span className="text-error">*</span>
+ </label>
+ <div className="flex flex-col gap-y-3">
+ <label className="flex items-start gap-x-3 cursor-pointer">
+ <input
+ type="radio"
+ name="oauth2-auth-style"
+ checked={
+ configForOAuth2.authStyle === OAuth2AuthStyle.IN_PARAMS
+ }
+ onChange={() =>
+ onUpdateOAuth2({
+ ...configForOAuth2,
+ authStyle: OAuth2AuthStyle.IN_PARAMS,
+ })
+ }
+ className="mt-1"
+ />
+ <div>
+ <div className="font-medium">
+ {t("settings.sso.form.in-parameters")}
+ </div>
+ <div className="text-sm text-gray-600">
+ {t("settings.sso.form.in-parameters-description")}
+ </div>
+ </div>
+ </label>
+ <label className="flex items-start gap-x-3 cursor-pointer">
+ <input
+ type="radio"
+ name="oauth2-auth-style"
+ checked={
+ configForOAuth2.authStyle === OAuth2AuthStyle.IN_HEADER
+ }
+ onChange={() =>
+ onUpdateOAuth2({
+ ...configForOAuth2,
+ authStyle: OAuth2AuthStyle.IN_HEADER,
+ })
+ }
+ className="mt-1"
+ />
+ <div>
+ <div className="font-medium">
+ {t("settings.sso.form.in-header")}
+ </div>
+ <div className="text-sm text-gray-600">
+ {t("settings.sso.form.in-header-description")}
+ </div>
+ </div>
+ </label>
+ </div>
+ </div>
+
+ <div>
+ <label className="block text-base font-semibold text-gray-800 mb-3">
+ {t("settings.sso.form.security-options")}
+ </label>
+ <label className="flex items-center gap-x-2 cursor-pointer">
+ <input
+ type="checkbox"
+ checked={configForOAuth2.skipTlsVerify}
+ onChange={(e) =>
+ onUpdateOAuth2({
+ ...configForOAuth2,
+ skipTlsVerify: e.target.checked,
+ })
+ }
+ />
+ <span>{t("settings.sso.form.skip-tls-verification")}</span>
+ </label>
+ <p className="text-sm text-gray-600 mt-1 ml-6">
+ {t("settings.sso.form.skip-tls-warning")}
+ </p>
+ </div>
+ </div>
+ );
+ }
+
+ if (providerType === IdentityProviderType.OIDC) {
+ return (
+ <div className="flex flex-col gap-y-6">
+ <div>
+ <label className="block text-base font-semibold text-gray-800 mb-2">
+ Issuer URL <span className="text-error">*</span>
+ </label>
+ <Input
+ value={configForOIDC.issuer}
+ onChange={(e) =>
+ onUpdateOIDC({ ...configForOIDC, issuer: e.target.value })
+ }
+ placeholder={t("settings.sso.form.issuer-url-placeholder")}
+ />
+ <p className="text-sm text-gray-600 mt-1">
+ {t("settings.sso.form.issuer-url-description")}
+ </p>
+ </div>
+
+ <div className="grid grid-cols-1 md:grid-cols-2 gap-6">
+ <div>
+ <label className="block text-base font-semibold text-gray-800 mb-2">
+ Client ID <span className="text-error">*</span>
+ </label>
+ <Input
+ value={configForOIDC.clientId}
+ onChange={(e) =>
+ onUpdateOIDC({ ...configForOIDC, clientId: e.target.value })
+ }
+ placeholder="e.g. 6655asd77895265aa110ac0d3"
+ />
+ </div>
+ <div>
+ <label className="block text-base font-semibold text-gray-800 mb-2">
+ Client Secret <span className="text-error">*</span>
+ </label>
+ <Input
+ type="password"
+ value={configForOIDC.clientSecret}
+ onChange={(e) =>
+ onUpdateOIDC({
+ ...configForOIDC,
+ clientSecret: e.target.value,
+ })
+ }
+ placeholder="e.g. 5bbezxc3972ca304de70c5d70a6aa932asd8"
+ />
+ </div>
+ </div>
+
+ <div>
+ <label className="block text-base font-semibold text-gray-800 mb-2">
+ {t("settings.sso.form.scopes")}{" "}
+ <span className="text-error">*</span>
+ </label>
+ <Input
+ value={scopesString}
+ onChange={(e) => onUpdateScopes(e.target.value)}
+ placeholder={t("settings.sso.form.scopes-placeholder-oidc")}
+ />
+ <p className="text-sm text-gray-600 mt-1">
+ {t("settings.sso.form.openid-scopes-description")}
+ </p>
+ </div>
+
+ <div>
+ <label className="block text-base font-semibold text-gray-800 mb-3">
+ {t("settings.sso.form.authentication-style")}{" "}
+ <span className="text-error">*</span>
+ </label>
+ <div className="flex flex-col gap-y-3">
+ <label className="flex items-start gap-x-3 cursor-pointer">
+ <input
+ type="radio"
+ name="oidc-auth-style"
+ checked={configForOIDC.authStyle === OAuth2AuthStyle.IN_PARAMS}
+ onChange={() =>
+ onUpdateOIDC({
+ ...configForOIDC,
+ authStyle: OAuth2AuthStyle.IN_PARAMS,
+ })
+ }
+ className="mt-1"
+ />
+ <div>
+ <div className="font-medium">
+ {t("settings.sso.form.in-parameters")}
+ </div>
+ <div className="text-sm text-gray-600">
+ {t("settings.sso.form.in-parameters-description")}
+ </div>
+ </div>
+ </label>
+ <label className="flex items-start gap-x-3 cursor-pointer">
+ <input
+ type="radio"
+ name="oidc-auth-style"
+ checked={configForOIDC.authStyle === OAuth2AuthStyle.IN_HEADER}
+ onChange={() =>
+ onUpdateOIDC({
+ ...configForOIDC,
+ authStyle: OAuth2AuthStyle.IN_HEADER,
+ })
+ }
+ className="mt-1"
+ />
+ <div>
+ <div className="font-medium">
+ {t("settings.sso.form.in-header")}
+ </div>
+ <div className="text-sm text-gray-600">
+ {t("settings.sso.form.in-header-description")}
+ </div>
+ </div>
+ </label>
+ </div>
+ </div>
+
+ <div>
+ <label className="block text-base font-semibold text-gray-800 mb-3">
+ {t("settings.sso.form.security-options")}
+ </label>
+ <label className="flex items-center gap-x-2 cursor-pointer">
+ <input
+ type="checkbox"
+ checked={configForOIDC.skipTlsVerify}
+ onChange={(e) =>
+ onUpdateOIDC({
+ ...configForOIDC,
+ skipTlsVerify: e.target.checked,
+ })
+ }
+ />
+ <span>{t("settings.sso.form.skip-tls-verification")}</span>
+ </label>
+ <p className="text-sm text-gray-600 mt-1 ml-6">
+ {t("settings.sso.form.skip-tls-warning")}
+ </p>
+ </div>
+ </div>
+ );
+ }
+
+ if (providerType === IdentityProviderType.LDAP) {
+ return (
+ <div className="flex flex-col gap-y-6">
+ <div className="grid grid-cols-1 md:grid-cols-3 gap-6">
+ <div className="md:col-span-2">
+ <label className="block text-base font-semibold text-gray-800 mb-2">
+ Host <span className="text-error">*</span>
+ </label>
+ <Input
+ value={configForLDAP.host}
+ onChange={(e) =>
+ onUpdateLDAP({ ...configForLDAP, host: e.target.value })
+ }
+ placeholder={t("settings.sso.form.host-placeholder")}
+ />
+ </div>
+ <div>
+ <label className="block text-base font-semibold text-gray-800 mb-2">
+ Port <span className="text-error">*</span>
+ </label>
+ <input
+ type="number"
+ value={configForLDAP.port}
+ onChange={(e) =>
+ onUpdateLDAP({
+ ...configForLDAP,
+ port: parseInt(e.target.value, 10) || 0,
+ })
+ }
+ min={1}
+ max={65535}
+ placeholder="389"
+ className="flex h-9 w-full rounded-md border border-control-border bg-transparent px-3 py-1 text-sm"
+ />
+ </div>
+ </div>
+
+ <div>
+ <label className="block text-base font-semibold text-gray-800 mb-2">
+ {t("settings.sso.form.bind-dn")}{" "}
+ <span className="text-error">*</span>
+ </label>
+ <Input
+ value={configForLDAP.bindDn}
+ onChange={(e) =>
+ onUpdateLDAP({ ...configForLDAP, bindDn: e.target.value })
+ }
+ placeholder={t("settings.sso.form.bind-dn-placeholder")}
+ />
+ <p className="text-sm text-gray-600 mt-1">
+ {t("settings.sso.form.bind-dn-description")}
+ </p>
+ </div>
+
+ <div>
+ <label className="block text-base font-semibold text-gray-800 mb-2">
+ {t("settings.sso.form.bind-password")}{" "}
+ <span className="text-error">*</span>
+ </label>
+ <Input
+ type="password"
+ value={configForLDAP.bindPassword}
+ onChange={(e) =>
+ onUpdateLDAP({
+ ...configForLDAP,
+ bindPassword: e.target.value,
+ })
+ }
+ placeholder="••••••••"
+ />
+ </div>
+
+ <div>
+ <label className="block text-base font-semibold text-gray-800 mb-2">
+ {t("settings.sso.form.base-dn")}{" "}
+ <span className="text-error">*</span>
+ </label>
+ <Input
+ value={configForLDAP.baseDn}
+ onChange={(e) =>
+ onUpdateLDAP({ ...configForLDAP, baseDn: e.target.value })
+ }
+ placeholder={t("settings.sso.form.base-dn-placeholder")}
+ />
+ <p className="text-sm text-gray-600 mt-1">
+ {t("settings.sso.form.base-dn-description")}
+ </p>
+ </div>
+
+ <div>
+ <label className="block text-base font-semibold text-gray-800 mb-2">
+ {t("settings.sso.form.user-filter")}{" "}
+ <span className="text-error">*</span>
+ </label>
+ <Input
+ value={configForLDAP.userFilter}
+ onChange={(e) =>
+ onUpdateLDAP({ ...configForLDAP, userFilter: e.target.value })
+ }
+ placeholder={t("settings.sso.form.user-filter-placeholder")}
+ />
+ <p className="text-sm text-gray-600 mt-1">
+ {t("settings.sso.form.user-filter-description")}
+ </p>
+ </div>
+
+ <div>
+ <label className="block text-base font-semibold text-gray-800 mb-3">
+ {t("settings.sso.form.security-protocol")}{" "}
+ <span className="text-error">*</span>
+ </label>
+ <div className="flex flex-col gap-y-3">
+ <label className="flex items-start gap-x-3 cursor-pointer">
+ <input
+ type="radio"
+ name="ldap-security"
+ checked={
+ configForLDAP.securityProtocol ===
+ LDAPIdentityProviderConfig_SecurityProtocol.START_TLS
+ }
+ onChange={() =>
+ onUpdateLDAP({
+ ...configForLDAP,
+ securityProtocol:
+ LDAPIdentityProviderConfig_SecurityProtocol.START_TLS,
+ })
+ }
+ className="mt-1"
+ />
+ <div>
+ <div className="font-medium">
+ {t("settings.sso.form.starttls")}
+ </div>
+ <div className="text-sm text-gray-600">
+ {t("settings.sso.form.starttls-description")}
+ </div>
+ </div>
+ </label>
+ <label className="flex items-start gap-x-3 cursor-pointer">
+ <input
+ type="radio"
+ name="ldap-security"
+ checked={
+ configForLDAP.securityProtocol ===
+ LDAPIdentityProviderConfig_SecurityProtocol.LDAPS
+ }
+ onChange={() =>
+ onUpdateLDAP({
+ ...configForLDAP,
+ securityProtocol:
+ LDAPIdentityProviderConfig_SecurityProtocol.LDAPS,
+ })
+ }
+ className="mt-1"
+ />
+ <div>
+ <div className="font-medium">
+ {t("settings.sso.form.ldaps")}
+ </div>
+ <div className="text-sm text-gray-600">
+ {t("settings.sso.form.ldaps-description")}
+ </div>
+ </div>
+ </label>
+ <label className="flex items-start gap-x-3 cursor-pointer">
+ <input
+ type="radio"
+ name="ldap-security"
+ checked={
+ configForLDAP.securityProtocol ===
+ LDAPIdentityProviderConfig_SecurityProtocol.SECURITY_PROTOCOL_UNSPECIFIED
+ }
+ onChange={() =>
+ onUpdateLDAP({
+ ...configForLDAP,
+ securityProtocol:
+ LDAPIdentityProviderConfig_SecurityProtocol.SECURITY_PROTOCOL_UNSPECIFIED,
+ })
+ }
+ className="mt-1"
+ />
+ <div>
+ <div className="font-medium">{t("settings.sso.form.none")}</div>
+ <div className="text-sm text-gray-600">
+ {t("settings.sso.form.none-description")}
+ </div>
+ </div>
+ </label>
+ </div>
+ </div>
+
+ <div>
+ <label className="block text-base font-semibold text-gray-800 mb-3">
+ {t("settings.sso.form.security-options")}
+ </label>
+ <label className="flex items-center gap-x-2 cursor-pointer">
+ <input
+ type="checkbox"
+ checked={configForLDAP.skipTlsVerify}
+ onChange={(e) =>
+ onUpdateLDAP({
+ ...configForLDAP,
+ skipTlsVerify: e.target.checked,
+ })
+ }
+ />
+ <span>{t("settings.sso.form.skip-tls-verification")}</span>
+ </label>
+ <p className="text-sm text-gray-600 mt-1 ml-6">
+ {t("settings.sso.form.skip-tls-warning")}
+ </p>
+ </div>
+ </div>
+ );
+ }
+
+ return null;
+}
+
+// ============================================================
+// FieldMappingForm
+// ============================================================
+
+function FieldMappingForm({
+ providerType,
+ fieldMapping,
+ onChange,
+}: {
+ providerType: IdentityProviderType;
+ fieldMapping: FieldMappingState;
+ onChange: (mapping: FieldMappingState) => void;
+}) {
+ const { t } = useTranslation();
+
+ return (
+ <div className="flex flex-col gap-y-6">
+ <div className="grid grid-cols-[256px_1fr] gap-4 items-center">
+ <Input
+ value={fieldMapping.identifier}
+ onChange={(e) =>
+ onChange({ ...fieldMapping, identifier: e.target.value })
+ }
+ placeholder={t("settings.sso.form.identifier-placeholder")}
+ />
+ <div className="flex items-center text-base">
+ <ArrowRight className="mx-2 h-5 w-5 text-gray-400" />
+ <p className="flex items-center font-semibold text-gray-800">
+ {t("settings.sso.form.identifier")}
+ <span className="ml-0.5 text-error">*</span>
+ <span
+ className="ml-1"
+ title={t("settings.sso.form.identifier-tips")}
+ >
+ <Info className="w-4 h-4 text-blue-500" />
+ </span>
+ </p>
+ </div>
+ </div>
+
+ <div className="grid grid-cols-[256px_1fr] gap-4 items-center">
+ <Input
+ value={fieldMapping.displayName}
+ onChange={(e) =>
+ onChange({ ...fieldMapping, displayName: e.target.value })
+ }
+ placeholder={t("settings.sso.form.display-name-placeholder")}
+ />
+ <div className="flex items-center text-base">
+ <ArrowRight className="mx-2 h-5 w-5 text-gray-400" />
+ <p className="font-semibold text-gray-800">
+ {t("settings.sso.form.display-name")}
+ </p>
+ </div>
+ </div>
+
+ <div className="grid grid-cols-[256px_1fr] gap-4 items-center">
+ <Input
+ value={fieldMapping.phone}
+ onChange={(e) => onChange({ ...fieldMapping, phone: e.target.value })}
+ placeholder={t("settings.sso.form.phone-placeholder")}
+ />
+ <div className="flex items-center text-base">
+ <ArrowRight className="mx-2 h-5 w-5 text-gray-400" />
+ <p className="font-semibold text-gray-800">
+ {t("settings.sso.form.phone")}
+ </p>
+ </div>
+ </div>
+
+ {providerType === IdentityProviderType.OIDC && (
+ <>
+ <div className="grid grid-cols-[256px_1fr] gap-4 items-center">
+ <Input
+ value={fieldMapping.groups}
+ onChange={(e) =>
+ onChange({ ...fieldMapping, groups: e.target.value })
+ }
+ placeholder={t("settings.sso.form.groups-placeholder")}
+ />
+ <div className="flex items-center text-base">
+ <ArrowRight className="mx-2 h-5 w-5 text-gray-400" />
+ <p className="font-semibold text-gray-800">
+ {t("settings.sso.form.groups")}
+ </p>
+ </div>
+ </div>
+ <p className="text-sm text-gray-600">
+ {t("settings.sso.form.groups-description")}
+ </p>
+ </>
+ )}
+ </div>
+ );
+}
+
+// ============================================================
+// CreateWizardDrawer
+// ============================================================
+
+function getTemplateList(hasEnterpriseSSOFeature: boolean): OAuth2Template[] {
+ return [
+ {
+ title: "Google",
+ domain: "google.com",
+ domainDisabled: !hasEnterpriseSSOFeature,
+ feature: PlanFeature.FEATURE_GOOGLE_AND_GITHUB_SSO,
+ config: create(OAuth2IdentityProviderConfigSchema, {
+ clientId: "",
+ clientSecret: "",
+ authUrl: "https://accounts.google.com/o/oauth2/v2/auth",
+ tokenUrl: "https://oauth2.googleapis.com/token",
+ userInfoUrl: "https://www.googleapis.com/oauth2/v2/userinfo",
+ scopes: [
+ "https://www.googleapis.com/auth/userinfo.email",
+ "https://www.googleapis.com/auth/userinfo.profile",
+ ],
+ skipTlsVerify: false,
+ authStyle: OAuth2AuthStyle.IN_PARAMS,
+ fieldMapping: create(FieldMappingSchema, {
+ identifier: "email",
+ displayName: "name",
+ phone: "",
+ groups: "",
+ }),
+ }),
+ },
+ {
+ title: "GitHub",
+ domain: "github.com",
+ domainDisabled: !hasEnterpriseSSOFeature,
+ feature: PlanFeature.FEATURE_GOOGLE_AND_GITHUB_SSO,
+ config: create(OAuth2IdentityProviderConfigSchema, {
+ clientId: "",
+ clientSecret: "",
+ authUrl: "https://github.com/login/oauth/authorize",
+ tokenUrl: "https://github.com/login/oauth/access_token",
+ userInfoUrl: "https://api.github.com/user",
+ scopes: ["user"],
+ skipTlsVerify: false,
+ authStyle: OAuth2AuthStyle.IN_PARAMS,
+ fieldMapping: create(FieldMappingSchema, {
+ identifier: "email",
+ displayName: "name",
+ phone: "",
+ groups: "",
+ }),
+ }),
+ },
+ {
+ title: "GitLab",
+ domain: "gitlab.com",
+ feature: PlanFeature.FEATURE_ENTERPRISE_SSO,
+ config: create(OAuth2IdentityProviderConfigSchema, {
+ clientId: "",
+ clientSecret: "",
+ authUrl: "https://gitlab.com/oauth/authorize",
+ tokenUrl: "https://gitlab.com/oauth/token",
+ userInfoUrl: "https://gitlab.com/api/v4/user",
+ scopes: ["read_user"],
+ skipTlsVerify: false,
+ authStyle: OAuth2AuthStyle.IN_PARAMS,
+ fieldMapping: create(FieldMappingSchema, {
+ identifier: "email",
+ displayName: "name",
+ phone: "",
+ groups: "",
+ }),
+ }),
+ },
+ {
+ title: "Microsoft Entra",
+ domain: "",
+ feature: PlanFeature.FEATURE_ENTERPRISE_SSO,
+ config: create(OAuth2IdentityProviderConfigSchema, {
+ clientId: "",
+ clientSecret: "",
+ authUrl:
+ "https://login.microsoftonline.com/{uuid}/oauth2/v2.0/authorize",
+ tokenUrl: "https://login.microsoftonline.com/{uuid}/oauth2/v2.0/token",
+ userInfoUrl: "https://graph.microsoft.com/v1.0/me",
+ scopes: ["user.read"],
+ skipTlsVerify: false,
+ authStyle: OAuth2AuthStyle.IN_PARAMS,
+ fieldMapping: create(FieldMappingSchema, {
+ identifier: "userPrincipalName",
+ displayName: "displayName",
+ phone: "",
+ groups: "",
+ }),
+ }),
+ },
+ {
+ title: "Custom",
+ domain: "",
+ feature: PlanFeature.FEATURE_ENTERPRISE_SSO,
+ config: create(OAuth2IdentityProviderConfigSchema, {
+ clientId: "",
+ clientSecret: "",
+ authUrl: "",
+ tokenUrl: "",
+ userInfoUrl: "",
+ scopes: [],
+ skipTlsVerify: false,
+ authStyle: OAuth2AuthStyle.IN_PARAMS,
+ fieldMapping: create(FieldMappingSchema, {
+ identifier: "",
+ displayName: "",
+ phone: "",
+ groups: "",
+ }),
+ }),
+ },
+ ];
+}
+
+const PROVIDER_TYPE_LIST = [
+ {
+ type: IdentityProviderType.OAUTH2,
+ feature: PlanFeature.FEATURE_GOOGLE_AND_GITHUB_SSO,
+ },
+ {
+ type: IdentityProviderType.OIDC,
+ feature: PlanFeature.FEATURE_ENTERPRISE_SSO,
+ },
+ {
+ type: IdentityProviderType.LDAP,
+ feature: PlanFeature.FEATURE_ENTERPRISE_SSO,
+ },
+];
+
+function getProviderIcon(type: IdentityProviderType) {
+ switch (type) {
+ case IdentityProviderType.OAUTH2:
+ return Key;
+ case IdentityProviderType.OIDC:
+ return ShieldCheck;
+ case IdentityProviderType.LDAP:
+ return Database;
+ default:
+ return Key;
+ }
+}
+
+function getTemplateIcon(title: string) {
+ switch (title.toLowerCase()) {
+ case "google":
+ return Globe;
+ case "github":
+ return GitBranch;
+ case "gitlab":
+ return GitFork;
+ case "microsoft entra":
+ return Building;
+ default:
+ return Key;
+ }
+}
+
+function CreateWizardDrawer({
+ onClose,
+ onCreated,
+}: {
+ onClose: () => void;
+ onCreated: (provider: IdentityProvider) => void;
+}) {
+ const { t } = useTranslation();
+ const identityProviderStore = useIdentityProviderStore();
+ const subscriptionStore = useSubscriptionV1Store();
+ useEscapeKey(onClose);
+
+ const hasEnterpriseSSOFeature = useVueState(() =>
+ subscriptionStore.hasFeature(PlanFeature.FEATURE_ENTERPRISE_SSO)
+ );
+
+ const [currentStep, setCurrentStep] = useState(1);
+ const [selectedType, setSelectedType] = useState<IdentityProviderType>(
+ IdentityProviderType.OAUTH2
+ );
+ const [selectedTemplate, setSelectedTemplate] =
+ useState<OAuth2Template | null>(null);
+ const [isCreating, setIsCreating] = useState(false);
+
+ const [title, setTitle] = useState("");
+ const [domain, setDomain] = useState("");
+ const [resourceId, setResourceId] = useState("");
+ const [resourceIdValid, setResourceIdValid] = useState(true);
+ const resourceIdFieldRef = useRef<ResourceIdFieldRef>(null);
+
+ const [configForOAuth2, setConfigForOAuth2] =
+ useState<OAuth2IdentityProviderConfig>(
+ create(OAuth2IdentityProviderConfigSchema, {
+ authStyle: OAuth2AuthStyle.IN_PARAMS,
+ })
+ );
+ const [configForOIDC, setConfigForOIDC] =
+ useState<OIDCIdentityProviderConfig>(
+ create(OIDCIdentityProviderConfigSchema, {
+ authStyle: OAuth2AuthStyle.IN_PARAMS,
+ })
+ );
+ const [configForLDAP, setConfigForLDAP] =
+ useState<LDAPIdentityProviderConfig>(
+ create(LDAPIdentityProviderConfigSchema, { port: 389 })
+ );
+ const [scopesString, setScopesString] = useState("");
+ const [fieldMapping, setFieldMapping] = useState<FieldMappingState>({
+ identifier: "",
+ displayName: "",
+ phone: "",
+ groups: "",
+ });
+
+ const templateList = useMemo(
+ () => getTemplateList(hasEnterpriseSSOFeature),
+ [hasEnterpriseSSOFeature]
+ );
+
+ // Initialize with first template on mount
+ useEffect(() => {
+ const first = templateList[0];
+ if (first) {
+ applyTemplate(first);
+ }
+ }, []);
+
+ const applyTemplate = useCallback((template: OAuth2Template) => {
+ setSelectedTemplate(template);
+ setTitle(template.title);
+ setDomain(template.domain);
+ setConfigForOAuth2(
+ create(OAuth2IdentityProviderConfigSchema, {
+ clientId: template.config.clientId || "",
+ clientSecret: template.config.clientSecret || "",
+ authUrl: template.config.authUrl || "",
+ tokenUrl: template.config.tokenUrl || "",
+ userInfoUrl: template.config.userInfoUrl || "",
+ scopes: template.config.scopes || [],
+ skipTlsVerify: template.config.skipTlsVerify || false,
+ authStyle: template.config.authStyle || OAuth2AuthStyle.IN_PARAMS,
+ })
+ );
+ setScopesString((template.config.scopes || []).join(" "));
+ const fm = template.config.fieldMapping;
+ setFieldMapping({
+ identifier: fm?.identifier || "",
+ displayName: fm?.displayName || "",
+ phone: fm?.phone || "",
+ groups: fm?.groups || "",
+ });
+ }, []);
+
+ const maxSteps = selectedType === IdentityProviderType.OAUTH2 ? 5 : 4;
+ const isLastStep = currentStep === maxSteps;
+
+ const isConfigurationValid = useMemo(() => {
+ if (selectedType === IdentityProviderType.OAUTH2) {
+ return !!(
+ configForOAuth2.clientId &&
+ configForOAuth2.clientSecret &&
+ configForOAuth2.authUrl &&
+ configForOAuth2.tokenUrl &&
+ configForOAuth2.userInfoUrl &&
+ scopesString
+ );
+ }
+ if (selectedType === IdentityProviderType.OIDC) {
+ return !!(
+ configForOIDC.clientId &&
+ configForOIDC.clientSecret &&
+ configForOIDC.issuer &&
+ scopesString
+ );
+ }
+ if (selectedType === IdentityProviderType.LDAP) {
+ return !!(
+ configForLDAP.host &&
+ configForLDAP.port &&
+ configForLDAP.bindDn &&
+ configForLDAP.bindPassword &&
+ configForLDAP.baseDn &&
+ configForLDAP.userFilter
+ );
+ }
+ return false;
+ }, [
+ selectedType,
+ configForOAuth2,
+ configForOIDC,
+ configForLDAP,
+ scopesString,
+ ]);
+
+ const canProceed = useMemo(() => {
+ const isOAuth2 = selectedType === IdentityProviderType.OAUTH2;
+ switch (currentStep) {
+ case 1:
+ return !!selectedType;
+ case 2:
+ if (isOAuth2) return !!selectedTemplate;
+ return !!(title && resourceId && resourceIdValid);
+ case 3:
+ if (isOAuth2) return !!(title && resourceId && resourceIdValid);
+ return isConfigurationValid;
+ case 4:
+ if (isOAuth2) return isConfigurationValid;
+ return !!fieldMapping.identifier;
+ case 5:
+ return !!fieldMapping.identifier;
+ default:
+ return false;
+ }
+ }, [
+ currentStep,
+ selectedType,
+ selectedTemplate,
+ title,
+ resourceId,
+ resourceIdValid,
+ isConfigurationValid,
+ fieldMapping.identifier,
+ ]);
+
+ const canCreate = !!(
+ title &&
+ resourceId &&
+ isConfigurationValid &&
+ fieldMapping.identifier
+ );
+
+ const allowTestConnection = isConfigurationValid && !!fieldMapping.identifier;
+
+ const buildIdpToCreate = useCallback((): IdentityProvider => {
+ const base = create(IdentityProviderSchema, {
+ name: resourceId,
+ title,
+ domain,
+ type: selectedType,
+ });
+
+ if (selectedType === IdentityProviderType.OAUTH2) {
+ base.config = create(IdentityProviderConfigSchema, {
+ config: {
+ case: "oauth2Config",
+ value: create(OAuth2IdentityProviderConfigSchema, {
+ ...configForOAuth2,
+ scopes: scopesString.split(" ").filter(Boolean),
+ fieldMapping: create(FieldMappingSchema, fieldMapping),
+ }),
+ },
+ });
+ } else if (selectedType === IdentityProviderType.OIDC) {
+ base.config = create(IdentityProviderConfigSchema, {
+ config: {
+ case: "oidcConfig",
+ value: create(OIDCIdentityProviderConfigSchema, {
+ ...configForOIDC,
+ scopes: scopesString.split(" ").filter(Boolean),
+ fieldMapping: create(FieldMappingSchema, fieldMapping),
+ }),
+ },
+ });
+ } else if (selectedType === IdentityProviderType.LDAP) {
+ base.config = create(IdentityProviderConfigSchema, {
+ config: {
+ case: "ldapConfig",
+ value: create(LDAPIdentityProviderConfigSchema, {
+ ...configForLDAP,
+ fieldMapping: create(FieldMappingSchema, fieldMapping),
+ }),
+ },
+ });
+ }
+
+ return base;
+ }, [
+ resourceId,
+ title,
+ domain,
+ selectedType,
+ configForOAuth2,
+ configForOIDC,
+ configForLDAP,
+ scopesString,
+ fieldMapping,
+ ]);
+
+ const idpToCreate = useMemo(() => buildIdpToCreate(), [buildIdpToCreate]);
+
+ const handleTypeChange = (type: IdentityProviderType) => {
+ setSelectedType(type);
+ if (type === IdentityProviderType.OAUTH2) {
+ const first = templateList[0];
+ if (first) applyTemplate(first);
+ } else {
+ setTitle("");
+ setDomain("");
+ setScopesString("");
+ setFieldMapping({
+ identifier: "",
+ displayName: "",
+ phone: "",
+ groups: "",
+ });
+ }
+ };
+
+ const handlePrev = () => {
+ if (currentStep > 1) setCurrentStep(currentStep - 1);
+ };
+
+ const handleNext = () => {
+ if (currentStep < maxSteps && canProceed) {
+ setCurrentStep(currentStep + 1);
+ }
+ };
+
+ const handleCreate = async () => {
+ if (!canCreate) return;
+ setIsCreating(true);
+ try {
+ const createdProvider =
+ await identityProviderStore.createIdentityProvider(idpToCreate);
+ pushNotification({
+ module: "bytebase",
+ style: "SUCCESS",
+ title: t("identity-provider.identity-provider-created"),
+ });
+ onCreated(createdProvider);
+ } catch (error) {
+ if (error instanceof ConnectError && error.code === Code.AlreadyExists) {
+ resourceIdFieldRef.current?.addValidationError(
+ (error as ConnectError).message
+ );
+ } else {
+ pushNotification({
+ module: "bytebase",
+ style: "CRITICAL",
+ title: t("identity-provider.identity-provider-create-failed"),
+ });
+ }
+ } finally {
+ setIsCreating(false);
+ }
+ };
+
+ const validateResourceId = useCallback(
+ async (val: string) => {
+ try {
+ await identityProviderStore.getOrFetchIdentityProviderByName(
+ `${idpNamePrefix}${val}`,
+ true
+ );
+ return [
+ {
+ type: "error" as const,
+ message: t("resource-id.validation.duplicated", {
+ resource: "SSO",
+ }),
+ },
+ ];
+ } catch {
+ return [];
+ }
+ },
+ [identityProviderStore, t]
+ );
+
+ // Step labels
+ const stepLabels = useMemo(() => {
+ const labels = [t("settings.sso.form.type")];
+ if (selectedType === IdentityProviderType.OAUTH2) {
+ labels.push(t("settings.sso.form.use-template"));
+ }
+ labels.push(t("common.general"));
+ labels.push(t("settings.sso.form.configuration"));
+ labels.push(t("settings.sso.form.user-information-mapping"));
+ return labels;
+ }, [selectedType, t]);
+
+ const getProviderDescription = (type: IdentityProviderType) => {
+ switch (type) {
+ case IdentityProviderType.OAUTH2:
+ return t("settings.sso.form.oauth2-description");
+ case IdentityProviderType.OIDC:
+ return t("settings.sso.form.oidc-description");
+ case IdentityProviderType.LDAP:
+ return t("settings.sso.form.ldap-description");
+ default:
+ return "";
+ }
+ };
+
+ const getTemplateDescription = (templateTitle: string) => {
+ switch (templateTitle.toLowerCase()) {
+ case "google":
+ return t("settings.sso.form.google-template-description");
+ case "github":
+ return t("settings.sso.form.github-template-description");
+ case "gitlab":
+ return t("settings.sso.form.gitlab-template-description");
+ case "microsoft entra":
+ return t("settings.sso.form.microsoft-entra-template-description");
+ case "custom":
+ return t("settings.sso.form.custom-template-description");
+ default:
+ return "";
+ }
+ };
+
+ // Determine which step content to render
+ const isOAuth2 = selectedType === IdentityProviderType.OAUTH2;
+ const basicInfoStep = isOAuth2 ? 3 : 2;
+ const configStep = isOAuth2 ? 4 : 3;
+ const mappingStep = isOAuth2 ? 5 : 4;
+
+ return (
+ <>
+ <div className="fixed inset-0 z-40 bg-black/30" onClick={onClose} />
+ <div className="fixed inset-y-0 right-0 z-50 w-[64rem] max-w-[100vw] bg-white shadow-xl flex flex-col">
+ {/* Header */}
+ <div className="flex items-center justify-between px-6 py-4 border-b">
+ <h2 className="text-lg font-medium">{t("settings.sso.create")}</h2>
+ <Button variant="ghost" size="icon" onClick={onClose}>
+ <X className="h-5 w-5" />
+ </Button>
+ </div>
+
+ {/* Content */}
+ <div className="flex-1 overflow-auto px-6 py-6">
+ <div className="flex flex-col gap-y-6">
+ {/* Step indicators */}
+ <div className="flex items-center gap-x-2">
+ {stepLabels.map((label, i) => {
+ const stepNum = i + 1;
+ const isActive = stepNum === currentStep;
+ const isComplete = stepNum < currentStep;
+ return (
+ <div key={i} className="flex items-center gap-x-2">
+ {i > 0 && (
+ <div
+ className={`w-8 h-px ${isComplete ? "bg-accent" : "bg-gray-300"}`}
+ />
+ )}
+ <div className="flex items-center gap-x-1.5">
+ <div
+ className={`w-7 h-7 rounded-full flex items-center justify-center text-xs font-medium ${
+ isActive
+ ? "bg-accent text-white"
+ : isComplete
+ ? "bg-accent/20 text-accent"
+ : "bg-gray-200 text-gray-500"
+ }`}
+ >
+ {stepNum}
+ </div>
+ <span
+ className={`text-sm ${isActive ? "font-medium text-main" : "text-gray-500"}`}
+ >
+ {label}
+ </span>
+ </div>
+ </div>
+ );
+ })}
+ </div>
+
+ {/* Step content */}
+ <div className="bg-white rounded-lg border border-gray-200 px-6 pt-6 pb-10">
+ {/* Step 1: Select provider type */}
+ {currentStep === 1 && (
+ <div className="flex flex-col gap-y-6">
+ <div className="text-center flex flex-col gap-y-2">
+ <h2 className="text-2xl font-bold text-gray-900">
+ {t("settings.sso.form.type")}
+ </h2>
+ <p className="text-gray-600">
+ {t("settings.sso.form.type-description")}
+ </p>
+ </div>
+ <div className="max-w-2xl mx-auto w-full">
+ {PROVIDER_TYPE_LIST.map((item) => {
+ const Icon = getProviderIcon(item.type);
+ const hasFeature = subscriptionStore.hasFeature(
+ item.feature
+ );
+ return (
+ <label
+ key={item.type}
+ className={`block border rounded-lg mb-4 p-4 transition-colors cursor-pointer ${
+ selectedType === item.type
+ ? "border-blue-500 bg-blue-50"
+ : "border-gray-200 hover:border-gray-300"
+ } ${!hasFeature ? "opacity-50 cursor-not-allowed" : ""}`}
+ >
+ <div className="flex items-start gap-x-3">
+ <input
+ type="radio"
+ name="provider-type"
+ checked={selectedType === item.type}
+ disabled={!hasFeature}
+ onChange={() => handleTypeChange(item.type)}
+ className="mt-1.5"
+ />
+ <Icon
+ className="w-6 h-6 mt-1 shrink-0"
+ strokeWidth={1.5}
+ />
+ <div className="flex-1">
+ <div className="flex items-center gap-x-2">
+ <span className="text-lg font-medium text-gray-900">
+ {identityProviderTypeToString(item.type)}
+ </span>
+ </div>
+ <p className="text-sm text-gray-600 mt-1">
+ {getProviderDescription(item.type)}
+ </p>
+ </div>
+ </div>
+ </label>
+ );
+ })}
+ </div>
+ </div>
+ )}
+
+ {/* Step 2 for OAuth2: Select template */}
+ {currentStep === 2 && isOAuth2 && (
+ <div className="flex flex-col gap-y-6">
+ <div className="text-center flex flex-col gap-y-2">
+ <h2 className="text-2xl font-bold text-gray-900">
+ {t("settings.sso.form.use-template")}
+ </h2>
+ <p className="text-gray-600">
+ {t("settings.sso.form.template-description")}
+ </p>
+ </div>
+ <div className="max-w-3xl mx-auto grid grid-cols-1 sm:grid-cols-2 gap-4">
+ {templateList.map((tmpl) => {
+ const Icon = getTemplateIcon(tmpl.title);
+ const hasFeature = subscriptionStore.hasFeature(
+ tmpl.feature
+ );
+ return (
+ <label
+ key={tmpl.title}
+ className={`block border rounded-lg p-4 transition-colors cursor-pointer ${
+ selectedTemplate?.title === tmpl.title
+ ? "border-blue-500 bg-blue-50"
+ : "border-gray-200 hover:border-gray-300"
+ } ${!hasFeature ? "opacity-50 cursor-not-allowed" : ""}`}
+ >
+ <div className="flex items-center gap-x-3">
+ <input
+ type="radio"
+ name="template"
+ checked={selectedTemplate?.title === tmpl.title}
+ disabled={!hasFeature}
+ onChange={() => applyTemplate(tmpl)}
+ className="shrink-0"
+ />
+ <Icon
+ className="w-8 h-8 shrink-0"
+ strokeWidth={1}
+ />
+ <div className="flex-1">
+ <span className="text-base font-medium text-gray-900">
+ {tmpl.title}
+ </span>
+ <p className="text-sm text-gray-600">
+ {getTemplateDescription(tmpl.title)}
+ </p>
+ </div>
+ </div>
+ </label>
+ );
+ })}
+ </div>
+ </div>
+ )}
+
+ {/* Basic information step */}
+ {currentStep === basicInfoStep && (
+ <div className="flex flex-col gap-y-6">
+ <div className="text-center flex flex-col gap-y-2">
+ <h2 className="text-2xl font-bold text-gray-900">
+ {t("common.general")}
+ </h2>
+ <p className="text-gray-600">
+ {t("settings.sso.form.general-setting-description")}
+ </p>
+ </div>
+ <div className="max-w-2xl mx-auto flex flex-col gap-y-6 w-full">
+ <div>
+ <label className="block text-base font-semibold text-gray-800 mb-2">
+ {t("settings.sso.form.name")}{" "}
+ <span className="text-error">*</span>
+ </label>
+ <Input
+ value={title}
+ onChange={(e) => setTitle(e.target.value)}
+ placeholder={t("settings.sso.form.name-description")}
+ className="mb-2"
+ />
+ <ResourceIdField
+ ref={resourceIdFieldRef}
+ value={resourceId}
+ resourceType="idp"
+ resourceName="SSO"
+ resourceTitle={title}
+ suffix
+ validate={validateResourceId}
+ onChange={setResourceId}
+ onValidationChange={setResourceIdValid}
+ />
+ </div>
+ <div>
+ <label className="block text-base font-semibold text-gray-800 mb-2">
+ {t("settings.sso.form.domain")}
+ </label>
+ <Input
+ value={domain}
+ onChange={(e) => setDomain(e.target.value)}
+ disabled={selectedTemplate?.domainDisabled}
+ placeholder={t("settings.sso.form.domain-description")}
+ />
+ <p className="text-sm text-gray-600 mt-1">
+ {t("settings.sso.form.domain-optional-hint")}
+ </p>
+ </div>
+ </div>
+ </div>
+ )}
+
+ {/* Configuration step */}
+ {currentStep === configStep && (
+ <div className="flex flex-col gap-y-6">
+ <div className="text-center flex flex-col gap-y-2">
+ <h2 className="text-2xl font-bold text-gray-900">
+ {t("settings.sso.form.configuration")}
+ </h2>
+ <p className="text-gray-600">
+ {t("settings.sso.form.configuration-description")}
+ </p>
+ </div>
+ <div className="max-w-3xl mx-auto w-full">
+ {(selectedType === IdentityProviderType.OAUTH2 ||
+ selectedType === IdentityProviderType.OIDC) && (
+ <div className="mb-6">
+ <ExternalURLInfo type={selectedType} />
+ </div>
+ )}
+ <ProviderConfigForm
+ providerType={selectedType}
+ configForOAuth2={configForOAuth2}
+ configForOIDC={configForOIDC}
+ configForLDAP={configForLDAP}
+ scopesString={scopesString}
+ onUpdateOAuth2={setConfigForOAuth2}
+ onUpdateOIDC={setConfigForOIDC}
+ onUpdateLDAP={setConfigForLDAP}
+ onUpdateScopes={setScopesString}
+ />
+ </div>
+ </div>
+ )}
+
+ {/* User information mapping step */}
+ {currentStep === mappingStep && (
+ <div className="flex flex-col gap-y-6">
+ <div className="text-center flex flex-col gap-y-2">
+ <h2 className="text-2xl font-bold text-gray-900">
+ {t("settings.sso.form.user-information-mapping")}
+ </h2>
+ <p className="text-gray-600">
+ {t(
+ "settings.sso.form.user-information-mapping-description"
+ )}{" "}
+ <a
+ href="https://docs.bytebase.com/administration/sso/oauth2#user-information-field-mapping?source=console"
+ target="_blank"
+ rel="noopener noreferrer"
+ className="text-accent hover:underline ml-1"
+ >
+ {t("common.learn-more")}
+ </a>
+ </p>
+ </div>
+ <div className="max-w-2xl mx-auto flex flex-col gap-y-6 w-full">
+ <FieldMappingForm
+ providerType={selectedType}
+ fieldMapping={fieldMapping}
+ onChange={setFieldMapping}
+ />
+ <div>
+ <TestConnectionButton
+ disabled={!allowTestConnection}
+ isCreating
+ idp={idpToCreate}
+ />
+ </div>
+ </div>
+ </div>
+ )}
+ </div>
+ </div>
+ </div>
+
+ {/* Footer */}
+ <div className="flex items-center justify-end gap-x-2 px-6 py-4 border-t">
+ {currentStep === 1 ? (
+ <Button variant="outline" onClick={onClose}>
+ {t("common.cancel")}
+ </Button>
+ ) : (
+ <Button variant="outline" onClick={handlePrev}>
+ {t("common.back")}
+ </Button>
+ )}
+ {!isLastStep ? (
+ <Button disabled={!canProceed} onClick={handleNext}>
+ {t("common.next")}
+ </Button>
+ ) : (
+ <Button disabled={!canCreate || isCreating} onClick={handleCreate}>
+ {t("common.create")}
+ </Button>
+ )}
+ </div>
+
+ {isCreating && (
+ <div className="absolute inset-0 z-10 bg-white/50 flex items-center justify-center">
+ <div className="animate-spin h-6 w-6 border-2 border-accent border-t-transparent rounded-full" />
+ </div>
+ )}
+ </div>
+ </>
+ );
+}
+
+// ============================================================
+// IDPsPage (main)
+// ============================================================
+
+export function IDPsPage() {
+ const { t } = useTranslation();
+ const identityProviderStore = useIdentityProviderStore();
+
+ const subscriptionStore = useSubscriptionV1Store();
+
+ const [ready, setReady] = useState(false);
+ const [showCreateDrawer, setShowCreateDrawer] = useState(false);
+
+ const hasSSOFeature = useVueState(() =>
+ subscriptionStore.hasFeature(PlanFeature.FEATURE_GOOGLE_AND_GITHUB_SSO)
+ );
+ const canCreate = hasWorkspacePermissionV2("bb.identityProviders.create");
+
+ const identityProviderList = useVueState(() => [
+ ...identityProviderStore.identityProviderList,
+ ]);
+
+ useEffect(() => {
+ identityProviderStore
+ .fetchIdentityProviderList()
+ .finally(() => setReady(true));
+ }, []);
+
+ const handleCreateSSO = () => {
+ if (!hasSSOFeature) return;
+ setShowCreateDrawer(true);
+ };
+
+ const handleProviderCreated = (provider: IdentityProvider) => {
+ setShowCreateDrawer(false);
+ router.replace({
+ name: WORKSPACE_ROUTE_IDENTITY_PROVIDER_DETAIL,
+ params: {
+ idpId: getIdentityProviderResourceId(provider.name),
+ },
+ });
+ };
+
+ const handleRowClick = (idp: IdentityProvider) => {
+ router.push({
+ name: WORKSPACE_ROUTE_IDENTITY_PROVIDER_DETAIL,
+ params: {
+ idpId: getIdentityProviderResourceId(idp.name),
+ },
+ });
+ };
+
+ return (
+ <div className="w-full px-4 py-4 flex flex-col gap-y-4">
+ <FeatureAttention feature={PlanFeature.FEATURE_GOOGLE_AND_GITHUB_SSO} />
+
+ <div className="textinfolabel">
+ {t("settings.sso.description")}{" "}
+ <a
+ href="https://docs.bytebase.com/administration/sso/overview?source=console"
+ target="_blank"
+ rel="noopener noreferrer"
+ className="text-accent hover:underline"
+ >
+ {t("common.learn-more")}
+ </a>
+ </div>
+
+ <div className="w-full flex justify-end">
+ <Button disabled={!canCreate} onClick={handleCreateSSO}>
+ <Plus className="h-4 w-4 mr-1" />
+ {t("settings.sso.create")}
+ </Button>
+ </div>
+
+ {ready ? (
+ <div className="border rounded-md overflow-hidden">
+ <table className="w-full text-sm">
+ <thead>
+ <tr className="border-b bg-control-bg">
+ <th className="px-4 py-2 text-left font-medium w-40">
+ {t("common.id")}
+ </th>
+ <th className="px-4 py-2 text-left font-medium">
+ {t("common.name")}
+ </th>
+ <th className="px-4 py-2 text-left font-medium w-32">
+ {t("common.type")}
+ </th>
+ <th className="px-4 py-2 text-left font-medium w-48">
+ {t("settings.sso.form.domain")}
+ </th>
+ </tr>
+ </thead>
+ <tbody>
+ {identityProviderList.length === 0 ? (
+ <tr>
+ <td
+ colSpan={4}
+ className="px-4 py-8 text-center text-control-light"
+ >
+ {t("common.no-data")}
+ </td>
+ </tr>
+ ) : (
+ identityProviderList.map((idp, i) => (
+ <tr
+ key={idp.name}
+ className={`border-b last:border-b-0 cursor-pointer hover:bg-gray-50 ${
+ i % 2 === 1 ? "bg-gray-50/50" : ""
+ }`}
+ onClick={() => handleRowClick(idp)}
+ >
+ <td className="px-4 py-2">
+ {getIdentityProviderResourceId(idp.name)}
+ </td>
+ <td className="px-4 py-2">{idp.title}</td>
+ <td className="px-4 py-2">
+ {identityProviderTypeToString(idp.type)}
+ </td>
+ <td className="px-4 py-2">{idp.domain || "-"}</td>
+ </tr>
+ ))
+ )}
+ </tbody>
+ </table>
+ </div>
+ ) : (
+ <div className="flex items-center justify-center h-32">
+ <div className="animate-spin h-6 w-6 border-2 border-accent border-t-transparent rounded-full" />
+ </div>
+ )}
+
+ {showCreateDrawer && (
+ <CreateWizardDrawer
+ onClose={() => setShowCreateDrawer(false)}
+ onCreated={handleProviderCreated}
+ />
+ )}
+ </div>
+ );
+}
diff --git a/frontend/src/router/dashboard/workspace.ts b/frontend/src/router/dashboard/workspace.ts
index a7d4b6a39b..a1f1d58fc5 100644
--- a/frontend/src/router/dashboard/workspace.ts
+++ b/frontend/src/router/dashboard/workspace.ts
@@ -214,13 +214,14 @@ const workspaceRoutes: RouteRecordRaw[] = [
{
path: "",
name: WORKSPACE_ROUTE_IDENTITY_PROVIDERS,
- component: () => import("@/views/SettingWorkspaceSSO.vue"),
+ component: () => import("@/react/ReactPageMount.vue"),
+ props: () => ({ page: "IDPsPage" }),
},
{
path: ":idpId",
name: WORKSPACE_ROUTE_IDENTITY_PROVIDER_DETAIL,
- component: () => import("@/views/SettingWorkspaceSSODetail.vue"),
- props: true,
+ component: () => import("@/react/ReactPageMount.vue"),
+ props: () => ({ page: "IDPDetailPage" }),
},
],
},
diff --git a/frontend/src/views/SettingWorkspaceSSO.vue b/frontend/src/views/SettingWorkspaceSSO.vue
deleted file mode 100644
index e038804265..0000000000
--- a/frontend/src/views/SettingWorkspaceSSO.vue
+++ /dev/null
@@ -1,109 +0,0 @@
-<template>
- <div class="w-full px-4 py-4 flex flex-col gap-y-4">
- <div class="textinfolabel">
- {{ $t("settings.sso.description") }}
- <LearnMoreLink
- url="https://docs.bytebase.com/administration/sso/overview?source=console"
- />
- </div>
- <div class="w-full flex flex-row justify-end items-center">
- <PermissionGuardWrapper
- v-slot="slotProps"
- :permissions="['bb.identityProviders.create']"
- >
- <NButton
- type="primary"
- :disabled="slotProps.disabled"
- @click="handleCreateSSO"
- >
- <template #icon>
- <PlusIcon class="h-4 w-4" />
- <FeatureBadge
- :feature="PlanFeature.FEATURE_GOOGLE_AND_GITHUB_SSO"
- class="text-white"
- />
- </template>
- {{ $t("settings.sso.create") }}
- </NButton>
- </PermissionGuardWrapper>
- </div>
- <IdentityProviderTable
- :identity-provider-list="identityProviderList"
- :bordered="true"
- :loading="state.isLoading"
- />
- </div>
-
- <FeatureModal
- :feature="PlanFeature.FEATURE_GOOGLE_AND_GITHUB_SSO"
- :open="state.showFeatureModal"
- @cancel="state.showFeatureModal = false"
- />
-
- <IdentityProviderCreateWizard
- :show="state.showCreateDrawer"
- @update:show="state.showCreateDrawer = $event"
- @created="handleProviderCreated"
- />
-</template>
-
-<script lang="ts" setup>
-import { PlusIcon } from "lucide-vue-next";
-import { NButton } from "naive-ui";
-import { computed, onMounted, reactive } from "vue";
-import { useRouter } from "vue-router";
-import { FeatureBadge, FeatureModal } from "@/components/FeatureGuard";
-import {
- IdentityProviderCreateWizard,
- IdentityProviderTable,
-} from "@/components/IdentityProvider";
-import LearnMoreLink from "@/components/LearnMoreLink.vue";
-import PermissionGuardWrapper from "@/components/Permission/PermissionGuardWrapper.vue";
-import { WORKSPACE_ROUTE_IDENTITY_PROVIDER_DETAIL } from "@/router/dashboard/workspaceRoutes";
-import { featureToRef, getIdentityProviderResourceId } from "@/store";
-import { useIdentityProviderStore } from "@/store/modules/idp";
-import type { IdentityProvider } from "@/types/proto-es/v1/idp_service_pb";
-import { PlanFeature } from "@/types/proto-es/v1/subscription_service_pb";
-
-interface LocalState {
- isLoading: boolean;
- showFeatureModal: boolean;
- showCreateDrawer: boolean;
-}
-
-const router = useRouter();
-const state = reactive<LocalState>({
- isLoading: true,
- showFeatureModal: false,
- showCreateDrawer: false,
-});
-const identityProviderStore = useIdentityProviderStore();
-const hasSSOFeature = featureToRef(PlanFeature.FEATURE_GOOGLE_AND_GITHUB_SSO);
-
-const identityProviderList = computed(() => {
- return identityProviderStore.identityProviderList;
-});
-
-onMounted(async () => {
- await identityProviderStore.fetchIdentityProviderList();
- state.isLoading = false;
-});
-
-const handleCreateSSO = () => {
- if (!hasSSOFeature.value) {
- state.showFeatureModal = true;
- return;
- }
- state.showCreateDrawer = true;
-};
-
-const handleProviderCreated = (provider: IdentityProvider) => {
- state.showCreateDrawer = false;
- router.replace({
- name: WORKSPACE_ROUTE_IDENTITY_PROVIDER_DETAIL,
- params: {
- idpId: getIdentityProviderResourceId(provider.name),
- },
- });
-};
-</script>
diff --git a/frontend/src/views/SettingWorkspaceSSODetail.vue b/frontend/src/views/SettingWorkspaceSSODetail.vue
deleted file mode 100644
index afd0ad303c..0000000000
--- a/frontend/src/views/SettingWorkspaceSSODetail.vue
+++ /dev/null
@@ -1,77 +0,0 @@
-<template>
- <div class="w-full px-4 py-4 flex flex-col gap-y-6">
- <div class="w-full flex flex-row justify-between items-center">
- <div class="textinfolabel mr-4">
- {{ $t("settings.sso.description") }}
- <LearnMoreLink
- url="https://docs.bytebase.com/administration/sso/overview?source=console"
- />
- </div>
- </div>
-
- <!-- Edit existing identity provider -->
- <IdentityProviderEditForm
- v-if="!isLoading && currentIdentityProvider"
- :identity-provider="currentIdentityProvider"
- @updated="props.onUpdated"
- @deleted="props.onDeleted"
- />
-
- <BBSpin v-else class="w-full h-64" />
- </div>
-
- <FeatureModal
- :feature="PlanFeature.FEATURE_ENTERPRISE_SSO"
- :open="state.showFeatureModal"
- @cancel="state.showFeatureModal = false"
- />
-</template>
-
-<script lang="ts" setup>
-import { computed, reactive, ref, watchEffect } from "vue";
-import { BBSpin } from "@/bbkit";
-import { FeatureModal } from "@/components/FeatureGuard";
-import { IdentityProviderEditForm } from "@/components/IdentityProvider";
-import LearnMoreLink from "@/components/LearnMoreLink.vue";
-import { useIdentityProviderStore } from "@/store/modules/idp";
-import { idpNamePrefix } from "@/store/modules/v1/common";
-import type { IdentityProvider } from "@/types/proto-es/v1/idp_service_pb";
-import { PlanFeature } from "@/types/proto-es/v1/subscription_service_pb";
-
-const props = defineProps<{
- idpId?: string;
- onCreated?: (identityProvider: IdentityProvider) => void;
- onUpdated?: (identityProvider: IdentityProvider) => void;
- onDeleted?: () => void;
- onCanceled?: () => void;
-}>();
-
-interface LocalState {
- showFeatureModal: boolean;
-}
-
-const state = reactive<LocalState>({
- showFeatureModal: false,
-});
-const identityProviderStore = useIdentityProviderStore();
-const isLoading = ref<boolean>(true);
-
-const idpName = computed(() => {
- if (!props.idpId) {
- return "";
- }
- return `${idpNamePrefix}${props.idpId}`;
-});
-
-watchEffect(async () => {
- if (idpName.value) {
- isLoading.value = true;
- await identityProviderStore.getOrFetchIdentityProviderByName(idpName.value);
- }
- isLoading.value = false;
-});
-
-const currentIdentityProvider = computed(() => {
- return identityProviderStore.getIdentityProviderByName(idpName.value);
-});
-</script>