Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
chore: feature guard for directory sync (#13785)
ecmadao7da3c60a0d03
diff --git a/backend/api/directory-sync/webhook.go b/backend/api/directory-sync/webhook.goindex beec205674..55717f2b31 100644--- a/backend/api/directory-sync/webhook.go+++ b/backend/api/directory-sync/webhook.go@@ -30,15 +30,19 @@ const entraIDSource = "Entra ID"// https://learn.microsoft.com/en-us/entra/identity/app-provisioning/use-scim-to-provision-users-and-groupsfunc (s *Service) RegisterDirectorySyncRoutes(g *echo.Group) {g.POST("/workspaces/:workspaceID/Users", func(c echo.Context) error {+ ctx := c.Request().Context()+ if err := s.validRequestURL(ctx, c); err != nil {+ return c.String(http.StatusInternalServerError, err.Error())+ }+ if err := s.licenseService.IsFeatureEnabled(api.FeaturePasswordRestriction); err != nil {+ return c.String(http.StatusForbidden, err.Error())+ }+body, err := io.ReadAll(c.Request().Body)if err != nil {return c.String(http.StatusInternalServerError, fmt.Sprintf("failed to read body, error %v", err))}- ctx := c.Request().Context()- if err := s.validRequestURL(ctx, c); err != nil {- return c.String(http.StatusInternalServerError, err.Error())- }var aadUser AADUserif err := json.Unmarshal(body, &aadUser); err != nil {return c.String(http.StatusInternalServerError, fmt.Sprintf("failed to unmarshal body, error %v", err))@@ -97,6 +101,9 @@ func (s *Service) RegisterDirectorySyncRoutes(g *echo.Group) {if err := s.validRequestURL(ctx, c); err != nil {return c.String(http.StatusInternalServerError, err.Error())}+ if err := s.licenseService.IsFeatureEnabled(api.FeaturePasswordRestriction); err != nil {+ return c.String(http.StatusForbidden, err.Error())+ }uid, err := strconv.Atoi(c.Param("userID"))if err != nil {@@ -125,6 +132,9 @@ func (s *Service) RegisterDirectorySyncRoutes(g *echo.Group) {if err := s.validRequestURL(ctx, c); err != nil {return c.String(http.StatusInternalServerError, err.Error())}+ if err := s.licenseService.IsFeatureEnabled(api.FeaturePasswordRestriction); err != nil {+ return c.String(http.StatusForbidden, err.Error())+ }response := &ListUsersResponse{Schemas: []string{@@ -178,6 +188,9 @@ func (s *Service) RegisterDirectorySyncRoutes(g *echo.Group) {if err := s.validRequestURL(ctx, c); err != nil {return c.String(http.StatusInternalServerError, err.Error())}+ if err := s.licenseService.IsFeatureEnabled(api.FeaturePasswordRestriction); err != nil {+ return c.String(http.StatusForbidden, err.Error())+ }uid, err := strconv.Atoi(c.Param("userID"))if err != nil {@@ -207,6 +220,9 @@ func (s *Service) RegisterDirectorySyncRoutes(g *echo.Group) {if err := s.validRequestURL(ctx, c); err != nil {return c.String(http.StatusInternalServerError, err.Error())}+ if err := s.licenseService.IsFeatureEnabled(api.FeaturePasswordRestriction); err != nil {+ return c.String(http.StatusForbidden, err.Error())+ }body, err := io.ReadAll(c.Request().Body)if err != nil {@@ -278,6 +294,9 @@ func (s *Service) RegisterDirectorySyncRoutes(g *echo.Group) {if err := s.validRequestURL(ctx, c); err != nil {return c.String(http.StatusInternalServerError, err.Error())}+ if err := s.licenseService.IsFeatureEnabled(api.FeaturePasswordRestriction); err != nil {+ return c.String(http.StatusForbidden, err.Error())+ }body, err := io.ReadAll(c.Request().Body)if err != nil {@@ -313,6 +332,9 @@ func (s *Service) RegisterDirectorySyncRoutes(g *echo.Group) {if err := s.validRequestURL(ctx, c); err != nil {return c.String(http.StatusInternalServerError, err.Error())}+ if err := s.licenseService.IsFeatureEnabled(api.FeaturePasswordRestriction); err != nil {+ return c.String(http.StatusForbidden, err.Error())+ }email, err := decodeGroupEmail(c.Param("groupID"))if err != nil {@@ -341,6 +363,9 @@ func (s *Service) RegisterDirectorySyncRoutes(g *echo.Group) {if err := s.validRequestURL(ctx, c); err != nil {return c.String(http.StatusInternalServerError, err.Error())}+ if err := s.licenseService.IsFeatureEnabled(api.FeaturePasswordRestriction); err != nil {+ return c.String(http.StatusForbidden, err.Error())+ }response := &ListGroupsResponse{Schemas: []string{@@ -391,6 +416,9 @@ func (s *Service) RegisterDirectorySyncRoutes(g *echo.Group) {if err := s.validRequestURL(ctx, c); err != nil {return c.String(http.StatusInternalServerError, err.Error())}+ if err := s.licenseService.IsFeatureEnabled(api.FeaturePasswordRestriction); err != nil {+ return c.String(http.StatusForbidden, err.Error())+ }email, err := decodeGroupEmail(c.Param("groupID"))if err != nil {@@ -413,6 +441,9 @@ func (s *Service) RegisterDirectorySyncRoutes(g *echo.Group) {if err := s.validRequestURL(ctx, c); err != nil {return c.String(http.StatusInternalServerError, err.Error())}+ if err := s.licenseService.IsFeatureEnabled(api.FeaturePasswordRestriction); err != nil {+ return c.String(http.StatusForbidden, err.Error())+ }body, err := io.ReadAll(c.Request().Body)if err != nil {diff --git a/backend/enterprise/api/plan.yaml b/backend/enterprise/api/plan.yamlindex adf42eb70a..042f6cc186 100644--- a/backend/enterprise/api/plan.yaml+++ b/backend/enterprise/api/plan.yaml@@ -15,6 +15,8 @@ categoryList:- database-group- batch-change- issue-advanced-search+ - password-restriction+ - directory-sync- type: sql-editorfeatureList:- auto-complete@@ -231,6 +233,8 @@ planList:- type: custom-approval- type: issue-advanced-searchcontent: issue-advanced-search-advanced+ - type: password-restriction+ - type: directory-sync# SQL Editor- type: auto-complete- type: schema-editordiff --git a/backend/legacyapi/plan.go b/backend/legacyapi/plan.goindex a7a576d94c..070b590115 100644--- a/backend/legacyapi/plan.go+++ b/backend/legacyapi/plan.go@@ -63,6 +63,8 @@ const (FeatureExternalSecretManager FeatureType = "bb.feature.external-secret-manager"// FeaturePasswordRestriction allows user to configure the password restriction.FeaturePasswordRestriction FeatureType = "bb.feature.password-restriction"+ // FeatureDirectorySync allows to sync users and groups from Entra ID.+ FeatureDirectorySync FeatureType = "bb.feature.directory-sync"// FeatureRBAC enables RBAC.//@@ -198,6 +200,8 @@ func (e FeatureType) Name() string {return "Secure token"case FeaturePasswordRestriction:return "Password restriction"+ case FeatureDirectorySync:+ return "Directory sync"case FeatureExternalSecretManager:return "External Secret Manager"case FeatureRBAC:@@ -298,6 +302,7 @@ var FeatureMatrix = map[FeatureType][3]bool{FeatureDisallowPasswordSignin: {false, false, true},FeatureSecureToken: {false, false, true},FeaturePasswordRestriction: {false, false, true},+ FeatureDirectorySync: {false, false, true},FeatureExternalSecretManager: {false, false, true},FeatureRBAC: {true, true, true},FeatureWatermark: {false, false, true},diff --git a/frontend/i18n.ts b/frontend/i18n.tsindex 768b1fc7ad..d0d5a2d283 100644--- a/frontend/i18n.ts+++ b/frontend/i18n.ts@@ -176,29 +176,24 @@ async function addMissingKeysFromSource(// Main function to load the source file and update each target fileasync function updateLocalizationFiles() {- const sourceData = await loadJsonFile(`src/locales/${SOURCE_LANG}.json`);- const sourceSQLReviewData = await loadJsonFile(- `src/locales/sql-review/${SOURCE_LANG}.json`- );-- for (const lang of TARGET_LANGS) {- const langFile = `src/locales/${lang}.json`;- const targetData = await loadJsonFile(langFile);- const updatedData = await addMissingKeysFromSource(- sourceData,- targetData,- lang.split("-")[0]- );- await saveJsonFile(langFile, updatedData);-- const langSQLReviewFile = `src/locales/sql-review/${lang}.json`;- const targetSQLReviewData = await loadJsonFile(langSQLReviewFile);- const updatedSQLReviewData = await addMissingKeysFromSource(- sourceSQLReviewData,- targetSQLReviewData,- lang.split("-")[0]- );- await saveJsonFile(langSQLReviewFile, updatedSQLReviewData);+ const folders = [+ "src/locales",+ "src/locales/sql-review",+ "src/locales/subscription",+ ];++ for (const folder of folders) {+ const sourceData = await loadJsonFile(`${folder}/${SOURCE_LANG}.json`);+ for (const lang of TARGET_LANGS) {+ const langFile = `${folder}/${lang}.json`;+ const targetData = await loadJsonFile(langFile);+ const updatedData = await addMissingKeysFromSource(+ sourceData,+ targetData,+ lang.split("-")[0]+ );+ await saveJsonFile(langFile, updatedData);+ }}}diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.jsonindex dbeee7ca4c..1ba8797803 100644--- a/frontend/src/locales/en-US.json+++ b/frontend/src/locales/en-US.json@@ -2899,6 +2899,10 @@"bb-feature-password-restriction": {"title": "Password restriction","desc": "Allow to configure the restriction for users' password"+ },+ "bb-feature-directory-sync": {+ "title": "Directory sync",+ "desc": "Sync users and groups from Entra ID (formerly Azure AD) to your Bytebase instance"}}},diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.jsonindex 56e9ae7a15..3c369003ec 100644--- a/frontend/src/locales/es-ES.json+++ b/frontend/src/locales/es-ES.json@@ -2899,6 +2899,10 @@"bb-feature-password-restriction": {"title": "Restricción de contraseña","desc": "Permitir configurar la restricción de contraseña de los usuarios"+ },+ "bb-feature-directory-sync": {+ "title": "Sincronización de directorios",+ "desc": "Sincronice usuarios y grupos de Entra ID (anteriormente Azure AD) con su instancia de Bytebase"}}},@@ -3749,4 +3753,4 @@"setup": {"self": "Configuración"}-}+}\ No newline at end of filediff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.jsonindex 7a5ec01b11..3f8139c7c7 100644--- a/frontend/src/locales/ja-JP.json+++ b/frontend/src/locales/ja-JP.json@@ -2899,6 +2899,10 @@"bb-feature-password-restriction": {"title": "パスワード制限","desc": "ユーザーのパスワードの制限を設定できるようにする"+ },+ "bb-feature-directory-sync": {+ "title": "ディレクトリ同期",+ "desc": "Entra ID (旧 Azure AD) のユーザーとグループを Bytebase インスタンスに同期します"}}},@@ -3749,4 +3753,4 @@"setup": {"self": "設定"}-}+}\ No newline at end of filediff --git a/frontend/src/locales/subscription/en-US.json b/frontend/src/locales/subscription/en-US.jsonindex c2b835a1c0..1291f27918 100644--- a/frontend/src/locales/subscription/en-US.json+++ b/frontend/src/locales/subscription/en-US.json@@ -89,7 +89,9 @@"issue-advanced-search": "Issue advanced search","issue-advanced-search-basic": "30-day limit","issue-advanced-search-basic-tooltip": "Issues older than 30 days are hidden",- "issue-advanced-search-advanced": "Unlimited"+ "issue-advanced-search-advanced": "Unlimited",+ "password-restriction": "Password restriction",+ "directory-sync": "Sync from Entra ID"}},"sql-editor": {diff --git a/frontend/src/locales/subscription/es-ES.json b/frontend/src/locales/subscription/es-ES.jsonindex 33fc318e66..bd12990812 100644--- a/frontend/src/locales/subscription/es-ES.json+++ b/frontend/src/locales/subscription/es-ES.json@@ -89,7 +89,9 @@"issue-advanced-search": "Emitir búsqueda avanzada","issue-advanced-search-basic": "límite de 30 días","issue-advanced-search-basic-tooltip": "Los problemas de más de 30 días están ocultos",- "issue-advanced-search-advanced": "Ilimitado"+ "issue-advanced-search-advanced": "Ilimitado",+ "password-restriction": "Restricción de contraseña",+ "directory-sync": "Sincronización desde Entra ID"}},"sql-editor": {@@ -188,4 +190,4 @@"2fa": "Autenticación de dos factores (2FA)","custom-approval": "Aprobación personalizada"}-}+}\ No newline at end of filediff --git a/frontend/src/locales/subscription/ja-JP.json b/frontend/src/locales/subscription/ja-JP.jsonindex 904fe5fcb5..ca25ad0598 100644--- a/frontend/src/locales/subscription/ja-JP.json+++ b/frontend/src/locales/subscription/ja-JP.json@@ -89,7 +89,9 @@"issue-advanced-search": "高度な検索","issue-advanced-search-basic": "30日間の制限","issue-advanced-search-basic-tooltip": "30日以上前の問題は非表示になります",- "issue-advanced-search-advanced": "無制限"+ "issue-advanced-search-advanced": "無制限",+ "password-restriction": "パスワード制限",+ "directory-sync": "Entra IDからの同期"}},"sql-editor": {@@ -188,4 +190,4 @@"2fa": "二要素認証(2FA)","custom-approval": "カスタム承認"}-}+}\ No newline at end of filediff --git a/frontend/src/locales/subscription/zh-CN.json b/frontend/src/locales/subscription/zh-CN.jsonindex 5f872a6e05..d5b1b69e90 100644--- a/frontend/src/locales/subscription/zh-CN.json+++ b/frontend/src/locales/subscription/zh-CN.json@@ -89,7 +89,9 @@"issue-advanced-search": "工单搜索","issue-advanced-search-basic": "30天内的历史","issue-advanced-search-basic-tooltip": "30 天之前的工单会被隐藏",- "issue-advanced-search-advanced": "无限制"+ "issue-advanced-search-advanced": "无限制",+ "password-restriction": "密码限制",+ "directory-sync": "同步 Entra ID"}},"sql-editor": {@@ -188,4 +190,4 @@"2fa": "双重认证 (2FA)","custom-approval": "自定义审批"}-}+}\ No newline at end of filediff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.jsonindex ed46d1e053..bfbfa2f701 100644--- a/frontend/src/locales/zh-CN.json+++ b/frontend/src/locales/zh-CN.json@@ -2899,6 +2899,10 @@"bb-feature-password-restriction": {"title": "密码限制","desc": "允许配置用户密码的规则"+ },+ "bb-feature-directory-sync": {+ "title": "目录同步",+ "desc": "将 Entra ID(以前称为 Azure AD)中的用户和组同步到您的 Bytebase 实例"}}},@@ -3749,4 +3753,4 @@"setup": {"self": "设置"}-}+}\ No newline at end of filediff --git a/frontend/src/types/plan.ts b/frontend/src/types/plan.tsindex 92d3fb5ce1..b5a64086a4 100644--- a/frontend/src/types/plan.ts+++ b/frontend/src/types/plan.ts@@ -22,6 +22,7 @@ export type FeatureType =| "bb.feature.issue-advanced-search"| "bb.feature.announcement"| "bb.feature.external-secret-manager"+ | "bb.feature.directory-sync"// Branding| "bb.feature.branding"// Change Workflowdiff --git a/frontend/src/views/SettingWorkspaceUsers.vue b/frontend/src/views/SettingWorkspaceUsers.vueindex f6b7a10bf8..7bb8db2d33 100644--- a/frontend/src/views/SettingWorkspaceUsers.vue+++ b/frontend/src/views/SettingWorkspaceUsers.vue@@ -55,10 +55,19 @@<NButtonv-if="allowGetSCIMSetting"class="capitalize"- @click="state.showAadSyncDrawer = true"+ @click="+ () => {+ if (!hasDirectorySyncFeature) {+ state.showFeatureModal = true;+ return;+ }+ state.showAadSyncDrawer = true;+ }+ "><template #icon>- <SettingsIcon class="h-5 w-5" />+ <SettingsIcon v-if="hasDirectorySyncFeature" class="h-5 w-5" />+ <FeatureBadge v-else feature="bb.feature.directory-sync" /></template>{{ $t(`settings.members.entra-sync.self`) }}</NButton>@@ -146,6 +155,12 @@:show="state.showAadSyncDrawer"@close="state.showAadSyncDrawer = false"/>++ <FeatureModal+ feature="bb.feature.directory-sync"+ :open="state.showFeatureModal"+ @cancel="state.showFeatureModal = false"+ /></template><script setup lang="ts">@@ -155,6 +170,7 @@ import { computed, onMounted, reactive, watch } from "vue";import { useI18n } from "vue-i18n";import { useRoute, useRouter, RouterLink } from "vue-router";import { FeatureAttention } from "@/components/FeatureGuard";+import { FeatureBadge, FeatureModal } from "@/components/FeatureGuard";import AADSyncDrawer from "@/components/User/Settings/AADSyncDrawer.vue";import CreateGroupDrawer from "@/components/User/Settings/CreateGroupDrawer.vue";import CreateUserDrawer from "@/components/User/Settings/CreateUserDrawer.vue";@@ -167,6 +183,7 @@ import {useUIStateStore,useGroupStore,useSettingV1Store,+ featureToRef,} from "@/store";import { groupNamePrefix } from "@/store/modules/v1/common";import {@@ -195,6 +212,7 @@ type LocalState = {showAadSyncDrawer: boolean;editingUser?: User;editingGroup?: Group;+ showFeatureModal: boolean;};defineProps<{@@ -209,6 +227,7 @@ const state = reactive<LocalState>({showCreateUserDrawer: false,showCreateGroupDrawer: false,showAadSyncDrawer: false,+ showFeatureModal: false,});const { t } = useI18n();@@ -248,6 +267,8 @@ const workspaceProfileSetting = computed(() =>));+const hasDirectorySyncFeature = featureToRef("bb.feature.directory-sync");+const allowGetSCIMSetting = computed(() =>hasWorkspacePermissionV2("bb.settings.get"));