Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
fix: user filter and email validation (#19130)
ecmadaoc1185082513b
diff --git a/backend/api/mcp/gen/openapi.yaml b/backend/api/mcp/gen/openapi.yamlindex b8ef881c0f..5374cf6d38 100644--- a/backend/api/mcp/gen/openapi.yaml+++ b/backend/api/mcp/gen/openapi.yaml@@ -12564,7 +12564,7 @@ components:Supported filter:- name: the user name, support "==" and ".matches()" operator.- email: the user email, support "==" and ".matches()" operator.- - user_type: the type, check UserType enum for values, support "==", "in [xx]", "!(in [xx])" operator.+ - user_type: the type, check UserType enum for values, support "SYSTEM_BOT" or "USER" value, support "==" and "in [xx]" operator.- state: check State enum for values, support "==" operator.- project: the project full name in "projects/{id}" format, support "==" operator.@@ -12573,9 +12573,8 @@ components:name.matches("ed")email == "[email protected]"email.matches("ed")- user_type == "SERVICE_ACCOUNT"- user_type in ["SERVICE_ACCOUNT", "USER"]- !(user_type in ["SERVICE_ACCOUNT", "USER"])+ user_type == "USER"+ user_type in ["SYSTEM_BOT", "USER"]state == "DELETED"project == "projects/sample-project"You can combine filter conditions like:diff --git a/backend/api/v1/user_service.go b/backend/api/v1/user_service.goindex 706da9e53f..ef5c75e717 100644--- a/backend/api/v1/user_service.go+++ b/backend/api/v1/user_service.go@@ -55,6 +55,9 @@ func (s *UserService) GetUser(ctx context.Context, request *connect.Request[v1pbif err != nil {return nil, connect.NewError(connect.CodeInvalidArgument, err)}+ if err := validateEndUserEmail(email); err != nil {+ return nil, err+ }// Special case for SYSTEM_BOT user which is a built-in resource.// SYSTEM_BOT is stored in principal table with type='SYSTEM_BOT', but GetEndUserByEmail@@ -119,21 +122,19 @@ func (s *UserService) ListUsers(ctx context.Context, request *connect.Request[v1}limitPlusOne := offset.limit + 1- endUserType := storepb.PrincipalType_END_USERfind := &store.FindUserMessage{Limit: &limitPlusOne,Offset: &offset.offset,ShowDeleted: request.Msg.ShowDeleted,- Type: &endUserType,}filterResult, err := store.GetListUserFilter(request.Msg.Filter)if err != nil {return nil, connect.NewError(connect.CodeInvalidArgument, err)}- if filterResult != nil {- find.FilterQ = filterResult.Query- find.ProjectID = filterResult.ProjectID- }+ find.FilterQ = filterResult.Query+ find.ProjectID = filterResult.ProjectID+ find.UserTypes = &filterResult.UserTypes+if v := find.ProjectID; v != nil {user, ok := GetUserFromContext(ctx)if !ok {@@ -342,6 +343,9 @@ func (s *UserService) UpdateUser(ctx context.Context, request *connect.Request[vif err != nil {return nil, connect.NewError(connect.CodeInvalidArgument, err)}+ if err := validateEndUserEmail(email); err != nil {+ return nil, err+ }user, err := s.store.GetEndUserByEmail(ctx, email)if err != nil {return nil, connect.NewError(connect.CodeInternal, errors.Wrapf(err, "failed to get user"))@@ -531,6 +535,9 @@ func (s *UserService) DeleteUser(ctx context.Context, request *connect.Request[vif err != nil {return nil, connect.NewError(connect.CodeInvalidArgument, err)}+ if err := validateEndUserEmail(email); err != nil {+ return nil, err+ }user, err := s.store.GetEndUserByEmail(ctx, email)if err != nil {return nil, connect.NewError(connect.CodeInternal, errors.Wrapf(err, "failed to get user"))@@ -624,6 +631,9 @@ func (s *UserService) UndeleteUser(ctx context.Context, request *connect.Requestif err != nil {return nil, connect.NewError(connect.CodeInvalidArgument, err)}+ if err := validateEndUserEmail(email); err != nil {+ return nil, err+ }user, err := s.store.GetEndUserByEmail(ctx, email)if err != nil {return nil, connect.NewError(connect.CodeInternal, errors.Wrapf(err, "failed to get user"))@@ -773,7 +783,20 @@ func convertToPrincipalType(userType v1pb.UserType) (storepb.PrincipalType, erroreturn t, nil}+func validateEndUserEmail(email string) error {+ if common.IsServiceAccountEmail(email) {+ return connect.NewError(connect.CodeInvalidArgument, errors.Errorf("email for end users cannot end with %v", common.ServiceAccountSuffix))+ }+ if common.IsWorkloadIdentityEmail(email) {+ return connect.NewError(connect.CodeInvalidArgument, errors.Errorf("email for end users cannot end with %v", common.WorkloadIdentitySuffix))+ }+ return nil+}+func validateEmailWithDomains(ctx context.Context, licenseService *enterprise.LicenseService, stores *store.Store, email string, checkDomainSetting bool) error {+ if err := validateEndUserEmail(email); err != nil {+ return err+ }if licenseService.IsFeatureEnabled(v1pb.PlanFeature_FEATURE_USER_EMAIL_DOMAIN_RESTRICTION) != nil {// nolint:nilerr// feature not enabled, only validate email and skip domain restriction.diff --git a/backend/generated-go/v1/user_service.pb.go b/backend/generated-go/v1/user_service.pb.goindex fc8818763b..dc00461bcd 100644--- a/backend/generated-go/v1/user_service.pb.go+++ b/backend/generated-go/v1/user_service.pb.go@@ -294,7 +294,7 @@ type ListUsersRequest struct {// Supported filter:// - name: the user name, support "==" and ".matches()" operator.// - email: the user email, support "==" and ".matches()" operator.- // - user_type: the type, check UserType enum for values, support "==", "in [xx]", "!(in [xx])" operator.+ // - user_type: the type, check UserType enum for values, support "SYSTEM_BOT" or "USER" value, support "==" and "in [xx]" operator.// - state: check State enum for values, support "==" operator.// - project: the project full name in "projects/{id}" format, support "==" operator.//@@ -303,9 +303,8 @@ type ListUsersRequest struct {// name.matches("ed")// email == "[email protected]"// email.matches("ed")- // user_type == "SERVICE_ACCOUNT"- // user_type in ["SERVICE_ACCOUNT", "USER"]- // !(user_type in ["SERVICE_ACCOUNT", "USER"])+ // user_type == "USER"+ // user_type in ["SYSTEM_BOT", "USER"]// state == "DELETED"// project == "projects/sample-project"// You can combine filter conditions like:diff --git a/backend/store/principal.go b/backend/store/principal.goindex bdc0f9a0e7..1242d8d01d 100644--- a/backend/store/principal.go+++ b/backend/store/principal.go@@ -29,11 +29,11 @@ type FindUserMessage struct {ID *intEmail *stringShowDeleted bool- Type *storepb.PrincipalTypeLimit *intOffset *intFilterQ *qb.QueryProjectID *string+ UserTypes *[]storepb.PrincipalType}// UpdateUserMessage is the message to update a user.@@ -279,8 +279,12 @@ func listUserImpl(ctx context.Context, txn *sql.Tx, find *FindUserMessage) ([]*Uwhere.And("principal.email = ?", strings.ToLower(*v))}}- if v := find.Type; v != nil {- where.And("principal.type = ?", v.String())+ if v := find.UserTypes; v != nil {+ typeStrings := make([]string, 0, len(*v))+ for _, t := range *v {+ typeStrings = append(typeStrings, t.String())+ }+ where.And("principal.type = ANY(?)", typeStrings)}if !find.ShowDeleted {where.And("principal.deleted = ?", false)diff --git a/backend/store/principal_end_user.go b/backend/store/principal_end_user.goindex a56a34bfaf..1f4ac64fdc 100644--- a/backend/store/principal_end_user.go+++ b/backend/store/principal_end_user.go@@ -32,7 +32,7 @@ func (s *Store) GetEndUserByEmail(ctx context.Context, email string) (*UserMessareturn nil, nil}- users, err := s.ListEndUsers(ctx, &FindEndUserMessage{Email: &email, ShowDeleted: true})+ users, err := s.listEndUsers(ctx, &FindEndUserMessage{Email: &email, ShowDeleted: true})if err != nil {return nil, err}@@ -42,18 +42,20 @@ func (s *Store) GetEndUserByEmail(ctx context.Context, email string) (*UserMessareturn users[0], nil}-// ListEndUsers lists end users.-func (s *Store) ListEndUsers(ctx context.Context, find *FindEndUserMessage) ([]*UserMessage, error) {- endUserType := storepb.PrincipalType_END_USER+// listEndUsers lists end users.+func (s *Store) listEndUsers(ctx context.Context, find *FindEndUserMessage) ([]*UserMessage, error) {+ userTypes := []storepb.PrincipalType{+ storepb.PrincipalType_END_USER,+ }findUser := &FindUserMessage{ID: find.ID,Email: find.Email,ShowDeleted: find.ShowDeleted,- Type: &endUserType,Limit: find.Limit,Offset: find.Offset,FilterQ: find.FilterQ,ProjectID: find.ProjectID,+ UserTypes: &userTypes,}return s.ListUsers(ctx, findUser)}diff --git a/backend/store/principal_filter.go b/backend/store/principal_filter.goindex ce7d72515a..ef76f49c5b 100644--- a/backend/store/principal_filter.go+++ b/backend/store/principal_filter.go@@ -19,12 +19,18 @@ import (type GetListUserFilterResult struct {Query *qb.QueryProjectID *string+ UserTypes []storepb.PrincipalType}// GetListUserFilter parses a CEL filter string and returns a query for filtering users.func GetListUserFilter(filter string) (*GetListUserFilterResult, error) {if filter == "" {- return nil, nil+ return &GetListUserFilterResult{+ UserTypes: []storepb.PrincipalType{+ storepb.PrincipalType_END_USER,+ storepb.PrincipalType_SYSTEM_BOT,+ },+ }, nil}e, err := cel.NewEnv()@@ -38,6 +44,7 @@ func GetListUserFilter(filter string) (*GetListUserFilterResult, error) {var getFilter func(expr celast.Expr) (*qb.Query, error)var projectID *string+ userTypes := []storepb.PrincipalType{}convertToPrincipalType := func(v1UserType v1pb.UserType) (storepb.PrincipalType, error) {switch v1UserType {@@ -45,10 +52,6 @@ func GetListUserFilter(filter string) (*GetListUserFilterResult, error) {return storepb.PrincipalType_END_USER, nilcase v1pb.UserType_SYSTEM_BOT:return storepb.PrincipalType_SYSTEM_BOT, nil- case v1pb.UserType_SERVICE_ACCOUNT:- return storepb.PrincipalType_SERVICE_ACCOUNT, nil- case v1pb.UserType_WORKLOAD_IDENTITY:- return storepb.PrincipalType_WORKLOAD_IDENTITY, nildefault:return storepb.PrincipalType_END_USER, errors.Errorf("invalid user type %s", v1UserType)}@@ -69,7 +72,8 @@ func GetListUserFilter(filter string) (*GetListUserFilterResult, error) {if err != nil {return nil, errors.Errorf("failed to parse the user type %q with error: %v", v1UserType, err)}- return qb.Q().Space("principal.type = ?", principalType.String()), nil+ userTypes = append(userTypes, principalType)+ return qb.Q().Space("TRUE"), nilcase "state":stateStr, ok := value.(string)if !ok {@@ -114,7 +118,6 @@ func GetListUserFilter(filter string) (*GetListUserFilterResult, error) {return nil, errors.Errorf("empty user_type filter")}- userTypeList := make([]any, 0, len(rawTypeList))for _, rawType := range rawTypeList {v1UserType, ok := v1pb.UserType_value[rawType.(string)]if !ok {@@ -124,10 +127,10 @@ func GetListUserFilter(filter string) (*GetListUserFilterResult, error) {if err != nil {return nil, errors.Errorf("failed to parse the user type %q with error: %v", v1UserType, err)}- userTypeList = append(userTypeList, principalType.String())+ userTypes = append(userTypes, principalType)}- return qb.Q().Space("principal.type = ANY(?)", userTypeList), nil+ return qb.Q().Space("TRUE"), nil}getFilter = func(expr celast.Expr) (*qb.Query, error) {@@ -174,16 +177,6 @@ func GetListUserFilter(filter string) (*GetListUserFilterResult, error) {return qb.Q().Space("LOWER(principal."+variable+") LIKE ?", "%"+strings.ToLower(strValue)+"%"), nilcase celoperators.In:return parseToUserTypeSQL(expr)- case celoperators.LogicalNot:- args := expr.AsCall().Args()- if len(args) != 1 {- return nil, errors.Errorf(`only support !(user_type in ["{type1}", "{type2}"]) format`)- }- qq, err := getFilter(args[0])- if err != nil {- return nil, err- }- return q.Space("(NOT (?))", qq), nildefault:return nil, errors.Errorf("unexpected function %v", functionName)}@@ -197,8 +190,18 @@ func GetListUserFilter(filter string) (*GetListUserFilterResult, error) {return nil, err}+ if len(userTypes) == 0 {+ // Force to query end users and system bot.+ userTypes = append(+ userTypes,+ storepb.PrincipalType_END_USER,+ storepb.PrincipalType_SYSTEM_BOT,+ )+ }+return &GetListUserFilterResult{Query: qb.Q().Space("(?)", q),ProjectID: projectID,+ UserTypes: userTypes,}, nil}diff --git a/backend/store/principal_filter_test.go b/backend/store/principal_filter_test.goindex 152aa00d77..0bcc7cb4c5 100644--- a/backend/store/principal_filter_test.go+++ b/backend/store/principal_filter_test.go@@ -10,13 +10,14 @@ import (func TestGetListUserFilter(t *testing.T) {tests := []struct {- name string- filter string- wantSQL string- wantArgs []any- wantProject *string- wantErr bool- errContains string+ name string+ filter string+ wantSQL string+ wantArgs []any+ wantProject *string+ wantUserTypes []storepb.PrincipalType+ wantErr bool+ errContains string}{{name: "empty filter",@@ -24,6 +25,10 @@ func TestGetListUserFilter(t *testing.T) {wantSQL: "",wantArgs: nil,wantErr: false,+ wantUserTypes: []storepb.PrincipalType{+ storepb.PrincipalType_END_USER,+ storepb.PrincipalType_SYSTEM_BOT,+ },},{name: "name filter",@@ -54,32 +59,43 @@ func TestGetListUserFilter(t *testing.T) {wantErr: false,},{- name: "user_type filter - SERVICE_ACCOUNT",- filter: `user_type == "SERVICE_ACCOUNT"`,- wantSQL: "(principal.type = $1)",- wantArgs: []any{storepb.PrincipalType_SERVICE_ACCOUNT.String()},- wantErr: false,+ name: "user_type filter - SERVICE_ACCOUNT",+ filter: `user_type == "SERVICE_ACCOUNT"`,+ wantErr: true,+ errContains: "invalid user type SERVICE_ACCOUNT",},{name: "user_type filter - USER",filter: `user_type == "USER"`,- wantSQL: "(principal.type = $1)",- wantArgs: []any{storepb.PrincipalType_END_USER.String()},+ wantSQL: "(TRUE)",+ wantArgs: []any{},wantErr: false,+ wantUserTypes: []storepb.PrincipalType{+ storepb.PrincipalType_END_USER,+ },},{- name: "user_type in list",- filter: `user_type in ["SERVICE_ACCOUNT", "USER"]`,- wantSQL: "(principal.type = ANY($1))",- wantArgs: []any{[]any{storepb.PrincipalType_SERVICE_ACCOUNT.String(), storepb.PrincipalType_END_USER.String()}},+ name: "user_type filter - USER",+ filter: `user_type in ["SYSTEM_BOT", "USER"]`,+ wantSQL: "(TRUE)",+ wantArgs: []any{},wantErr: false,+ wantUserTypes: []storepb.PrincipalType{+ storepb.PrincipalType_SYSTEM_BOT,+ storepb.PrincipalType_END_USER,+ },},{- name: "user_type not in list",- filter: `!(user_type in ["SERVICE_ACCOUNT"])`,- wantSQL: "((NOT (principal.type = ANY($1))))",- wantArgs: []any{[]any{storepb.PrincipalType_SERVICE_ACCOUNT.String()}},- wantErr: false,+ name: "user_type in list",+ filter: `user_type in ["SERVICE_ACCOUNT", "USER"]`,+ wantErr: true,+ errContains: "invalid user type SERVICE_ACCOUNT",+ },+ {+ name: "user_type not in list",+ filter: `!(user_type in ["SERVICE_ACCOUNT"])`,+ wantErr: true,+ errContains: "unexpected function",},{name: "state filter - STATE_ACTIVE",@@ -120,9 +136,12 @@ func TestGetListUserFilter(t *testing.T) {{name: "complex nested condition",filter: `(name == "ed" || name == "alice") && user_type == "USER"`,- wantSQL: "(((principal.name = $1 OR principal.name = $2) AND principal.type = $3))",- wantArgs: []any{"ed", "alice", storepb.PrincipalType_END_USER.String()},+ wantSQL: "(((principal.name = $1 OR principal.name = $2) AND TRUE))",+ wantArgs: []any{"ed", "alice"},wantErr: false,+ wantUserTypes: []storepb.PrincipalType{+ storepb.PrincipalType_END_USER,+ },},{name: "unsupported variable",@@ -163,12 +182,6 @@ func TestGetListUserFilter(t *testing.T) {}require.NoError(t, err)-- if tt.filter == "" {- require.Nil(t, result)- return- }-require.NotNil(t, result)if tt.wantProject != nil {@@ -178,10 +191,16 @@ func TestGetListUserFilter(t *testing.T) {require.Nil(t, result.ProjectID)}- sql, args, err := result.Query.ToSQL()- require.NoError(t, err)- require.Equal(t, tt.wantSQL, sql)- require.Equal(t, tt.wantArgs, args)+ if len(tt.wantUserTypes) > 0 {+ require.Equal(t, tt.wantUserTypes, result.UserTypes)+ }++ if query := result.Query; query != nil {+ sql, args, err := query.ToSQL()+ require.NoError(t, err)+ require.Equal(t, tt.wantSQL, sql)+ require.Equal(t, tt.wantArgs, args)+ }})}}diff --git a/frontend/src/components/Member/MembersBindingSelect.vue b/frontend/src/components/Member/MembersBindingSelect.vueindex 90f9d85f64..053c53b439 100644--- a/frontend/src/components/Member/MembersBindingSelect.vue+++ b/frontend/src/components/Member/MembersBindingSelect.vue@@ -129,6 +129,7 @@ const emit = defineEmits<{(event: "update:value", memberList: string[]): void;}>();+// TODO(ed): we'd probably support "SERVICE_ACCOUNT" and "WORKLOAD_IDENTITY"const initMemberType = computed((): MemberType => {for (const binding of props.value) {if (binding.startsWith(groupBindingPrefix)) {diff --git a/frontend/src/components/User/Settings/CreateUserDrawer.vue b/frontend/src/components/User/Settings/CreateUserDrawer.vueindex 134b5565f0..bcf15ce23c 100644--- a/frontend/src/components/User/Settings/CreateUserDrawer.vue+++ b/frontend/src/components/User/Settings/CreateUserDrawer.vue@@ -59,7 +59,7 @@</label><EmailInputv-model:value="state.user.email"- domain="workload.bytebase.com"+ :domain="workloadIdentitySuffix":show-domain="true":disabled="isEditMode"/>@@ -326,7 +326,7 @@v-model:value="state.user.email":domain="state.user.userType === UserType.SERVICE_ACCOUNT- ? 'service.bytebase.com'+ ? serviceAccountSuffix: ''":show-domain="state.user.userType === UserType.SERVICE_ACCOUNT"@@ -427,7 +427,9 @@ import {getServiceAccountNameInBinding,getUserEmailInBinding,getWorkloadIdentityNameInBinding,+ serviceAccountSuffix,unknownUser,+ workloadIdentitySuffix,} from "@/types";import { PresetRoleType } from "@/types/iam";import type { User } from "@/types/proto-es/v1/user_service_pb";diff --git a/frontend/src/components/v2/Model/cells/UserLink.vue b/frontend/src/components/v2/Model/cells/UserLink.vueindex 42e58b89ec..1abc852d1f 100644--- a/frontend/src/components/v2/Model/cells/UserLink.vue+++ b/frontend/src/components/v2/Model/cells/UserLink.vue@@ -2,7 +2,12 @@<component:is="isLink ? 'router-link' : 'div'":class="isLink && 'normal-link'"- :to="`/users/${email}`"+ :to="{+ name: WORKSPACE_ROUTE_USER_PROFILE,+ params: {+ principalEmail: email,+ },+ }"><HighlightLabelText:keyword="keyword ?? ''"@@ -14,6 +19,9 @@<script lang="tsx" setup>import { computed } from "vue";import { HighlightLabelText } from "@/components/v2";+import { WORKSPACE_ROUTE_USER_PROFILE } from "@/router/dashboard/workspaceRoutes";+import { getUserTypeByEmail } from "@/types";+import { UserType } from "@/types/proto-es/v1/user_service_pb";import { hasWorkspacePermissionV2 } from "@/utils";const props = withDefaults(@@ -28,7 +36,12 @@ const props = withDefaults(});+const isEndUser = computed(+ () => getUserTypeByEmail(props.email) === UserType.USER+);+const isLink = computed(- () => props.link && hasWorkspacePermissionV2("bb.users.get")+ () =>+ props.link && isEndUser.value && hasWorkspacePermissionV2("bb.users.get"));</script>\ No newline at end of filediff --git a/frontend/src/components/v2/Select/UserSelect.vue b/frontend/src/components/v2/Select/UserSelect.vueindex 08d62a9d69..689554613f 100644--- a/frontend/src/components/v2/Select/UserSelect.vue+++ b/frontend/src/components/v2/Select/UserSelect.vue@@ -22,9 +22,9 @@ import { computed } from "vue";import { HighlightLabelText } from "@/components/v2";import { UserNameCell } from "@/components/v2/Model/cells";import {+ batchGetOrFetchAccounts,getUserFullNameByType,type UserFilter,- userNamePrefix,useUserStore,} from "@/store";import { allUsersUser } from "@/types";@@ -106,9 +106,7 @@ const additionalOptions = computedAsync(async () => {}// Ensure users are fetched into store- await userStore.batchGetOrFetchUsers(- userEmails.map((email) => `${userNamePrefix}${email}`)- );+ await batchGetOrFetchAccounts(userEmails);// Get all users from storefor (const email of userEmails) {diff --git a/frontend/src/store/modules/account.ts b/frontend/src/store/modules/account.tsnew file mode 100644index 0000000000..88a3e706fa--- /dev/null+++ b/frontend/src/store/modules/account.ts@@ -0,0 +1,36 @@+import { getUserTypeByEmail } from "@/types";+import { UserType } from "@/types/proto-es/v1/user_service_pb";+import { useServiceAccountStore } from "./serviceAccount";+import { useUserStore } from "./user";+import { useWorkloadIdentityStore } from "./workloadIdentity";++export const batchGetOrFetchAccounts = async (nameList: string[]) => {+ const userStore = useUserStore();+ const serviceAccountStore = useServiceAccountStore();+ const workloadIdentityStore = useWorkloadIdentityStore();++ const endUsers: string[] = [];+ const serviceAccounts: string[] = [];+ const workloadIdentities: string[] = [];++ for (const name of nameList) {+ const userType = getUserTypeByEmail(name);+ switch (userType) {+ case UserType.SERVICE_ACCOUNT:+ serviceAccounts.push(name);+ break;+ case UserType.WORKLOAD_IDENTITY:+ workloadIdentities.push(name);+ break;+ default:+ endUsers.push(name);+ break;+ }+ }++ await Promise.all([+ userStore.batchGetOrFetchUsers(endUsers),+ serviceAccountStore.batchGetOrFetchServiceAccounts(serviceAccounts),+ workloadIdentityStore.batchGetOrFetchWorkloadIdentities(workloadIdentities),+ ]);+};diff --git a/frontend/src/store/modules/index.ts b/frontend/src/store/modules/index.tsindex 588d1875f0..118cd8d8ac 100644--- a/frontend/src/store/modules/index.ts+++ b/frontend/src/store/modules/index.ts@@ -7,6 +7,7 @@ export * from "./uistate";export * from "./sqlReview";export * from "./idp";export * from "./user";+export * from "./account";export * from "./serviceAccount";export * from "./workloadIdentity";export * from "./workspaceApprovalSetting";diff --git a/frontend/src/store/modules/serviceAccount.ts b/frontend/src/store/modules/serviceAccount.tsindex fd138d5249..0e98796962 100644--- a/frontend/src/store/modules/serviceAccount.ts+++ b/frontend/src/store/modules/serviceAccount.ts@@ -1,9 +1,11 @@import { create } from "@bufbuild/protobuf";import { createContextValues } from "@connectrpc/connect";+import { uniq } from "lodash-es";import { defineStore } from "pinia";import { ref } from "vue";import { serviceAccountServiceClientConnect } from "@/connect";import { silentContextKey } from "@/connect/context-key";+import { serviceAccountBindingPrefix } from "@/types";import { State } from "@/types/proto-es/v1/common_pb";import type { ServiceAccount } from "@/types/proto-es/v1/service_account_service_pb";import {@@ -21,6 +23,12 @@ import {UserType,} from "@/types/proto-es/v1/user_service_pb";import { useActuatorV1Store } from "./v1/actuator";+import { extractServiceAccountId, serviceAccountNamePrefix } from "./v1/common";++const ensureServiceAccountFullName = (identifier: string) => {+ const id = extractServiceAccountId(identifier);+ return `${serviceAccountNamePrefix}${id}`;+};export const useServiceAccountStore = defineStore("serviceAccount", () => {const actuatorStore = useActuatorV1Store();@@ -49,7 +57,7 @@ export const useServiceAccountStore = defineStore("serviceAccount", () => {};const getServiceAccount = (name: string) => {- return cacheByName.value.get(name);+ return cacheByName.value.get(ensureServiceAccountFullName(name));};const getOrFetchServiceAccount = async (name: string, silent = false) => {@@ -62,6 +70,29 @@ export const useServiceAccountStore = defineStore("serviceAccount", () => {return sa;};+ // TODO(ed): support batch get+ const batchGetOrFetchServiceAccounts = async (nameList: string[]) => {+ const validList = uniq(nameList).filter(+ (name) =>+ Boolean(name) &&+ (name.startsWith(serviceAccountNamePrefix) ||+ name.startsWith(serviceAccountBindingPrefix))+ );+ try {+ const pendingFetch = validList+ .filter((name) => {+ return getServiceAccount(name) === undefined;+ })+ .map((name) => ensureServiceAccountFullName(name));++ await Promise.all(+ pendingFetch.map((name) => {+ return getOrFetchServiceAccount(name);+ })+ );+ } catch {}+ };+const createServiceAccount = async (serviceAccountId: string,serviceAccount: Partial<ServiceAccount>@@ -76,7 +107,13 @@ export const useServiceAccountStore = defineStore("serviceAccount", () => {const sa =await serviceAccountServiceClientConnect.createServiceAccount(request);cacheByName.value.set(sa.name, sa);- await actuatorStore.fetchServerInfo();+ actuatorStore.updateUserStat([+ {+ count: 1,+ state: State.ACTIVE,+ userType: UserType.SERVICE_ACCOUNT,+ },+ ]);return sa;};@@ -106,7 +143,18 @@ export const useServiceAccountStore = defineStore("serviceAccount", () => {if (sa) {sa.state = State.DELETED;}- await actuatorStore.fetchServerInfo();+ actuatorStore.updateUserStat([+ {+ count: -1,+ state: State.ACTIVE,+ userType: UserType.SERVICE_ACCOUNT,+ },+ {+ count: 1,+ state: State.DELETED,+ userType: UserType.SERVICE_ACCOUNT,+ },+ ]);};const undeleteServiceAccount = async (name: string) => {@@ -116,7 +164,18 @@ export const useServiceAccountStore = defineStore("serviceAccount", () => {const sa =await serviceAccountServiceClientConnect.undeleteServiceAccount(request);cacheByName.value.set(sa.name, sa);- await actuatorStore.fetchServerInfo();+ actuatorStore.updateUserStat([+ {+ count: 1,+ state: State.ACTIVE,+ userType: UserType.SERVICE_ACCOUNT,+ },+ {+ count: -1,+ state: State.DELETED,+ userType: UserType.SERVICE_ACCOUNT,+ },+ ]);return sa;};@@ -124,6 +183,7 @@ export const useServiceAccountStore = defineStore("serviceAccount", () => {listServiceAccounts,getServiceAccount,getOrFetchServiceAccount,+ batchGetOrFetchServiceAccounts,createServiceAccount,updateServiceAccount,deleteServiceAccount,diff --git a/frontend/src/store/modules/user.ts b/frontend/src/store/modules/user.tsindex c97bb468bf..5ce103ce7c 100644--- a/frontend/src/store/modules/user.ts+++ b/frontend/src/store/modules/user.ts@@ -227,7 +227,13 @@ export const useUserStore = defineStore("user", () => {user: user,});const response = await userServiceClientConnect.createUser(request);- await actuatorStore.fetchServerInfo();+ actuatorStore.updateUserStat([+ {+ count: 1,+ state: State.ACTIVE,+ userType: UserType.USER,+ },+ ]);return setUser(response);};@@ -267,7 +273,18 @@ export const useUserStore = defineStore("user", () => {name,});await userServiceClientConnect.deleteUser(request);- await actuatorStore.fetchServerInfo();+ actuatorStore.updateUserStat([+ {+ count: -1,+ state: State.ACTIVE,+ userType: UserType.USER,+ },+ {+ count: 1,+ state: State.DELETED,+ userType: UserType.USER,+ },+ ]);const user = userMapByName.value.get(name);if (user) {@@ -280,7 +297,18 @@ export const useUserStore = defineStore("user", () => {name,});const response = await userServiceClientConnect.undeleteUser(request);- await actuatorStore.fetchServerInfo();+ actuatorStore.updateUserStat([+ {+ count: 1,+ state: State.ACTIVE,+ userType: UserType.USER,+ },+ {+ count: -1,+ state: State.DELETED,+ userType: UserType.USER,+ },+ ]);return setUser(response);};@@ -302,80 +330,18 @@ export const useUserStore = defineStore("user", () => {);}- const regularUsers: string[] = [];- const serviceAccountEmails: string[] = [];- const workloadIdentityEmails: string[] = [];-- for (const name of pendingFetch) {- const email = extractUserId(name);- if (- email.endsWith("@service.bytebase.com") ||- email.includes(".service.bytebase.com")- ) {- serviceAccountEmails.push(email);- } else if (- email.endsWith("@workload.bytebase.com") ||- email.includes(".workload.bytebase.com")- ) {- workloadIdentityEmails.push(email);- } else {- regularUsers.push(name);- }- }-try {- const promises: Promise<void>[] = [];-- if (regularUsers.length > 0) {- const userPromise = (async () => {- const request = create(BatchGetUsersRequestSchema, {- names: regularUsers,- });- const response = await userServiceClientConnect.batchGetUsers(- request,- {- contextValues: createContextValues().set(silentContextKey, true),- }- );- for (const user of response.users) {- setUser(user);- }- })();- promises.push(userPromise);- }-- for (const email of serviceAccountEmails) {- const saPromise = (async () => {- try {- const response = await serviceAccountStore.getOrFetchServiceAccount(- `${serviceAccountNamePrefix}${email}`,- true- );- setUser(serviceAccountToUser(response));- } catch {- // Ignore errors for individual fetches- }- })();- promises.push(saPromise);- }-- for (const email of workloadIdentityEmails) {- const wiPromise = (async () => {- try {- const response =- await workloadIdentityStore.getOrFetchWorkloadIdentity(- `${workloadIdentityNamePrefix}${email}`,- true- );- setUser(workloadIdentityToUser(response));- } catch {- // Ignore errors for individual fetches- }- })();- promises.push(wiPromise);+ if (pendingFetch.length > 0) {+ const request = create(BatchGetUsersRequestSchema, {+ names: pendingFetch,+ });+ const response = await userServiceClientConnect.batchGetUsers(request, {+ contextValues: createContextValues().set(silentContextKey, true),+ });+ for (const user of response.users) {+ setUser(user);+ }}-- await Promise.all(promises);} finally {return validList.map((name) => getUserByIdentifier(name) ?? unknownUser(name)diff --git a/frontend/src/store/modules/v1/actuator.ts b/frontend/src/store/modules/v1/actuator.tsindex 3239492a71..885fe7ea7f 100644--- a/frontend/src/store/modules/v1/actuator.ts+++ b/frontend/src/store/modules/v1/actuator.ts@@ -109,91 +109,37 @@ export const useActuatorV1Store = defineStore("actuator_v1", () => {const replicaCount = computed(() => serverInfo.value?.replicaCount ?? 1);- const inactiveUserCount = computed(() => {- return (serverInfo.value?.userStats ?? []).reduce((count, stat) => {- if (- stat.state === State.DELETED &&- stat.userType !== UserType.SERVICE_ACCOUNT &&- stat.userType !== UserType.WORKLOAD_IDENTITY- ) {- count += stat.count;- }- return count;- }, 0);- });-- const serviceAccountCount = computed(() => {- return (serverInfo.value?.userStats ?? []).reduce((count, stat) => {- if (- stat.state === State.ACTIVE &&- stat.userType === UserType.SERVICE_ACCOUNT- ) {- count += stat.count;- }- return count;- }, 0);- });-- const workloadIdentityCount = computed(() => {- return (serverInfo.value?.userStats ?? []).reduce((count, stat) => {- if (- stat.state === State.ACTIVE &&- stat.userType === UserType.WORKLOAD_IDENTITY- ) {- count += stat.count;- }- return count;- }, 0);- });-- const inactiveServiceAccountCount = computed(() => {- return (serverInfo.value?.userStats ?? []).reduce((count, stat) => {- if (- stat.state === State.DELETED &&- stat.userType === UserType.SERVICE_ACCOUNT- ) {- count += stat.count;- }- return count;- }, 0);- });-- const inactiveWorkloadIdentityCount = computed(() => {+ const countUser = ({+ state,+ userTypes,+ }: {+ state: State;+ userTypes: UserType[];+ }): number => {return (serverInfo.value?.userStats ?? []).reduce((count, stat) => {- if (- stat.state === State.DELETED &&- stat.userType === UserType.WORKLOAD_IDENTITY- ) {+ if (stat.state === state && userTypes.includes(stat.userType)) {count += stat.count;}return count;}, 0);- });+ };- // Actions- const getActiveUserCount = ({- includeBot,- includeServiceAccount,- }: {- includeBot: boolean;- includeServiceAccount: boolean;- }) => {- return (serverInfo.value?.userStats ?? []).reduce((count, stat) => {- if (stat.state !== State.ACTIVE) {- return count;- }- if (!includeBot && stat.userType === UserType.SYSTEM_BOT) {- return count;- }- if (- !includeServiceAccount &&- stat.userType === UserType.SERVICE_ACCOUNT- ) {- return count;+ const updateUserStat = (+ updates: {+ count: number;+ state: State;+ userType: UserType;+ }[]+ ) => {+ for (const update of updates) {+ const item = (serverInfo.value?.userStats ?? []).find(+ (stat) =>+ stat.state === update.state && stat.userType === update.userType+ );+ if (item) {+ item.count += update.count;}- count += stat.count;- return count;- }, 0);+ }};const quickStartEnabled = computed(() => {@@ -206,9 +152,9 @@ export const useActuatorV1Store = defineStore("actuator_v1", () => {// Hide quickstart if there are more than 1 active users.return (- getActiveUserCount({- includeBot: false,- includeServiceAccount: false,+ countUser({+ state: State.ACTIVE,+ userTypes: [UserType.USER],}) <= 1);});@@ -326,14 +272,10 @@ export const useActuatorV1Store = defineStore("actuator_v1", () => {activatedInstanceCount,totalInstanceCount,replicaCount,- inactiveUserCount,- serviceAccountCount,- workloadIdentityCount,- inactiveServiceAccountCount,- inactiveWorkloadIdentityCount,quickStartEnabled,// Actions- getActiveUserCount,+ countUser,+ updateUserStat,setLogo,setServerInfo,fetchServerInfo,diff --git a/frontend/src/store/modules/v1/projectIamPolicy.ts b/frontend/src/store/modules/v1/projectIamPolicy.tsindex 3ea3a35e8d..67b1b57895 100644--- a/frontend/src/store/modules/v1/projectIamPolicy.ts+++ b/frontend/src/store/modules/v1/projectIamPolicy.ts@@ -22,8 +22,8 @@ import type { Project } from "@/types/proto-es/v1/project_service_pb";import type { User } from "@/types/proto-es/v1/user_service_pb";import { getDatabaseProject, getUserListInBinding } from "@/utils";import { convertFromExpr } from "@/utils/issue/cel";+import { batchGetOrFetchAccounts } from "../account";import { useRoleStore } from "../role";-import { useUserStore } from "../user";import { useCurrentUserV1 } from "./auth";import { getUserFullNameByType, userNamePrefix } from "./common";import { useGroupStore } from "./group";@@ -49,7 +49,7 @@ export const composePolicyBindings = async (useGroupStore().batchGetOrFetchGroups(groups),];if (!skipFetchUsers) {- requests.push(useUserStore().batchGetOrFetchUsers(users));+ requests.push(batchGetOrFetchAccounts(users));}await Promise.allSettled(requests);};diff --git a/frontend/src/store/modules/workloadIdentity.ts b/frontend/src/store/modules/workloadIdentity.tsindex 8f387350c8..84609f11c1 100644--- a/frontend/src/store/modules/workloadIdentity.ts+++ b/frontend/src/store/modules/workloadIdentity.ts@@ -1,9 +1,11 @@import { create } from "@bufbuild/protobuf";import { createContextValues } from "@connectrpc/connect";+import { uniq } from "lodash-es";import { defineStore } from "pinia";import { ref } from "vue";import { workloadIdentityServiceClientConnect } from "@/connect";import { silentContextKey } from "@/connect/context-key";+import { workloadIdentityBindingPrefix } from "@/types";import { State } from "@/types/proto-es/v1/common_pb";import {type User,@@ -21,6 +23,15 @@ import {WorkloadIdentitySchema,} from "@/types/proto-es/v1/workload_identity_service_pb";import { useActuatorV1Store } from "./v1/actuator";+import {+ extractWorkloadIdentityId,+ workloadIdentityNamePrefix,+} from "./v1/common";++const ensureWorkloadIdentityFullName = (identifier: string) => {+ const id = extractWorkloadIdentityId(identifier);+ return `${workloadIdentityNamePrefix}${id}`;+};export const useWorkloadIdentityStore = defineStore("workloadIdentity", () => {const actuatorStore = useActuatorV1Store();@@ -49,7 +60,7 @@ export const useWorkloadIdentityStore = defineStore("workloadIdentity", () => {};const getWorkloadIdentity = (name: string) => {- return cacheByName.value.get(name);+ return cacheByName.value.get(ensureWorkloadIdentityFullName(name));};const getOrFetchWorkloadIdentity = async (@@ -65,6 +76,29 @@ export const useWorkloadIdentityStore = defineStore("workloadIdentity", () => {return wi;};+ // TODO(ed): support batch get+ const batchGetOrFetchWorkloadIdentities = async (nameList: string[]) => {+ const validList = uniq(nameList).filter(+ (name) =>+ Boolean(name) &&+ (name.startsWith(workloadIdentityNamePrefix) ||+ name.startsWith(workloadIdentityBindingPrefix))+ );+ try {+ const pendingFetch = validList+ .filter((name) => {+ return getWorkloadIdentity(name) === undefined;+ })+ .map((name) => ensureWorkloadIdentityFullName(name));++ await Promise.all(+ pendingFetch.map((name) => {+ return getOrFetchWorkloadIdentity(name);+ })+ );+ } catch {}+ };+const createWorkloadIdentity = async (workloadIdentityId: string,workloadIdentity: Partial<WorkloadIdentity>@@ -81,7 +115,13 @@ export const useWorkloadIdentityStore = defineStore("workloadIdentity", () => {request);cacheByName.value.set(wi.name, wi);- await actuatorStore.fetchServerInfo();+ actuatorStore.updateUserStat([+ {+ count: 1,+ state: State.ACTIVE,+ userType: UserType.WORKLOAD_IDENTITY,+ },+ ]);return wi;};@@ -113,7 +153,18 @@ export const useWorkloadIdentityStore = defineStore("workloadIdentity", () => {if (wi) {wi.state = State.DELETED;}- await actuatorStore.fetchServerInfo();+ actuatorStore.updateUserStat([+ {+ count: -1,+ state: State.ACTIVE,+ userType: UserType.WORKLOAD_IDENTITY,+ },+ {+ count: 1,+ state: State.DELETED,+ userType: UserType.WORKLOAD_IDENTITY,+ },+ ]);};const undeleteWorkloadIdentity = async (name: string) => {@@ -125,7 +176,18 @@ export const useWorkloadIdentityStore = defineStore("workloadIdentity", () => {request);cacheByName.value.set(wi.name, wi);- await actuatorStore.fetchServerInfo();+ actuatorStore.updateUserStat([+ {+ count: 1,+ state: State.ACTIVE,+ userType: UserType.WORKLOAD_IDENTITY,+ },+ {+ count: -1,+ state: State.DELETED,+ userType: UserType.WORKLOAD_IDENTITY,+ },+ ]);return wi;};@@ -133,6 +195,7 @@ export const useWorkloadIdentityStore = defineStore("workloadIdentity", () => {listWorkloadIdentities,getWorkloadIdentity,getOrFetchWorkloadIdentity,+ batchGetOrFetchWorkloadIdentities,createWorkloadIdentity,updateWorkloadIdentity,deleteWorkloadIdentity,diff --git a/frontend/src/types/proto-es/v1/user_service_pb.d.ts b/frontend/src/types/proto-es/v1/user_service_pb.d.tsindex 2db973e1d3..d7165f8b6b 100644--- a/frontend/src/types/proto-es/v1/user_service_pb.d.ts+++ b/frontend/src/types/proto-es/v1/user_service_pb.d.ts@@ -107,7 +107,7 @@ export declare type ListUsersRequest = Message<"bytebase.v1.ListUsersRequest"> &* Supported filter:* - name: the user name, support "==" and ".matches()" operator.* - email: the user email, support "==" and ".matches()" operator.- * - user_type: the type, check UserType enum for values, support "==", "in [xx]", "!(in [xx])" operator.+ * - user_type: the type, check UserType enum for values, support "SYSTEM_BOT" or "USER" value, support "==" and "in [xx]" operator.* - state: check State enum for values, support "==" operator.* - project: the project full name in "projects/{id}" format, support "==" operator.*@@ -116,9 +116,8 @@ export declare type ListUsersRequest = Message<"bytebase.v1.ListUsersRequest"> &* name.matches("ed")* email == "[email protected]"* email.matches("ed")- * user_type == "SERVICE_ACCOUNT"- * user_type in ["SERVICE_ACCOUNT", "USER"]- * !(user_type in ["SERVICE_ACCOUNT", "USER"])+ * user_type == "USER"+ * user_type in ["SYSTEM_BOT", "USER"]* state == "DELETED"* project == "projects/sample-project"* You can combine filter conditions like:diff --git a/frontend/src/types/v1/user.ts b/frontend/src/types/v1/user.tsindex 7266e475fb..d1966322fa 100644--- a/frontend/src/types/v1/user.ts+++ b/frontend/src/types/v1/user.ts@@ -52,12 +52,14 @@ export const getGroupEmailInBinding = (email: string) => {return `${groupBindingPrefix}${email}`;};+export const serviceAccountSuffix = "service.bytebase.com";export const serviceAccountBindingPrefix = "serviceAccount:";export const getServiceAccountNameInBinding = (email: string) => {return `${serviceAccountBindingPrefix}${email}`;};+export const workloadIdentitySuffix = "workload.bytebase.com";export const workloadIdentityBindingPrefix = "workloadIdentity:";export const getWorkloadIdentityNameInBinding = (name: string) => {@@ -72,3 +74,16 @@ export const isValidUserName = (name: string) => {name !== allUsersUser().name);};++export const getUserTypeByEmail = (email: string): UserType => {+ if (email === SYSTEM_BOT_EMAIL) {+ return UserType.SYSTEM_BOT;+ }+ if (email.endsWith(serviceAccountSuffix)) {+ return UserType.SERVICE_ACCOUNT;+ }+ if (email.endsWith(workloadIdentitySuffix)) {+ return UserType.WORKLOAD_IDENTITY;+ }+ return UserType.USER;+};diff --git a/frontend/src/views/ProfileDashboard.vue b/frontend/src/views/ProfileDashboard.vueindex 37137e490e..5ff202c8c0 100644--- a/frontend/src/views/ProfileDashboard.vue+++ b/frontend/src/views/ProfileDashboard.vue@@ -220,7 +220,15 @@ import { cloneDeep, isEqual } from "lodash-es";import { EllipsisIcon } from "lucide-vue-next";import type { DropdownOption } from "naive-ui";import { NButton, NDropdown, NInput, NTag } from "naive-ui";-import { computed, nextTick, onMounted, onUnmounted, reactive, ref } from "vue";+import {+ computed,+ nextTick,+ onBeforeMount,+ onMounted,+ onUnmounted,+ reactive,+ ref,+} from "vue";import { useI18n } from "vue-i18n";import { useRouter } from "vue-router";import EmailInput from "@/components/EmailInput.vue";@@ -235,7 +243,10 @@ import UserPassword from "@/components/User/Settings/UserPassword.vue";import UserAvatar from "@/components/User/UserAvatar.vue";import { MiniActionButton } from "@/components/v2";import { useRouteChangeGuard } from "@/composables/useRouteChangeGuard";-import { WORKSPACE_ROUTE_USER_PROFILE } from "@/router/dashboard/workspaceRoutes";+import {+ WORKSPACE_ROUTE_404,+ WORKSPACE_ROUTE_USER_PROFILE,+} from "@/router/dashboard/workspaceRoutes";import {SETTING_ROUTE_PROFILE_TWO_FACTOR,SETTING_ROUTE_WORKSPACE_SUBSCRIPTION,@@ -251,6 +262,7 @@ import {} from "@/store";import {ALL_USERS_USER_EMAIL,+ getUserTypeByEmail,SYSTEM_BOT_USER_NAME,unknownUser,} from "@/types";@@ -291,6 +303,17 @@ const state = reactive<LocalState>({showRegenerateRecoveryCodesView: false,});+onBeforeMount(() => {+ if (props.principalEmail) {+ const userType = getUserTypeByEmail(props.principalEmail);+ if (userType !== UserType.USER) {+ router.replace({+ name: WORKSPACE_ROUTE_404,+ });+ }+ }+});+const editNameTextField = ref<InstanceType<typeof NInput>>();const userPasswordRef = ref<InstanceType<typeof UserPassword>>();diff --git a/frontend/src/views/SettingWorkspaceSubscription.vue b/frontend/src/views/SettingWorkspaceSubscription.vueindex 2c38f7b85a..4b149ac613 100644--- a/frontend/src/views/SettingWorkspaceSubscription.vue+++ b/frontend/src/views/SettingWorkspaceSubscription.vue@@ -162,7 +162,9 @@ import {useActuatorV1Store,useSubscriptionV1Store,} from "@/store";+import { State } from "@/types/proto-es/v1/common_pb";import { PlanType } from "@/types/proto-es/v1/subscription_service_pb";+import { UserType } from "@/types/proto-es/v1/user_service_pb";import { hasWorkspacePermissionV2 } from "@/utils";interface LocalState {@@ -188,9 +190,9 @@ const disabled = computed((): boolean => {});const activeUserCountWithoutBot = computed(() =>- actuatorStore.getActiveUserCount({- includeBot: false,- includeServiceAccount: false,+ actuatorStore.countUser({+ state: State.ACTIVE,+ userTypes: [UserType.USER],}));diff --git a/frontend/src/views/SettingWorkspaceUsers.vue b/frontend/src/views/SettingWorkspaceUsers.vueindex e1d3eec2c9..594d090b59 100644--- a/frontend/src/views/SettingWorkspaceUsers.vue+++ b/frontend/src/views/SettingWorkspaceUsers.vue@@ -682,39 +682,54 @@ onMounted(async () => {});const activeUserCount = computed(() => {- return actuatorStore.getActiveUserCount({- includeBot: true,- includeServiceAccount: false,+ return actuatorStore.countUser({+ state: State.ACTIVE,+ userTypes: [UserType.SYSTEM_BOT, UserType.USER],});});const activeServiceAccountCount = computed(() => {- return actuatorStore.serviceAccountCount;+ return actuatorStore.countUser({+ state: State.ACTIVE,+ userTypes: [UserType.SERVICE_ACCOUNT],+ });});const activeWorkloadIdentityCount = computed(() => {- return actuatorStore.workloadIdentityCount;+ return actuatorStore.countUser({+ state: State.ACTIVE,+ userTypes: [UserType.WORKLOAD_IDENTITY],+ });});const inactiveUserCount = computed(() => {- return actuatorStore.inactiveUserCount;+ return actuatorStore.countUser({+ state: State.DELETED,+ userTypes: [UserType.USER, UserType.SYSTEM_BOT],+ });});const inactiveServiceAccountCount = computed(() => {- return actuatorStore.inactiveServiceAccountCount;+ return actuatorStore.countUser({+ state: State.DELETED,+ userTypes: [UserType.SERVICE_ACCOUNT],+ });});const inactiveWorkloadIdentityCount = computed(() => {- return actuatorStore.inactiveWorkloadIdentityCount;+ return actuatorStore.countUser({+ state: State.DELETED,+ userTypes: [UserType.WORKLOAD_IDENTITY],+ });});const remainingUserCount = computed((): number => {return Math.max(0,subscriptionV1Store.userCountLimit -- actuatorStore.getActiveUserCount({- includeBot: false,- includeServiceAccount: false,+ actuatorStore.countUser({+ state: State.ACTIVE,+ userTypes: [UserType.USER],}));});diff --git a/proto/gen/grpc-doc/openapi.yaml b/proto/gen/grpc-doc/openapi.yamlindex 552af8935c..1dec165f75 100644--- a/proto/gen/grpc-doc/openapi.yaml+++ b/proto/gen/grpc-doc/openapi.yaml@@ -9431,7 +9431,7 @@ paths:Supported filter:- name: the user name, support "==" and ".matches()" operator.- email: the user email, support "==" and ".matches()" operator.- - user_type: the type, check UserType enum for values, support "==", "in [xx]", "!(in [xx])" operator.+ - user_type: the type, check UserType enum for values, support "SYSTEM_BOT" or "USER" value, support "==" and "in [xx]" operator.- state: check State enum for values, support "==" operator.- project: the project full name in "projects/{id}" format, support "==" operator.@@ -9440,9 +9440,8 @@ paths:name.matches("ed")email == "[email protected]"email.matches("ed")- user_type == "SERVICE_ACCOUNT"- user_type in ["SERVICE_ACCOUNT", "USER"]- !(user_type in ["SERVICE_ACCOUNT", "USER"])+ user_type == "USER"+ user_type in ["SYSTEM_BOT", "USER"]state == "DELETED"project == "projects/sample-project"You can combine filter conditions like:@@ -9458,7 +9457,7 @@ paths:Supported filter:- name: the user name, support "==" and ".matches()" operator.- email: the user email, support "==" and ".matches()" operator.- - user_type: the type, check UserType enum for values, support "==", "in [xx]", "!(in [xx])" operator.+ - user_type: the type, check UserType enum for values, support "SYSTEM_BOT" or "USER" value, support "==" and "in [xx]" operator.- state: check State enum for values, support "==" operator.- project: the project full name in "projects/{id}" format, support "==" operator.@@ -9467,9 +9466,8 @@ paths:name.matches("ed")email == "[email protected]"email.matches("ed")- user_type == "SERVICE_ACCOUNT"- user_type in ["SERVICE_ACCOUNT", "USER"]- !(user_type in ["SERVICE_ACCOUNT", "USER"])+ user_type == "USER"+ user_type in ["SYSTEM_BOT", "USER"]state == "DELETED"project == "projects/sample-project"You can combine filter conditions like:@@ -16723,7 +16721,7 @@ components:Supported filter:- name: the user name, support "==" and ".matches()" operator.- email: the user email, support "==" and ".matches()" operator.- - user_type: the type, check UserType enum for values, support "==", "in [xx]", "!(in [xx])" operator.+ - user_type: the type, check UserType enum for values, support "SYSTEM_BOT" or "USER" value, support "==" and "in [xx]" operator.- state: check State enum for values, support "==" operator.- project: the project full name in "projects/{id}" format, support "==" operator.@@ -16732,9 +16730,8 @@ components:name.matches("ed")email == "[email protected]"email.matches("ed")- user_type == "SERVICE_ACCOUNT"- user_type in ["SERVICE_ACCOUNT", "USER"]- !(user_type in ["SERVICE_ACCOUNT", "USER"])+ user_type == "USER"+ user_type in ["SYSTEM_BOT", "USER"]state == "DELETED"project == "projects/sample-project"You can combine filter conditions like:diff --git a/proto/gen/grpc-doc/v1/README.md b/proto/gen/grpc-doc/v1/README.mdindex d745048af0..12dc811688 100644--- a/proto/gen/grpc-doc/v1/README.md+++ b/proto/gen/grpc-doc/v1/README.md@@ -2386,9 +2386,9 @@ When paginating, all other parameters provided to `ListUsers` must match the cal| show_deleted | [bool](#bool) | | Show deleted users if specified. || filter | [string](#string) | | Filter is used to filter users returned in the list. The syntax and semantics of CEL are documented at https://github.com/google/cel-spec-Supported filter: - name: the user name, support "==" and ".matches()" operator. - email: the user email, support "==" and ".matches()" operator. - user_type: the type, check UserType enum for values, support "==", "in [xx]", "!(in [xx])" operator. - state: check State enum for values, support "==" operator. - project: the project full name in "projects/{id}" format, support "==" operator.+Supported filter: - name: the user name, support "==" and ".matches()" operator. - email: the user email, support "==" and ".matches()" operator. - user_type: the type, check UserType enum for values, support "SYSTEM_BOT" or "USER" value, support "==" and "in [xx]" operator. - state: check State enum for values, support "==" operator. - project: the project full name in "projects/{id}" format, support "==" operator.-For example: name == "ed" name.matches("ed") email == "[email protected]" email.matches("ed") user_type == "SERVICE_ACCOUNT" user_type in ["SERVICE_ACCOUNT", "USER"] !(user_type in ["SERVICE_ACCOUNT", "USER"]) state == "DELETED" project == "projects/sample-project" You can combine filter conditions like: name.matches("ed") && project == "projects/sample-project" (name == "ed" || email == "[email protected]") && project == "projects/sample-project" |+For example: name == "ed" name.matches("ed") email == "[email protected]" email.matches("ed") user_type == "USER" user_type in ["SYSTEM_BOT", "USER"] state == "DELETED" project == "projects/sample-project" You can combine filter conditions like: name.matches("ed") && project == "projects/sample-project" (name == "ed" || email == "[email protected]") && project == "projects/sample-project" |diff --git a/proto/gen/grpc-doc/v1/index.html b/proto/gen/grpc-doc/v1/index.htmlindex 875d77672a..e325cadcfc 100644--- a/proto/gen/grpc-doc/v1/index.html+++ b/proto/gen/grpc-doc/v1/index.html@@ -7203,7 +7203,7 @@ The syntax and semantics of CEL are documented at https://github.com/google/cel-Supported filter:- name: the user name, support "==" and ".matches()" operator.- email: the user email, support "==" and ".matches()" operator.-- user_type: the type, check UserType enum for values, support "==", "in [xx]", "!(in [xx])" operator.+- user_type: the type, check UserType enum for values, support "SYSTEM_BOT" or "USER" value, support "==" and "in [xx]" operator.- state: check State enum for values, support "==" operator.- project: the project full name in "projects/{id}" format, support "==" operator.@@ -7212,9 +7212,8 @@ name == "ed"name.matches("ed")email == "[email protected]"email.matches("ed")-user_type == "SERVICE_ACCOUNT"-user_type in ["SERVICE_ACCOUNT", "USER"]-!(user_type in ["SERVICE_ACCOUNT", "USER"])+user_type == "USER"+user_type in ["SYSTEM_BOT", "USER"]state == "DELETED"project == "projects/sample-project"You can combine filter conditions like:diff --git a/proto/v1/v1/user_service.proto b/proto/v1/v1/user_service.protoindex c06dc3237b..4ee182ba1b 100644--- a/proto/v1/v1/user_service.proto+++ b/proto/v1/v1/user_service.proto@@ -160,7 +160,7 @@ message ListUsersRequest {// Supported filter:// - name: the user name, support "==" and ".matches()" operator.// - email: the user email, support "==" and ".matches()" operator.- // - user_type: the type, check UserType enum for values, support "==", "in [xx]", "!(in [xx])" operator.+ // - user_type: the type, check UserType enum for values, support "SYSTEM_BOT" or "USER" value, support "==" and "in [xx]" operator.// - state: check State enum for values, support "==" operator.// - project: the project full name in "projects/{id}" format, support "==" operator.//@@ -169,9 +169,8 @@ message ListUsersRequest {// name.matches("ed")// email == "[email protected]"// email.matches("ed")- // user_type == "SERVICE_ACCOUNT"- // user_type in ["SERVICE_ACCOUNT", "USER"]- // !(user_type in ["SERVICE_ACCOUNT", "USER"])+ // user_type == "USER"+ // user_type in ["SYSTEM_BOT", "USER"]// state == "DELETED"// project == "projects/sample-project"// You can combine filter conditions like: