Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
feat: restrict default IAM credentials in SaaS mode for security (#18161)
Danny Xu45b64edfde78
diff --git a/backend/api/v1/instance_service.go b/backend/api/v1/instance_service.goindex 6e8aaea317..324401e92b 100644--- a/backend/api/v1/instance_service.go+++ b/backend/api/v1/instance_service.go@@ -12,6 +12,7 @@ import ("github.com/bytebase/bytebase/backend/common""github.com/bytebase/bytebase/backend/common/log"+ "github.com/bytebase/bytebase/backend/component/config""github.com/bytebase/bytebase/backend/component/dbfactory""github.com/bytebase/bytebase/backend/component/iam""github.com/bytebase/bytebase/backend/component/sampleinstance"@@ -32,6 +33,7 @@ import (type InstanceService struct {v1connect.UnimplementedInstanceServiceHandlerstore *store.Store+ profile *config.ProfilelicenseService *enterprise.LicenseServicemetricReporter *metricreport.ReporterstateCfg *state.State@@ -42,9 +44,10 @@ type InstanceService struct {}// NewInstanceService creates a new InstanceService.-func NewInstanceService(store *store.Store, licenseService *enterprise.LicenseService, metricReporter *metricreport.Reporter, stateCfg *state.State, dbFactory *dbfactory.DBFactory, schemaSyncer *schemasync.Syncer, iamManager *iam.Manager, sampleInstanceManager *sampleinstance.Manager) *InstanceService {+func NewInstanceService(store *store.Store, profile *config.Profile, licenseService *enterprise.LicenseService, metricReporter *metricreport.Reporter, stateCfg *state.State, dbFactory *dbfactory.DBFactory, schemaSyncer *schemasync.Syncer, iamManager *iam.Manager, sampleInstanceManager *sampleinstance.Manager) *InstanceService {return &InstanceService{store: store,+ profile: profile,licenseService: licenseService,metricReporter: metricReporter,stateCfg: stateCfg,@@ -262,6 +265,11 @@ func (s *InstanceService) checkDataSource(instance *store.InstanceMessage, dataSreturn connect.NewError(connect.CodeInvalidArgument, errors.New("data source id is required"))}+ // Validate IAM credential restrictions in SaaS mode+ if err := s.validateIAMCredentialForSaaS(dataSource); err != nil {+ return err+ }+if err := s.licenseService.IsFeatureEnabledForInstance(v1pb.PlanFeature_FEATURE_EXTERNAL_SECRET_MANAGER, instance); err != nil {missingFeatureError := connect.NewError(connect.CodePermissionDenied, err)if dataSource.GetExternalSecret() != nil {@@ -278,6 +286,33 @@ func (s *InstanceService) checkDataSource(instance *store.InstanceMessage, dataSreturn nil}+func (s *InstanceService) validateIAMCredentialForSaaS(dataSource *storepb.DataSource) error {+ if !s.profile.SaaS {+ return nil+ }++ // Check if using IAM authentication+ iamAuthTypes := map[storepb.DataSource_AuthenticationType]bool{+ storepb.DataSource_GOOGLE_CLOUD_SQL_IAM: true,+ storepb.DataSource_AWS_RDS_IAM: true,+ storepb.DataSource_AZURE_IAM: true,+ }++ if !iamAuthTypes[dataSource.GetAuthenticationType()] {+ return nil+ }++ // Check if using default credentials (iam_extension is not set)+ if dataSource.GetIamExtension() == nil {+ return connect.NewError(+ connect.CodeInvalidArgument,+ errors.New("default credentials are not allowed in SaaS mode for security. Please provide specific credentials"),+ )+ }++ return nil+}+// UpdateInstance updates an instance.func (s *InstanceService) UpdateInstance(ctx context.Context, req *connect.Request[v1pb.UpdateInstanceRequest]) (*connect.Response[v1pb.Instance], error) {if req.Msg.Instance == nil {diff --git a/backend/server/grpc_routes.go b/backend/server/grpc_routes.goindex baa455c38e..5085b476f7 100644--- a/backend/server/grpc_routes.go+++ b/backend/server/grpc_routes.go@@ -81,7 +81,7 @@ func configureGrpcRouters(groupService := apiv1.NewGroupService(stores, iamManager, licenseService)identityProviderService := apiv1.NewIdentityProviderService(stores, licenseService)instanceRoleService := apiv1.NewInstanceRoleService(stores, dbFactory)- instanceService := apiv1.NewInstanceService(stores, licenseService, metricReporter, stateCfg, dbFactory, schemaSyncer, iamManager, sampleInstanceManager)+ instanceService := apiv1.NewInstanceService(stores, profile, licenseService, metricReporter, stateCfg, dbFactory, schemaSyncer, iamManager, sampleInstanceManager)issueService := apiv1.NewIssueService(stores, webhookManager, stateCfg, licenseService, profile, iamManager, metricReporter)orgPolicyService := apiv1.NewOrgPolicyService(stores, licenseService)planService := apiv1.NewPlanService(stores, sheetManager, licenseService, dbFactory, stateCfg, profile, iamManager)diff --git a/frontend/src/components/InstanceForm/DataSourceSection/CredentialSourceForm.vue b/frontend/src/components/InstanceForm/DataSourceSection/CredentialSourceForm.vueindex 4da2873dcd..82f17bae6a 100644--- a/frontend/src/components/InstanceForm/DataSourceSection/CredentialSourceForm.vue+++ b/frontend/src/components/InstanceForm/DataSourceSection/CredentialSourceForm.vue@@ -9,12 +9,28 @@class="textlabel mt-2":disabled="!allowEdit">- <NRadio- v-for="option in iamExtensionOptions"- :value="option.value"- :key="option.value"- :label="option.label"- />+ <template v-for="option in iamExtensionOptions" :key="option.value">+ <NTooltip+ v-if="option.disabled"+ :show-arrow="true"+ trigger="hover"+ >+ <template #trigger>+ <NRadio+ :value="option.value"+ :label="option.label"+ :disabled="!allowEdit || option.disabled"+ />+ </template>+ {{ $t("instance.iam-extension.saas-default-credential-restriction") }}+ </NTooltip>+ <NRadio+ v-else+ :value="option.value"+ :label="option.label"+ :disabled="!allowEdit"+ />+ </template></NRadioGroup><template v-if="credentialSource === 'specific-credential'"><div@@ -268,9 +284,10 @@<script lang="tsx" setup>/* eslint-disable vue/no-mutating-props */import { create } from "@bufbuild/protobuf";-import { NInput, NRadio, NRadioGroup } from "naive-ui";+import { NInput, NRadio, NRadioGroup, NTooltip } from "naive-ui";import { computed, ref, watch } from "vue";import { useI18n } from "vue-i18n";+import { useActuatorV1Store } from "@/store";import {DataSource_AuthenticationType,DataSource_AWSCredentialSchema,@@ -288,14 +305,31 @@ const props = defineProps<{}>();const credentialSource = ref<credentialSource>("default");+const actuatorStore = useActuatorV1Store();const { t } = useI18n();+const isIAMAuthentication = computed(() => {+ return (+ props.dataSource.authenticationType ===+ DataSource_AuthenticationType.GOOGLE_CLOUD_SQL_IAM ||+ props.dataSource.authenticationType ===+ DataSource_AuthenticationType.AWS_RDS_IAM ||+ props.dataSource.authenticationType ===+ DataSource_AuthenticationType.AZURE_IAM+ );+});++const isDefaultCredentialDisabled = computed(() => {+ return actuatorStore.isSaaSMode && isIAMAuthentication.value;+});+const iamExtensionOptions = computed(() => {return [{label: t("common.Default"),value: "default",+ disabled: isDefaultCredentialDisabled.value,},{label: t("instance.iam-extension.specific-credential"),@@ -327,6 +361,17 @@ watch(});+// Force specific credential in SaaS mode for IAM authentication+watch(+ () => isDefaultCredentialDisabled.value,+ (disabled) => {+ if (disabled && credentialSource.value === "default") {+ credentialSource.value = "specific-credential";+ }+ },+ { immediate: true }+);+watch(() => credentialSource.value,(source) => {diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.jsonindex 15e424cefc..b1c853fab0 100644--- a/frontend/src/locales/en-US.json+++ b/frontend/src/locales/en-US.json@@ -1404,7 +1404,8 @@"tenant-id": "Tenant ID","client-id": "Client ID","client-secret": "Client Secret",- "specific-credential": "Specific Credential"+ "specific-credential": "Specific Credential",+ "saas-default-credential-restriction": "Default credentials are not available in Bytebase Cloud for security. Please provide specific credentials."},"database-region": "Database Region","external-secret-gcp": {diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.jsonindex 6e7de07d1f..9a816727f2 100644--- a/frontend/src/locales/es-ES.json+++ b/frontend/src/locales/es-ES.json@@ -1404,7 +1404,8 @@"tenant-id": "Tenant ID","client-id": "Client ID","client-secret": "Client Secret",- "specific-credential": "Credencial específica"+ "specific-credential": "Credencial específica",+ "saas-default-credential-restriction": "Las credenciales predeterminadas no están disponibles en Bytebase Cloud por seguridad. Proporcione credenciales específicas."},"database-region": "Región de la base de datos","external-secret-gcp": {diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.jsonindex 38c3193a6b..f847886121 100644--- a/frontend/src/locales/ja-JP.json+++ b/frontend/src/locales/ja-JP.json@@ -1404,7 +1404,8 @@"tenant-id": "Tenant ID","client-id": "Client ID","client-secret": "Client Secret",- "specific-credential": "特定の資格情報"+ "specific-credential": "特定の資格情報",+ "saas-default-credential-restriction": "セキュリティ上の理由により、Bytebase Cloud ではデフォルトの認証情報は使用できません。具体的な認証情報を入力してください。"},"database-region": "データベース領域","external-secret-gcp": {diff --git a/frontend/src/locales/vi-VN.json b/frontend/src/locales/vi-VN.jsonindex c64bd83c13..e99b4f5798 100644--- a/frontend/src/locales/vi-VN.json+++ b/frontend/src/locales/vi-VN.json@@ -1404,7 +1404,8 @@"tenant-id": "Tenant ID","client-id": "Client ID","client-secret": "Client Secret",- "specific-credential": "Chứng chỉ cụ thể"+ "specific-credential": "Chứng chỉ cụ thể",+ "saas-default-credential-restriction": "Thông tin xác thực mặc định không khả dụng trong Bytebase Cloud vì lý do bảo mật. Vui lòng cung cấp thông tin xác thực cụ thể."},"database-region": "Khu vực cơ sở dữ liệu","external-secret-gcp": {diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.jsonindex d1e04962ee..f53e581c6e 100644--- a/frontend/src/locales/zh-CN.json+++ b/frontend/src/locales/zh-CN.json@@ -1404,7 +1404,8 @@"tenant-id": "Tenant ID","client-id": "Client ID","client-secret": "Client Secret",- "specific-credential": "指定凭证"+ "specific-credential": "指定凭证",+ "saas-default-credential-restriction": "出于安全考虑,Bytebase Cloud 不支持使用默认凭证。请提供具体凭证。"},"database-region": "数据库区域","external-secret-gcp": {