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 password restriction (#13771)
ecmadaoaf69852d1c58
diff --git a/backend/api/v1/setting_service.go b/backend/api/v1/setting_service.goindex ac47e99df5..6e35d8f7ca 100644--- a/backend/api/v1/setting_service.go+++ b/backend/api/v1/setting_service.go@@ -620,6 +620,9 @@ func (s *SettingService) UpdateSetting(ctx context.Context, request *v1pb.Update}storeSettingValue = string(bytes)case api.SettingPasswordRestriction:+ if err := s.licenseService.IsFeatureEnabled(api.FeaturePasswordRestriction); err != nil {+ return nil, status.Error(codes.PermissionDenied, err.Error())+ }passwordSetting := new(storepb.PasswordRestrictionSetting)if err := convertV1PbToStorePb(request.Setting.Value.GetPasswordRestrictionSetting(), passwordSetting); err != nil {return nil, status.Errorf(codes.Internal, "failed to unmarshal setting value for %s with error: %v", apiSettingName, err)diff --git a/backend/legacyapi/plan.go b/backend/legacyapi/plan.goindex e4dada7fa4..8dce4cd876 100644--- a/backend/legacyapi/plan.go+++ b/backend/legacyapi/plan.go@@ -61,6 +61,8 @@ const (FeatureSecureToken FeatureType = "bb.feature.secure-token"// FeatureExternalSecretManager uses secrets from external secret manager.FeatureExternalSecretManager FeatureType = "bb.feature.external-secret-manager"+ // FeaturePasswordRestriction allows user to configure the password restriction.+ FeaturePasswordRestriction FeatureType = "bb.feature.password-restriction"// FeatureRBAC enables RBAC.//@@ -192,6 +194,8 @@ func (e FeatureType) Name() string {return "Disallow password signin"case FeatureSecureToken:return "Secure token"+ case FeaturePasswordRestriction:+ return "Password restriction"case FeatureExternalSecretManager:return "External Secret Manager"case FeatureRBAC:@@ -289,6 +293,7 @@ var FeatureMatrix = map[FeatureType][3]bool{FeatureDisallowSignup: {false, false, true},FeatureDisallowPasswordSignin: {false, false, true},FeatureSecureToken: {false, false, true},+ FeaturePasswordRestriction: {false, false, true},FeatureExternalSecretManager: {false, false, true},FeatureRBAC: {true, true, true},FeatureWatermark: {false, false, true},diff --git a/backend/server/init.go b/backend/server/init.goindex 319b48dd7e..35b6b47821 100644--- a/backend/server/init.go+++ b/backend/server/init.go@@ -78,7 +78,7 @@ func (s *Server) getInitSetting(ctx context.Context) (string, time.Duration, err// Init password validationpasswordSettingValue, err := protojson.Marshal(&storepb.PasswordRestrictionSetting{MinLength: 8,- RequireNumber: true,+ RequireNumber: false,RequireLetter: true,RequireUppercaseLetter: false,RequireSpecialCharacter: false,@@ -254,11 +254,20 @@ func (s *Server) getInitSetting(ctx context.Context) (string, time.Duration, err}tokenDuration := auth.DefaultTokenDuration- if passwordRestriction.PasswordRotation != nil && passwordRestriction.PasswordRotation.GetSeconds() > 0 {- tokenDuration = passwordRestriction.PasswordRotation.AsDuration()- } else if workspaceProfile.TokenDuration != nil && workspaceProfile.TokenDuration.Seconds > 0 {+ if workspaceProfile.TokenDuration != nil && workspaceProfile.TokenDuration.GetSeconds() > 0 {tokenDuration = workspaceProfile.TokenDuration.AsDuration()}+ // Currently we implement the password rotation restriction in a simple way:+ // 1. Only check if users need to reset their password during login.+ // 2. For the 1st time login, if `RequireResetPasswordForFirstLogin` is true, `require_reset_password` in the response will be true+ // 3. Otherwise if the `PasswordRotation` exists, check the password last updated time to decide if the `require_reset_password` is true.+ // So we will use the minimum value between (`workspaceProfile.TokenDuration`, `passwordRestriction.PasswordRotation`) to force to expire the token.+ if passwordRestriction.PasswordRotation != nil && passwordRestriction.PasswordRotation.GetSeconds() > 0 {+ passwordRotation := passwordRestriction.PasswordRotation.AsDuration()+ if passwordRotation.Seconds() < tokenDuration.Seconds() {+ tokenDuration = passwordRotation+ }+ }return secret, tokenDuration, nil}diff --git a/frontend/src/components/GeneralSetting/PasswordRestrictionSetting.vue b/frontend/src/components/GeneralSetting/PasswordRestrictionSetting.vueindex 3c6192b62b..44a027901b 100644--- a/frontend/src/components/GeneralSetting/PasswordRestrictionSetting.vue+++ b/frontend/src/components/GeneralSetting/PasswordRestrictionSetting.vue@@ -4,6 +4,7 @@<span class="mr-2">{{ $t("settings.general.workspace.password-restriction.self") }}</span>+ <FeatureBadge feature="bb.feature.password-restriction" /></p><div class="w-full flex flex-col space-y-3"><div class="flex items-center space-x-2">@@ -162,16 +163,23 @@</NCheckbox></div></div>++ <FeatureModal+ feature="bb.feature.password-restriction"+ :open="showFeatureModal"+ @cancel="showFeatureModal = false"+ /></template><script setup lang="tsx">import { NInputNumber, NCheckbox } from "naive-ui";-import { computed } from "vue";+import { computed, ref } from "vue";import { useI18n } from "vue-i18n";-import { pushNotification } from "@/store";+import { featureToRef, pushNotification } from "@/store";import { useSettingV1Store } from "@/store/modules/v1/setting";import { Duration } from "@/types/proto/google/protobuf/duration";import { PasswordRestrictionSetting } from "@/types/proto/v1/setting_service";+import { FeatureBadge, FeatureModal } from "../FeatureGuard";const DEFAULT_MIN_LENGTH = 8;@@ -181,6 +189,8 @@ defineProps<{const { t } = useI18n();const settingV1Store = useSettingV1Store();+const showFeatureModal = ref<boolean>(false);+const hasPasswordFeature = featureToRef("bb.feature.password-restriction");const passwordRestrictionSetting = computed(() =>@@ -189,6 +199,10 @@ const passwordRestrictionSetting = computed();const onUpdate = async (update: Partial<PasswordRestrictionSetting>) => {+ if (!hasPasswordFeature.value) {+ showFeatureModal.value = true;+ return;+ }await settingV1Store.upsertSetting({name: "bb.workspace.password-restriction",value: {diff --git a/frontend/src/components/GeneralSetting/SignInFrequencySetting.vue b/frontend/src/components/GeneralSetting/SignInFrequencySetting.vueindex 89f211168f..ba2230835f 100644--- a/frontend/src/components/GeneralSetting/SignInFrequencySetting.vue+++ b/frontend/src/components/GeneralSetting/SignInFrequencySetting.vue@@ -42,9 +42,9 @@</div><FeatureModal- :open="!!state.featureNameForModal"- :feature="state.featureNameForModal"- @cancel="state.featureNameForModal = undefined"+ feature="bb.feature.secure-token"+ :open="state.showFeatureModal"+ @cancel="state.showFeatureModal = false"/></template>@@ -55,7 +55,6 @@ import { computed, reactive, watch } from "vue";import { useI18n } from "vue-i18n";import { featureToRef, pushNotification } from "@/store";import { useSettingV1Store } from "@/store/modules/v1/setting";-import type { FeatureType } from "@/types";import { defaultTokenDurationInHours } from "@/types";import { Duration } from "@/types/proto/google/protobuf/duration";import { FeatureBadge, FeatureModal } from "../FeatureGuard";@@ -64,6 +63,7 @@ const getInitialState = (): LocalState => {const defaultState: LocalState = {inputValue: defaultTokenDurationInHours / 24,timeFormat: "DAYS",+ showFeatureModal: false,};const seconds =settingV1Store.workspaceProfileSetting?.tokenDuration?.seconds?.toNumber();@@ -82,7 +82,7 @@ const getInitialState = (): LocalState => {interface LocalState {inputValue: number;timeFormat: "HOURS" | "DAYS";- featureNameForModal?: FeatureType;+ showFeatureModal: boolean;}const props = defineProps<{@@ -101,7 +101,7 @@ const allowChangeSetting = computed(() => {const handleValueFieldClick = () => {if (!hasSecureTokenFeature.value) {- state.featureNameForModal = "bb.feature.secure-token";+ state.showFeatureModal = true;return;}};@@ -137,7 +137,7 @@ watch(() => [state.inputValue, state.timeFormat],() => {if (!hasSecureTokenFeature.value) {- state.featureNameForModal = "bb.feature.secure-token";+ state.showFeatureModal = true;return;}diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.jsonindex 96bcaa22b2..cfee3da078 100644--- a/frontend/src/locales/en-US.json+++ b/frontend/src/locales/en-US.json@@ -2885,6 +2885,10 @@"bb-feature-issue-advanced-search": {"title": "Advanced issue search","desc": "Access unlimited issue history with advanced issue search."+ },+ "bb-feature-password-restriction": {+ "title": "Password restriction",+ "desc": "Allow to configure the restriction for users' password"}}},diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.jsonindex 90524ab7fb..c0b7479461 100644--- a/frontend/src/locales/es-ES.json+++ b/frontend/src/locales/es-ES.json@@ -2885,6 +2885,10 @@"bb-feature-issue-advanced-search": {"title": "Búsqueda avanzada de problemas","desc": "Acceda a un historial de problemas ilimitado con búsqueda avanzada de problemas."+ },+ "bb-feature-password-restriction": {+ "title": "Restricción de contraseña",+ "desc": "Permitir configurar la restricción de contraseña de los usuarios"}}},diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.jsonindex 627127958c..a12aefe4f7 100644--- a/frontend/src/locales/ja-JP.json+++ b/frontend/src/locales/ja-JP.json@@ -2885,6 +2885,10 @@"bb-feature-issue-advanced-search": {"title": "チケットの詳細検索","desc": "高度な検索機能を使用して、無制限の過去のチケットにアクセスできます。"+ },+ "bb-feature-password-restriction": {+ "title": "パスワード制限",+ "desc": "ユーザーのパスワードの制限を設定できるようにする"}}},diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.jsonindex 449ecae178..1410b45265 100644--- a/frontend/src/locales/zh-CN.json+++ b/frontend/src/locales/zh-CN.json@@ -2885,6 +2885,10 @@"bb-feature-issue-advanced-search": {"title": "工单高级搜索","desc": "通过高级搜索来访问无限制的历史工单。"+ },+ "bb-feature-password-restriction": {+ "title": "密码限制",+ "desc": "允许配置用户密码的规则"}}},diff --git a/frontend/src/types/plan.ts b/frontend/src/types/plan.tsindex 8aa07936b0..91a258c925 100644--- a/frontend/src/types/plan.ts+++ b/frontend/src/types/plan.ts@@ -13,6 +13,7 @@ export type FeatureType =| "bb.feature.sso"| "bb.feature.2fa"| "bb.feature.secure-token"+ | "bb.feature.password-restriction"| "bb.feature.rbac"| "bb.feature.disallow-signup"| "bb.feature.disallow-password-signin"