Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
make filter deterministic
Thiago Araujo da Silvaa53b637c0495
diff --git a/backend/src/server/routes/v2/identity-router.ts b/backend/src/server/routes/v2/identity-router.tsindex 2eac138753..8682298a55 100644--- a/backend/src/server/routes/v2/identity-router.ts+++ b/backend/src/server/routes/v2/identity-router.ts@@ -1,6 +1,6 @@import { z } from "zod";-import { IdentitiesSchema, OrgRolesSchema } from "@app/db/schemas";+import { IdentitiesSchema } from "@app/db/schemas";import { ApiDocsTags, IDENTITIES } from "@app/lib/api-docs";import { buildSearchZodSchema, SearchResourceOperators } from "@app/lib/search-resource/search";import { OrderByDirection } from "@app/lib/types";@@ -53,14 +53,6 @@ const identityMembershipResponseSchema = z.object({lastLoginAuthMethod: z.string().nullable().optional(),lastLoginTime: z.date().nullable().optional(),roles: z.array(roleSchema),- /** @deprecated use `roles` */- customRole: OrgRolesSchema.pick({- id: true,- name: true,- slug: true,- permissions: true,- description: true- }).optional(),identity: IdentitiesSchema.pick({ name: true, id: true, hasDeleteProtection: true, orgId: true }).extend({authMethods: z.array(z.string())})diff --git a/backend/src/services/identity/identity-org-dal.ts b/backend/src/services/identity/identity-org-dal.tsindex 5c062a69e4..00f2e47b7c 100644--- a/backend/src/services/identity/identity-org-dal.ts+++ b/backend/src/services/identity/identity-org-dal.ts@@ -26,6 +26,7 @@ import { selectAllTableCols, sqlNestRelationships } from "@app/lib/knex";import { buildKnexFilterForSearchResource } from "@app/lib/search-resource/db";import { OrderByDirection } from "@app/lib/types";import {+ accessScopeToSearchIdentitiesScope,OrgIdentityOrderBy,SearchIdentitiesScope,TCountIdentitiesV2DAL,@@ -782,6 +783,9 @@ export const identityOrgDALFactory = (db: TDbClient) => {} else {void searchedMemberships.orderBy("identityName", orderDirection);}+ // Secondary sort by membership id keeps pagination deterministic when the primary+ // sort key ties (duplicate names, identical aggregated role).+ void searchedMemberships.orderBy(`${TableName.Membership}.id`, "asc");if (limit) {void searchedMemberships.offset(offset).limit(limit);@@ -923,6 +927,7 @@ export const identityOrgDALFactory = (db: TDbClient) => {} else {void query.orderBy("searchedMemberships.identityName", orderDirection);}+ void query.orderBy("searchedMemberships.id", "asc");const docs = await query;@@ -963,7 +968,7 @@ export const identityOrgDALFactory = (db: TDbClient) => {}) => ({id,identityId: identityId as string,- scope: membershipScope as SearchIdentitiesScope,+ scope: accessScopeToSearchIdentitiesScope(membershipScope),orgId: membershipOrgId,projectId: scopeProjectId,total_count: total_count as string,diff --git a/backend/src/services/identity/identity-types.ts b/backend/src/services/identity/identity-types.tsindex 98c53cef32..02845da0fd 100644--- a/backend/src/services/identity/identity-types.ts+++ b/backend/src/services/identity/identity-types.ts@@ -1,3 +1,4 @@+import { AccessScope } from "@app/db/schemas";import { IPType } from "@app/lib/ip";import { TSearchResourceOperator } from "@app/lib/search-resource/search";import { OrderByDirection, TOrgPermission } from "@app/lib/types";@@ -69,6 +70,20 @@ export enum SearchIdentitiesScope {Project = "project"}+// Translate a raw `Membership.scope` value into a SearchIdentitiesScope. The two enums share+// string values today but live in separate files — go through this helper so a future drift+// (extra AccessScope variant, renamed value) surfaces here instead of silently mistyping rows.+export const accessScopeToSearchIdentitiesScope = (scope: string): SearchIdentitiesScope => {+ switch (scope) {+ case AccessScope.Organization:+ return SearchIdentitiesScope.Organization;+ case AccessScope.Project:+ return SearchIdentitiesScope.Project;+ default:+ throw new Error(`Unexpected membership scope for identity search: ${scope}`);+ }+};+export type TSearchIdentitiesV2DAL = {limit?: number;offset?: number;diff --git a/frontend/src/hooks/api/identities/types.ts b/frontend/src/hooks/api/identities/types.tsindex 55851bbada..8c0bd51637 100644--- a/frontend/src/hooks/api/identities/types.ts+++ b/frontend/src/hooks/api/identities/types.ts@@ -1012,8 +1012,6 @@ export type IdentityMembershipSearchResult = {lastLoginAuthMethod?: IdentityAuthMethod | null;lastLoginTime?: string | null;roles: IdentityMembershipSearchRole[];- /** @deprecated use `roles` */- customRole?: TOrgRole;identity: Pick<Identity, "id" | "name" | "hasDeleteProtection" | "orgId"> & {authMethods: IdentityAuthMethod[];};