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
feat: completed switch in metadata and resolved ts errors in backend
=974f3923d049
diff --git a/backend/src/ee/services/permission/permission-dal.ts b/backend/src/ee/services/permission/permission-dal.tsindex 88b52be229..efe17edad4 100644--- a/backend/src/ee/services/permission/permission-dal.ts+++ b/backend/src/ee/services/permission/permission-dal.ts@@ -204,9 +204,7 @@ export const permissionDALFactory = (db: TDbClient): TPermissionDALFactory => {.on(`${TableName.IdentityMetadata}.userId`, db.raw("?", [actorId])).andOn(`${TableName.Membership}.scopeOrgId`, `${TableName.IdentityMetadata}.orgId`);} else if (actorType === ActorType.IDENTITY) {- void queryBuilder- .on(`${TableName.IdentityMetadata}.identityId`, db.raw("?", [actorId]))- .andOn(`${TableName.Membership}.scopeOrgId`, `${TableName.IdentityMetadata}.orgId`);+ void queryBuilder.on(`${TableName.IdentityMetadata}.identityId`, db.raw("?", [actorId]));}}).where(`${TableName.Membership}.scopeOrgId`, scopeData.orgId)@@ -667,9 +665,7 @@ export const permissionDALFactory = (db: TDbClient): TPermissionDALFactory => {}).join(TableName.Identity, `${TableName.Identity}.id`, `${TableName.Membership}.actorIdentityId`).leftJoin(TableName.IdentityMetadata, (queryBuilder) => {- void queryBuilder- .on(`${TableName.Membership}.actorIdentityId`, `${TableName.IdentityMetadata}.identityId`)- .andOn(`${TableName.Membership}.scopeOrgId`, `${TableName.IdentityMetadata}.orgId`);+ void queryBuilder.on(`${TableName.Membership}.actorIdentityId`, `${TableName.IdentityMetadata}.identityId`);}).where(`${TableName.Membership}.scopeOrgId`, orgId).whereNotNull(`${TableName.Membership}.actorIdentityId`)diff --git a/backend/src/services/identity-alicloud-auth/identity-alicloud-auth-service.ts b/backend/src/services/identity-alicloud-auth/identity-alicloud-auth-service.tsindex 525da1e104..0bbc6f4803 100644--- a/backend/src/services/identity-alicloud-auth/identity-alicloud-auth-service.ts+++ b/backend/src/services/identity-alicloud-auth/identity-alicloud-auth-service.ts@@ -200,7 +200,7 @@ export const identityAliCloudAuthServiceFactory = ({identityId});if (!identityMembershipOrg) throw new NotFoundError({ message: `Failed to find identity with ID ${identityId}` });- if (identityMembershipOrg.identity.identityOrgId !== actorOrgId) {+ if (identityMembershipOrg.identity.orgId !== actorOrgId) {throw new ForbiddenRequestError({ message: "Sub organization not authorized to access this identity" });}@@ -280,7 +280,7 @@ export const identityAliCloudAuthServiceFactory = ({identityId});if (!identityMembershipOrg) throw new NotFoundError({ message: `Failed to find identity with ID ${identityId}` });- if (identityMembershipOrg.identity.identityOrgId !== actorOrgId) {+ if (identityMembershipOrg.identity.orgId !== actorOrgId) {throw new ForbiddenRequestError({ message: "Sub organization not authorized to access this identity" });}@@ -350,7 +350,7 @@ export const identityAliCloudAuthServiceFactory = ({identityId});if (!identityMembershipOrg) throw new NotFoundError({ message: `Failed to find identity with ID ${identityId}` });- if (identityMembershipOrg.identity.identityOrgId !== actorOrgId) {+ if (identityMembershipOrg.identity.orgId !== actorOrgId) {throw new ForbiddenRequestError({ message: "Sub organization not authorized to access this identity" });}@@ -389,7 +389,7 @@ export const identityAliCloudAuthServiceFactory = ({identityId});if (!identityMembershipOrg) throw new NotFoundError({ message: `Failed to find identity with ID ${identityId}` });- if (identityMembershipOrg.identity.identityOrgId !== actorOrgId) {+ if (identityMembershipOrg.identity.orgId !== actorOrgId) {throw new ForbiddenRequestError({ message: "Sub organization not authorized to access this identity" });}if (!identityMembershipOrg.identity.authMethods.includes(IdentityAuthMethod.ALICLOUD_AUTH)) {diff --git a/backend/src/services/identity-aws-auth/identity-aws-auth-service.ts b/backend/src/services/identity-aws-auth/identity-aws-auth-service.tsindex 81fab3fde0..2252263d13 100644--- a/backend/src/services/identity-aws-auth/identity-aws-auth-service.ts+++ b/backend/src/services/identity-aws-auth/identity-aws-auth-service.ts@@ -286,7 +286,7 @@ export const identityAwsAuthServiceFactory = ({identityId});if (!identityMembershipOrg) throw new NotFoundError({ message: `Failed to find identity with ID ${identityId}` });- if (identityMembershipOrg.identity.identityOrgId !== actorOrgId) {+ if (identityMembershipOrg.identity.orgId !== actorOrgId) {throw new ForbiddenRequestError({ message: "Sub organization not authorized to access this identity" });}@@ -370,7 +370,7 @@ export const identityAwsAuthServiceFactory = ({identityId});if (!identityMembershipOrg) throw new NotFoundError({ message: `Failed to find identity with ID ${identityId}` });- if (identityMembershipOrg.identity.identityOrgId !== actorOrgId) {+ if (identityMembershipOrg.identity.orgId !== actorOrgId) {throw new ForbiddenRequestError({ message: "Sub organization not authorized to access this identity" });}@@ -441,7 +441,7 @@ export const identityAwsAuthServiceFactory = ({identityId});if (!identityMembershipOrg) throw new NotFoundError({ message: `Failed to find identity with ID ${identityId}` });- if (identityMembershipOrg.identity.identityOrgId !== actorOrgId) {+ if (identityMembershipOrg.identity.orgId !== actorOrgId) {throw new ForbiddenRequestError({ message: "Sub organization not authorized to access this identity" });}@@ -480,7 +480,7 @@ export const identityAwsAuthServiceFactory = ({identityId});if (!identityMembershipOrg) throw new NotFoundError({ message: `Failed to find identity with ID ${identityId}` });- if (identityMembershipOrg.identity.identityOrgId !== actorOrgId) {+ if (identityMembershipOrg.identity.orgId !== actorOrgId) {throw new ForbiddenRequestError({ message: "Sub organization not authorized to access this identity" });}if (!identityMembershipOrg.identity.authMethods.includes(IdentityAuthMethod.AWS_AUTH)) {diff --git a/backend/src/services/identity-azure-auth/identity-azure-auth-service.ts b/backend/src/services/identity-azure-auth/identity-azure-auth-service.tsindex 17f274e7c9..0d6f8c3ee3 100644--- a/backend/src/services/identity-azure-auth/identity-azure-auth-service.ts+++ b/backend/src/services/identity-azure-auth/identity-azure-auth-service.ts@@ -192,7 +192,7 @@ export const identityAzureAuthServiceFactory = ({identityId});if (!identityMembershipOrg) throw new NotFoundError({ message: `Failed to find identity with ID ${identityId}` });- if (identityMembershipOrg.identity.identityOrgId !== actorOrgId) {+ if (identityMembershipOrg.identity.orgId !== actorOrgId) {throw new ForbiddenRequestError({ message: "Sub organization not authorized to access this identity" });}@@ -275,7 +275,7 @@ export const identityAzureAuthServiceFactory = ({identityId});if (!identityMembershipOrg) throw new NotFoundError({ message: `Failed to find identity with ID ${identityId}` });- if (identityMembershipOrg.identity.identityOrgId !== actorOrgId) {+ if (identityMembershipOrg.identity.orgId !== actorOrgId) {throw new ForbiddenRequestError({ message: "Sub organization not authorized to access this identity" });}if (!identityMembershipOrg.identity.authMethods.includes(IdentityAuthMethod.AZURE_AUTH)) {@@ -348,7 +348,7 @@ export const identityAzureAuthServiceFactory = ({identityId});if (!identityMembershipOrg) throw new NotFoundError({ message: `Failed to find identity with ID ${identityId}` });- if (identityMembershipOrg.identity.identityOrgId !== actorOrgId) {+ if (identityMembershipOrg.identity.orgId !== actorOrgId) {throw new ForbiddenRequestError({ message: "Sub organization not authorized to access this identity" });}if (!identityMembershipOrg.identity.authMethods.includes(IdentityAuthMethod.AZURE_AUTH)) {@@ -387,7 +387,7 @@ export const identityAzureAuthServiceFactory = ({identityId});if (!identityMembershipOrg) throw new NotFoundError({ message: `Failed to find identity with ID ${identityId}` });- if (identityMembershipOrg.identity.identityOrgId !== actorOrgId) {+ if (identityMembershipOrg.identity.orgId !== actorOrgId) {throw new ForbiddenRequestError({ message: "Sub organization not authorized to access this identity" });}if (!identityMembershipOrg.identity.authMethods.includes(IdentityAuthMethod.AZURE_AUTH)) {diff --git a/backend/src/services/identity-gcp-auth/identity-gcp-auth-service.ts b/backend/src/services/identity-gcp-auth/identity-gcp-auth-service.tsindex 3e0035e828..d5f71b84c8 100644--- a/backend/src/services/identity-gcp-auth/identity-gcp-auth-service.ts+++ b/backend/src/services/identity-gcp-auth/identity-gcp-auth-service.ts@@ -232,7 +232,7 @@ export const identityGcpAuthServiceFactory = ({identityId});if (!identityMembershipOrg) throw new NotFoundError({ message: `Failed to find identity with ID ${identityId}` });- if (identityMembershipOrg.identity.identityOrgId !== actorOrgId) {+ if (identityMembershipOrg.identity.orgId !== actorOrgId) {throw new ForbiddenRequestError({ message: "Sub organization not authorized to access this identity" });}@@ -317,7 +317,7 @@ export const identityGcpAuthServiceFactory = ({identityId});if (!identityMembershipOrg) throw new NotFoundError({ message: `Failed to find identity with ID ${identityId}` });- if (identityMembershipOrg.identity.identityOrgId !== actorOrgId) {+ if (identityMembershipOrg.identity.orgId !== actorOrgId) {throw new ForbiddenRequestError({ message: "Sub organization not authorized to access this identity" });}@@ -392,7 +392,7 @@ export const identityGcpAuthServiceFactory = ({identityId});if (!identityMembershipOrg) throw new NotFoundError({ message: `Failed to find identity with ID ${identityId}` });- if (identityMembershipOrg.identity.identityOrgId !== actorOrgId) {+ if (identityMembershipOrg.identity.orgId !== actorOrgId) {throw new ForbiddenRequestError({ message: "Sub organization not authorized to access this identity" });}@@ -432,7 +432,7 @@ export const identityGcpAuthServiceFactory = ({identityId});if (!identityMembershipOrg) throw new NotFoundError({ message: `Failed to find identity with ID ${identityId}` });- if (identityMembershipOrg.identity.identityOrgId !== actorOrgId) {+ if (identityMembershipOrg.identity.orgId !== actorOrgId) {throw new ForbiddenRequestError({ message: "Sub organization not authorized to access this identity" });}diff --git a/backend/src/services/identity-jwt-auth/identity-jwt-auth-service.ts b/backend/src/services/identity-jwt-auth/identity-jwt-auth-service.tsindex 3cf93fd16d..bfa5654b8d 100644--- a/backend/src/services/identity-jwt-auth/identity-jwt-auth-service.ts+++ b/backend/src/services/identity-jwt-auth/identity-jwt-auth-service.ts@@ -309,7 +309,7 @@ export const identityJwtAuthServiceFactory = ({identityId});if (!identityMembershipOrg) throw new NotFoundError({ message: `Failed to find identity with ID ${identityId}` });- if (identityMembershipOrg.identity.identityOrgId !== actorOrgId) {+ if (identityMembershipOrg.identity.orgId !== actorOrgId) {throw new ForbiddenRequestError({ message: "Sub organization not authorized to access this identity" });}if (identityMembershipOrg.identity.authMethods.includes(IdentityAuthMethod.JWT_AUTH)) {@@ -416,7 +416,7 @@ export const identityJwtAuthServiceFactory = ({identityId});if (!identityMembershipOrg) throw new NotFoundError({ message: `Failed to find identity with ID ${identityId}` });- if (identityMembershipOrg.identity.identityOrgId !== actorOrgId) {+ if (identityMembershipOrg.identity.orgId !== actorOrgId) {throw new ForbiddenRequestError({ message: "Sub organization not authorized to access this identity" });}@@ -524,7 +524,7 @@ export const identityJwtAuthServiceFactory = ({identityId});if (!identityMembershipOrg) throw new NotFoundError({ message: `Failed to find identity with ID ${identityId}` });- if (identityMembershipOrg.identity.identityOrgId !== actorOrgId) {+ if (identityMembershipOrg.identity.orgId !== actorOrgId) {throw new ForbiddenRequestError({ message: "Sub organization not authorized to access this identity" });}@@ -576,7 +576,7 @@ export const identityJwtAuthServiceFactory = ({if (!identityMembershipOrg) {throw new NotFoundError({ message: "Failed to find identity" });}- if (identityMembershipOrg.identity.identityOrgId !== actorOrgId) {+ if (identityMembershipOrg.identity.orgId !== actorOrgId) {throw new ForbiddenRequestError({ message: "Sub organization not authorized to access this identity" });}diff --git a/backend/src/services/identity-kubernetes-auth/identity-kubernetes-auth-service.ts b/backend/src/services/identity-kubernetes-auth/identity-kubernetes-auth-service.tsindex b633dc4333..e278853b37 100644--- a/backend/src/services/identity-kubernetes-auth/identity-kubernetes-auth-service.ts+++ b/backend/src/services/identity-kubernetes-auth/identity-kubernetes-auth-service.ts@@ -549,7 +549,7 @@ export const identityKubernetesAuthServiceFactory = ({identityId});if (!identityMembershipOrg) throw new NotFoundError({ message: `Failed to find identity with ID ${identityId}` });- if (identityMembershipOrg.identity.identityOrgId !== actorOrgId) {+ if (identityMembershipOrg.identity.orgId !== actorOrgId) {throw new ForbiddenRequestError({ message: "Sub organization not authorized to access this identity" });}@@ -679,7 +679,7 @@ export const identityKubernetesAuthServiceFactory = ({identityId});if (!identityMembershipOrg) throw new NotFoundError({ message: `Failed to find identity with ID ${identityId}` });- if (identityMembershipOrg.identity.identityOrgId !== actorOrgId) {+ if (identityMembershipOrg.identity.orgId !== actorOrgId) {throw new ForbiddenRequestError({ message: "Sub organization not authorized to access this identity" });}@@ -831,7 +831,7 @@ export const identityKubernetesAuthServiceFactory = ({identityId});if (!identityMembershipOrg) throw new NotFoundError({ message: `Failed to find identity with ID ${identityId}` });- if (identityMembershipOrg.identity.identityOrgId !== actorOrgId) {+ if (identityMembershipOrg.identity.orgId !== actorOrgId) {throw new ForbiddenRequestError({ message: "Sub organization not authorized to access this identity" });}@@ -897,7 +897,7 @@ export const identityKubernetesAuthServiceFactory = ({identityId});if (!identityMembershipOrg) throw new NotFoundError({ message: `Failed to find identity with ID ${identityId}` });- if (identityMembershipOrg.identity.identityOrgId !== actorOrgId) {+ if (identityMembershipOrg.identity.orgId !== actorOrgId) {throw new ForbiddenRequestError({ message: "Sub organization not authorized to access this identity" });}diff --git a/backend/src/services/identity-ldap-auth/identity-ldap-auth-service.ts b/backend/src/services/identity-ldap-auth/identity-ldap-auth-service.tsindex d327dabeed..921aa32735 100644--- a/backend/src/services/identity-ldap-auth/identity-ldap-auth-service.ts+++ b/backend/src/services/identity-ldap-auth/identity-ldap-auth-service.ts@@ -276,7 +276,7 @@ export const identityLdapAuthServiceFactory = ({identityId});if (!identityMembershipOrg) throw new NotFoundError({ message: `Failed to find identity with ID ${identityId}` });- if (identityMembershipOrg.identity.identityOrgId !== actorOrgId) {+ if (identityMembershipOrg.identity.orgId !== actorOrgId) {throw new ForbiddenRequestError({ message: "Sub organization not authorized to access this identity" });}@@ -451,7 +451,7 @@ export const identityLdapAuthServiceFactory = ({identityId});if (!identityMembershipOrg) throw new NotFoundError({ message: `Failed to find identity with ID ${identityId}` });- if (identityMembershipOrg.identity.identityOrgId !== actorOrgId) {+ if (identityMembershipOrg.identity.orgId !== actorOrgId) {throw new ForbiddenRequestError({ message: "Sub organization not authorized to access this identity" });}@@ -618,7 +618,7 @@ export const identityLdapAuthServiceFactory = ({identityId});if (!identityMembershipOrg) throw new NotFoundError({ message: `Failed to find identity with ID ${identityId}` });- if (identityMembershipOrg.identity.identityOrgId !== actorOrgId) {+ if (identityMembershipOrg.identity.orgId !== actorOrgId) {throw new ForbiddenRequestError({ message: "Sub organization not authorized to access this identity" });}@@ -669,7 +669,7 @@ export const identityLdapAuthServiceFactory = ({identityId});if (!identityMembershipOrg) throw new NotFoundError({ message: `Failed to find identity with ID ${identityId}` });- if (identityMembershipOrg.identity.identityOrgId !== actorOrgId) {+ if (identityMembershipOrg.identity.orgId !== actorOrgId) {throw new ForbiddenRequestError({ message: "Sub organization not authorized to access this identity" });}if (!identityMembershipOrg.identity.authMethods.includes(IdentityAuthMethod.LDAP_AUTH)) {diff --git a/backend/src/services/identity-oci-auth/identity-oci-auth-service.ts b/backend/src/services/identity-oci-auth/identity-oci-auth-service.tsindex c75abc76bb..5d7042b9f1 100644--- a/backend/src/services/identity-oci-auth/identity-oci-auth-service.ts+++ b/backend/src/services/identity-oci-auth/identity-oci-auth-service.ts@@ -203,7 +203,7 @@ export const identityOciAuthServiceFactory = ({identityId});if (!identityMembershipOrg) throw new NotFoundError({ message: `Failed to find identity with ID ${identityId}` });- if (identityMembershipOrg.identity.identityOrgId !== actorOrgId) {+ if (identityMembershipOrg.identity.orgId !== actorOrgId) {throw new ForbiddenRequestError({ message: "Sub organization not authorized to access this identity" });}@@ -285,7 +285,7 @@ export const identityOciAuthServiceFactory = ({identityId});if (!identityMembershipOrg) throw new NotFoundError({ message: `Failed to find identity with ID ${identityId}` });- if (identityMembershipOrg.identity.identityOrgId !== actorOrgId) {+ if (identityMembershipOrg.identity.orgId !== actorOrgId) {throw new ForbiddenRequestError({ message: "Sub organization not authorized to access this identity" });}@@ -355,7 +355,7 @@ export const identityOciAuthServiceFactory = ({identityId});if (!identityMembershipOrg) throw new NotFoundError({ message: `Failed to find identity with ID ${identityId}` });- if (identityMembershipOrg.identity.identityOrgId !== actorOrgId) {+ if (identityMembershipOrg.identity.orgId !== actorOrgId) {throw new ForbiddenRequestError({ message: "Sub organization not authorized to access this identity" });}@@ -394,7 +394,7 @@ export const identityOciAuthServiceFactory = ({identityId});if (!identityMembershipOrg) throw new NotFoundError({ message: `Failed to find identity with ID ${identityId}` });- if (identityMembershipOrg.identity.identityOrgId !== actorOrgId) {+ if (identityMembershipOrg.identity.orgId !== actorOrgId) {throw new ForbiddenRequestError({ message: "Sub organization not authorized to access this identity" });}if (!identityMembershipOrg.identity.authMethods.includes(IdentityAuthMethod.OCI_AUTH)) {diff --git a/backend/src/services/identity-oidc-auth/identity-oidc-auth-service.ts b/backend/src/services/identity-oidc-auth/identity-oidc-auth-service.tsindex d9c0b71c9f..36ca09b3fa 100644--- a/backend/src/services/identity-oidc-auth/identity-oidc-auth-service.ts+++ b/backend/src/services/identity-oidc-auth/identity-oidc-auth-service.ts@@ -366,7 +366,7 @@ export const identityOidcAuthServiceFactory = ({if (!identityMembershipOrg) {throw new NotFoundError({ message: `Failed to find identity with ID ${identityId}` });}- if (identityMembershipOrg.identity.identityOrgId !== actorOrgId) {+ if (identityMembershipOrg.identity.orgId !== actorOrgId) {throw new ForbiddenRequestError({ message: "Sub organization not authorized to access this identity" });}if (identityMembershipOrg.identity.authMethods.includes(IdentityAuthMethod.OIDC_AUTH)) {@@ -462,7 +462,7 @@ export const identityOidcAuthServiceFactory = ({identityId});if (!identityMembershipOrg) throw new NotFoundError({ message: `Failed to find identity with ID ${identityId}` });- if (identityMembershipOrg.identity.identityOrgId !== actorOrgId) {+ if (identityMembershipOrg.identity.orgId !== actorOrgId) {throw new ForbiddenRequestError({ message: "Sub organization not authorized to access this identity" });}@@ -555,7 +555,7 @@ export const identityOidcAuthServiceFactory = ({identityId});if (!identityMembershipOrg) throw new NotFoundError({ message: `Failed to find identity with ID ${identityId}` });- if (identityMembershipOrg.identity.identityOrgId !== actorOrgId) {+ if (identityMembershipOrg.identity.orgId !== actorOrgId) {throw new ForbiddenRequestError({ message: "Sub organization not authorized to access this identity" });}@@ -600,7 +600,7 @@ export const identityOidcAuthServiceFactory = ({if (!identityMembershipOrg) {throw new NotFoundError({ message: "Failed to find identity" });}- if (identityMembershipOrg.identity.identityOrgId !== actorOrgId) {+ if (identityMembershipOrg.identity.orgId !== actorOrgId) {throw new ForbiddenRequestError({ message: "Sub organization not authorized to access this identity" });}diff --git a/backend/src/services/identity-tls-cert-auth/identity-tls-cert-auth-service.ts b/backend/src/services/identity-tls-cert-auth/identity-tls-cert-auth-service.tsindex 60670d035f..aa4940d645 100644--- a/backend/src/services/identity-tls-cert-auth/identity-tls-cert-auth-service.ts+++ b/backend/src/services/identity-tls-cert-auth/identity-tls-cert-auth-service.ts@@ -223,7 +223,7 @@ export const identityTlsCertAuthServiceFactory = ({identityId});if (!identityMembershipOrg) throw new NotFoundError({ message: `Failed to find identity with ID ${identityId}` });- if (identityMembershipOrg.identity.identityOrgId !== actorOrgId) {+ if (identityMembershipOrg.identity.orgId !== actorOrgId) {throw new ForbiddenRequestError({ message: "Sub organization not authorized to access this identity" });}@@ -309,7 +309,7 @@ export const identityTlsCertAuthServiceFactory = ({identityId});if (!identityMembershipOrg) throw new NotFoundError({ message: `Failed to find identity with ID ${identityId}` });- if (identityMembershipOrg.identity.identityOrgId !== actorOrgId) {+ if (identityMembershipOrg.identity.orgId !== actorOrgId) {throw new ForbiddenRequestError({ message: "Sub organization not authorized to access this identity" });}@@ -392,7 +392,7 @@ export const identityTlsCertAuthServiceFactory = ({identityId});if (!identityMembershipOrg) throw new NotFoundError({ message: `Failed to find identity with ID ${identityId}` });- if (identityMembershipOrg.identity.identityOrgId !== actorOrgId) {+ if (identityMembershipOrg.identity.orgId !== actorOrgId) {throw new ForbiddenRequestError({ message: "Sub organization not authorized to access this identity" });}@@ -440,7 +440,7 @@ export const identityTlsCertAuthServiceFactory = ({identityId});if (!identityMembershipOrg) throw new NotFoundError({ message: `Failed to find identity with ID ${identityId}` });- if (identityMembershipOrg.identity.identityOrgId !== actorOrgId) {+ if (identityMembershipOrg.identity.orgId !== actorOrgId) {throw new ForbiddenRequestError({ message: "Sub organization not authorized to access this identity" });}if (!identityMembershipOrg.identity.authMethods.includes(IdentityAuthMethod.TLS_CERT_AUTH)) {diff --git a/backend/src/services/identity-token-auth/identity-token-auth-service.ts b/backend/src/services/identity-token-auth/identity-token-auth-service.tsindex e6969da611..338a7838a8 100644--- a/backend/src/services/identity-token-auth/identity-token-auth-service.ts+++ b/backend/src/services/identity-token-auth/identity-token-auth-service.ts@@ -87,7 +87,7 @@ export const identityTokenAuthServiceFactory = ({identityId});if (!identityMembershipOrg) throw new NotFoundError({ message: `Failed to find identity with ID ${identityId}` });- if (identityMembershipOrg.identity.identityOrgId !== actorOrgId) {+ if (identityMembershipOrg.identity.orgId !== actorOrgId) {throw new ForbiddenRequestError({ message: "Sub organization not authorized to access this identity" });}@@ -167,7 +167,7 @@ export const identityTokenAuthServiceFactory = ({identityId});if (!identityMembershipOrg) throw new NotFoundError({ message: `Failed to find identity with ID ${identityId}` });- if (identityMembershipOrg.identity.identityOrgId !== actorOrgId) {+ if (identityMembershipOrg.identity.orgId !== actorOrgId) {throw new ForbiddenRequestError({ message: "Sub organization not authorized to access this identity" });}@@ -239,7 +239,7 @@ export const identityTokenAuthServiceFactory = ({identityId});if (!identityMembershipOrg) throw new NotFoundError({ message: `Failed to find identity with ID ${identityId}` });- if (identityMembershipOrg.identity.identityOrgId !== actorOrgId) {+ if (identityMembershipOrg.identity.orgId !== actorOrgId) {throw new ForbiddenRequestError({ message: "Sub organization not authorized to access this identity" });}@@ -282,7 +282,7 @@ export const identityTokenAuthServiceFactory = ({identityId});if (!identityMembershipOrg) throw new NotFoundError({ message: `Failed to find identity with ID ${identityId}` });- if (identityMembershipOrg.identity.identityOrgId !== actorOrgId) {+ if (identityMembershipOrg.identity.orgId !== actorOrgId) {throw new ForbiddenRequestError({ message: "Sub organization not authorized to access this identity" });}diff --git a/backend/src/services/identity-ua/identity-ua-service.ts b/backend/src/services/identity-ua/identity-ua-service.tsindex 26bd016275..c8409585ee 100644--- a/backend/src/services/identity-ua/identity-ua-service.ts+++ b/backend/src/services/identity-ua/identity-ua-service.ts@@ -343,7 +343,7 @@ export const identityUaServiceFactory = ({message: "Failed to add universal auth to already configured identity"});}- if (identityMembershipOrg.identity.identityOrgId !== actorOrgId) {+ if (identityMembershipOrg.identity.orgId !== actorOrgId) {throw new ForbiddenRequestError({ message: "Sub organization not authorized to access this identity" });}@@ -456,7 +456,7 @@ export const identityUaServiceFactory = ({});}- if (identityMembershipOrg.identity.identityOrgId !== actorOrgId) {+ if (identityMembershipOrg.identity.orgId !== actorOrgId) {throw new ForbiddenRequestError({ message: "Sub organization not authorized to access this identity" });}@@ -550,7 +550,7 @@ export const identityUaServiceFactory = ({message: "The identity does not have universal auth"});}- if (identityMembershipOrg.identity.identityOrgId !== actorOrgId) {+ if (identityMembershipOrg.identity.orgId !== actorOrgId) {throw new ForbiddenRequestError({ message: "Sub organization not authorized to access this identity" });}@@ -587,7 +587,7 @@ export const identityUaServiceFactory = ({message: "The identity does not have universal auth"});}- if (identityMembershipOrg.identity.identityOrgId !== actorOrgId) {+ if (identityMembershipOrg.identity.orgId !== actorOrgId) {throw new ForbiddenRequestError({ message: "Sub organization not authorized to access this identity" });}const { permission } = await permissionService.getOrgPermission({@@ -658,7 +658,7 @@ export const identityUaServiceFactory = ({message: "The identity does not have universal auth"});}- if (identityMembershipOrg.identity.identityOrgId !== actorOrgId) {+ if (identityMembershipOrg.identity.orgId !== actorOrgId) {throw new ForbiddenRequestError({ message: "Sub organization not authorized to access this identity" });}@@ -744,7 +744,7 @@ export const identityUaServiceFactory = ({message: "The identity does not have universal auth"});}- if (identityMembershipOrg.identity.identityOrgId !== actorOrgId) {+ if (identityMembershipOrg.identity.orgId !== actorOrgId) {throw new ForbiddenRequestError({ message: "Sub organization not authorized to access this identity" });}@@ -818,7 +818,7 @@ export const identityUaServiceFactory = ({message: "The identity does not have universal auth"});}- if (identityMembershipOrg.identity.identityOrgId !== actorOrgId) {+ if (identityMembershipOrg.identity.orgId !== actorOrgId) {throw new ForbiddenRequestError({ message: "Sub organization not authorized to access this identity" });}@@ -890,7 +890,7 @@ export const identityUaServiceFactory = ({message: "The identity does not have universal auth"});}- if (identityMembershipOrg.identity.identityOrgId !== actorOrgId) {+ if (identityMembershipOrg.identity.orgId !== actorOrgId) {throw new ForbiddenRequestError({ message: "Sub organization not authorized to access this identity" });}@@ -967,7 +967,7 @@ export const identityUaServiceFactory = ({message: "The identity does not have universal auth"});}- if (identityMembershipOrg.identity.identityOrgId !== actorOrgId) {+ if (identityMembershipOrg.identity.orgId !== actorOrgId) {throw new ForbiddenRequestError({ message: "Sub organization not authorized to access this identity" });}diff --git a/backend/src/services/identity/identity-service.ts b/backend/src/services/identity/identity-service.tsindex f6ec60e9ea..72b81bac2f 100644--- a/backend/src/services/identity/identity-service.ts+++ b/backend/src/services/identity/identity-service.ts@@ -142,7 +142,7 @@ export const identityServiceFactory = ({if (metadata && metadata.length) {const rowsToInsert = metadata.map(({ key, value }) => ({identityId: newIdentity.id,- orgId,+ orgId: newIdentity.orgId,key,value}));@@ -243,13 +243,13 @@ export const identityServiceFactory = ({value: string;}> = [];- if (metadata) {- await identityMetadataDAL.delete({ orgId: identityOrgMembership.scopeOrgId, identityId: id }, tx);+ if (metadata && identityDetails.orgId === actorOrgId) {+ await identityMetadataDAL.delete({ orgId: newIdentity.orgId, identityId: id }, tx);if (metadata.length) {const rowsToInsert = metadata.map(({ key, value }) => ({identityId: newIdentity.id,- orgId: identityOrgMembership.scopeOrgId,+ orgId: newIdentity.orgId,key,value}));@@ -340,7 +340,7 @@ export const identityServiceFactory = ({if (identityOrgMembership.identity.hasDeleteProtection)throw new BadRequestError({ message: "Identity has delete protection" });- if (identityOrgMembership.identity.identityOrgId === actorOrgId) {+ if (identityOrgMembership.identity.orgId === actorOrgId) {const deletedIdentity = await identityDAL.deleteById(id);await licenseService.updateSubscriptionOrgMemberCount(identityOrgMembership.scopeOrgId);return { ...deletedIdentity, orgId: identityOrgMembership.scopeOrgId };diff --git a/backend/src/services/scoped-identity/identity-service.ts b/backend/src/services/scoped-identity/identity-service.tsindex b3605bd93f..489d3a7444 100644--- a/backend/src/services/scoped-identity/identity-service.ts+++ b/backend/src/services/scoped-identity/identity-service.ts@@ -115,7 +115,7 @@ export const identityServiceFactory = ({if (data.metadata && data.metadata.length) {const rowsToInsert = data.metadata.map(({ key, value }) => ({identityId: newIdentity.id,- orgId: dto.permission.orgId,+ orgId: newIdentity.orgId,key,value}));@@ -148,7 +148,7 @@ export const identityServiceFactory = ({throw new NotFoundError({ message: `Identity with id ${dto.selector.identityId} not found` });const identity = await identityDAL.transaction(async (tx) => {- const newIdentity =+ const updatedIdentity =data?.name || data?.hasDeleteProtection? await identityDAL.updateById(dto.selector.identityId,@@ -168,8 +168,8 @@ export const identityServiceFactory = ({if (data.metadata.length) {const rowsToInsert = data.metadata.map(({ key, value }) => ({- identityId: newIdentity.id,- orgId: dto.permission.orgId,+ identityId: updatedIdentity.id,+ orgId: updatedIdentity.orgId,key,value}));@@ -179,7 +179,7 @@ export const identityServiceFactory = ({}return {- ...newIdentity,+ ...updatedIdentity,metadata: insertedMetadata};});