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
fix order
Thiago Araujo da Silvac708315b3cfa
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 346550affa..63393b2fef 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@@ -272,8 +272,6 @@ export const identityAliCloudAuthServiceFactory = ({actorOrgId,isActorSuperAdmin}: TAttachAliCloudAuthDTO) => {- await validateIdentityUpdateForSuperAdminPrivileges(identityId, isActorSuperAdmin);-const identityMembershipOrg = await membershipIdentityDAL.getIdentityById({scopeData: {scope: AccessScope.Organization,@@ -324,6 +322,8 @@ export const identityAliCloudAuthServiceFactory = ({OrgPermissionSubjects.Identity);}++ await validateIdentityUpdateForSuperAdminPrivileges(identityId, isActorSuperAdmin);const plan = await licenseService.getPlan(identityMembershipOrg.scopeOrgId);const reformattedAccessTokenTrustedIps = accessTokenTrustedIps.map((accessTokenTrustedIp) => {if (@@ -374,8 +374,6 @@ export const identityAliCloudAuthServiceFactory = ({actorOrgId,isActorSuperAdmin}: TUpdateAliCloudAuthDTO) => {- await validateIdentityUpdateForSuperAdminPrivileges(identityId, isActorSuperAdmin);-const identityMembershipOrg = await membershipIdentityDAL.getIdentityById({scopeData: {scope: AccessScope.Organization,@@ -432,6 +430,8 @@ export const identityAliCloudAuthServiceFactory = ({OrgPermissionSubjects.Identity);}++ await validateIdentityUpdateForSuperAdminPrivileges(identityId, isActorSuperAdmin);const plan = await licenseService.getPlan(identityMembershipOrg.scopeOrgId);const reformattedAccessTokenTrustedIps = accessTokenTrustedIps?.map((accessTokenTrustedIp) => {if (@@ -521,8 +521,6 @@ export const identityAliCloudAuthServiceFactory = ({actorOrgId,isActorSuperAdmin}: TRevokeAliCloudAuthDTO) => {- await validateIdentityUpdateForSuperAdminPrivileges(identityId, isActorSuperAdmin);-const identityMembershipOrg = await membershipIdentityDAL.getIdentityById({scopeData: {scope: AccessScope.Organization,@@ -534,6 +532,7 @@ export const identityAliCloudAuthServiceFactory = ({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)) {throw new BadRequestError({message: "The identity does not have Alibaba Cloud auth"@@ -597,6 +596,8 @@ export const identityAliCloudAuthServiceFactory = ({});}+ await validateIdentityUpdateForSuperAdminPrivileges(identityId, isActorSuperAdmin);+const revokedIdentityAliCloudAuth = await identityAliCloudAuthDAL.transaction(async (tx) => {const deletedAliCloudAuth = await identityAliCloudAuthDAL.delete({ identityId }, tx);await identityAccessTokenDAL.delete({ identityId, authMethod: IdentityAuthMethod.ALICLOUD_AUTH }, tx);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 dcbe27dd07..80e877d009 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@@ -370,8 +370,6 @@ export const identityAwsAuthServiceFactory = ({actorOrgId,isActorSuperAdmin}: TAttachAwsAuthDTO) => {- await validateIdentityUpdateForSuperAdminPrivileges(identityId, isActorSuperAdmin);-const identityMembershipOrg = await membershipIdentityDAL.getIdentityById({scopeData: {scope: AccessScope.Organization,@@ -422,6 +420,8 @@ export const identityAwsAuthServiceFactory = ({OrgPermissionSubjects.Identity);}++ await validateIdentityUpdateForSuperAdminPrivileges(identityId, isActorSuperAdmin);const plan = await licenseService.getPlan(identityMembershipOrg.scopeOrgId);const reformattedAccessTokenTrustedIps = accessTokenTrustedIps.map((accessTokenTrustedIp) => {if (@@ -476,8 +476,6 @@ export const identityAwsAuthServiceFactory = ({actorOrgId,isActorSuperAdmin}: TUpdateAwsAuthDTO) => {- await validateIdentityUpdateForSuperAdminPrivileges(identityId, isActorSuperAdmin);-const identityMembershipOrg = await membershipIdentityDAL.getIdentityById({scopeData: {scope: AccessScope.Organization,@@ -533,6 +531,8 @@ export const identityAwsAuthServiceFactory = ({OrgPermissionSubjects.Identity);}++ await validateIdentityUpdateForSuperAdminPrivileges(identityId, isActorSuperAdmin);const plan = await licenseService.getPlan(identityMembershipOrg.scopeOrgId);const reformattedAccessTokenTrustedIps = accessTokenTrustedIps?.map((accessTokenTrustedIp) => {if (@@ -624,8 +624,6 @@ export const identityAwsAuthServiceFactory = ({actorOrgId,isActorSuperAdmin}: TRevokeAwsAuthDTO) => {- await validateIdentityUpdateForSuperAdminPrivileges(identityId, isActorSuperAdmin);-const identityMembershipOrg = await membershipIdentityDAL.getIdentityById({scopeData: {scope: AccessScope.Organization,@@ -637,6 +635,7 @@ export const identityAwsAuthServiceFactory = ({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)) {throw new BadRequestError({message: "The identity does not have aws auth"@@ -699,6 +698,8 @@ export const identityAwsAuthServiceFactory = ({details: { missingPermissions: permissionBoundary.missingPermissions }});}++ await validateIdentityUpdateForSuperAdminPrivileges(identityId, isActorSuperAdmin);const revokedIdentityAwsAuth = await identityAwsAuthDAL.transaction(async (tx) => {const deletedAwsAuth = await identityAwsAuthDAL.delete({ identityId }, tx);await identityAccessTokenDAL.delete({ identityId, authMethod: IdentityAuthMethod.AWS_AUTH }, tx);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 081b70ad56..9f9882ae8d 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@@ -272,8 +272,6 @@ export const identityAzureAuthServiceFactory = ({actorOrgId,isActorSuperAdmin}: TAttachAzureAuthDTO) => {- await validateIdentityUpdateForSuperAdminPrivileges(identityId, isActorSuperAdmin);-const identityMembershipOrg = await membershipIdentityDAL.getIdentityById({scopeData: {scope: AccessScope.Organization,@@ -323,6 +321,8 @@ export const identityAzureAuthServiceFactory = ({OrgPermissionSubjects.Identity);}++ await validateIdentityUpdateForSuperAdminPrivileges(identityId, isActorSuperAdmin);const plan = await licenseService.getPlan(identityMembershipOrg.scopeOrgId);const reformattedAccessTokenTrustedIps = accessTokenTrustedIps.map((accessTokenTrustedIp) => {if (@@ -377,8 +377,6 @@ export const identityAzureAuthServiceFactory = ({actorOrgId,isActorSuperAdmin}: TUpdateAzureAuthDTO) => {- await validateIdentityUpdateForSuperAdminPrivileges(identityId, isActorSuperAdmin);-const identityMembershipOrg = await membershipIdentityDAL.getIdentityById({scopeData: {scope: AccessScope.Organization,@@ -390,6 +388,7 @@ export const identityAzureAuthServiceFactory = ({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)) {throw new BadRequestError({message: "Failed to update Azure Auth"@@ -433,6 +432,8 @@ export const identityAzureAuthServiceFactory = ({OrgPermissionSubjects.Identity);}++ await validateIdentityUpdateForSuperAdminPrivileges(identityId, isActorSuperAdmin);const plan = await licenseService.getPlan(identityMembershipOrg.scopeOrgId);const reformattedAccessTokenTrustedIps = accessTokenTrustedIps?.map((accessTokenTrustedIp) => {if (@@ -526,8 +527,6 @@ export const identityAzureAuthServiceFactory = ({actorOrgId,isActorSuperAdmin}: TRevokeAzureAuthDTO) => {- await validateIdentityUpdateForSuperAdminPrivileges(identityId, isActorSuperAdmin);-const identityMembershipOrg = await membershipIdentityDAL.getIdentityById({scopeData: {scope: AccessScope.Organization,@@ -539,6 +538,7 @@ export const identityAzureAuthServiceFactory = ({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)) {throw new BadRequestError({message: "The identity does not have azure auth"@@ -600,6 +600,8 @@ export const identityAzureAuthServiceFactory = ({});}+ await validateIdentityUpdateForSuperAdminPrivileges(identityId, isActorSuperAdmin);+const revokedIdentityAzureAuth = await identityAzureAuthDAL.transaction(async (tx) => {const deletedAzureAuth = await identityAzureAuthDAL.delete({ identityId }, tx);await identityAccessTokenDAL.delete({ identityId, authMethod: IdentityAuthMethod.AZURE_AUTH }, tx);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 a8c807c84f..076fc79325 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@@ -316,8 +316,6 @@ export const identityGcpAuthServiceFactory = ({actorOrgId,isActorSuperAdmin}: TAttachGcpAuthDTO) => {- await validateIdentityUpdateForSuperAdminPrivileges(identityId, isActorSuperAdmin);-const identityMembershipOrg = await membershipIdentityDAL.getIdentityById({scopeData: {scope: AccessScope.Organization,@@ -368,6 +366,8 @@ export const identityGcpAuthServiceFactory = ({OrgPermissionSubjects.Identity);}++ await validateIdentityUpdateForSuperAdminPrivileges(identityId, isActorSuperAdmin);const plan = await licenseService.getPlan(identityMembershipOrg.scopeOrgId);const reformattedAccessTokenTrustedIps = accessTokenTrustedIps.map((accessTokenTrustedIp) => {if (@@ -423,8 +423,6 @@ export const identityGcpAuthServiceFactory = ({actorOrgId,isActorSuperAdmin}: TUpdateGcpAuthDTO) => {- await validateIdentityUpdateForSuperAdminPrivileges(identityId, isActorSuperAdmin);-const identityMembershipOrg = await membershipIdentityDAL.getIdentityById({scopeData: {scope: AccessScope.Organization,@@ -480,6 +478,8 @@ export const identityGcpAuthServiceFactory = ({OrgPermissionSubjects.Identity);}++ await validateIdentityUpdateForSuperAdminPrivileges(identityId, isActorSuperAdmin);const plan = await licenseService.getPlan(identityMembershipOrg.scopeOrgId);const reformattedAccessTokenTrustedIps = accessTokenTrustedIps?.map((accessTokenTrustedIp) => {if (@@ -575,8 +575,6 @@ export const identityGcpAuthServiceFactory = ({actorOrgId,isActorSuperAdmin}: TRevokeGcpAuthDTO) => {- await validateIdentityUpdateForSuperAdminPrivileges(identityId, isActorSuperAdmin);-const identityMembershipOrg = await membershipIdentityDAL.getIdentityById({scopeData: {scope: AccessScope.Organization,@@ -649,6 +647,8 @@ export const identityGcpAuthServiceFactory = ({});}+ await validateIdentityUpdateForSuperAdminPrivileges(identityId, isActorSuperAdmin);+const revokedIdentityGcpAuth = await identityGcpAuthDAL.transaction(async (tx) => {const deletedGcpAuth = await identityGcpAuthDAL.delete({ identityId }, tx);await identityAccessTokenDAL.delete({ identityId, authMethod: IdentityAuthMethod.GCP_AUTH }, tx);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 fb1759427b..d120211f09 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@@ -436,8 +436,6 @@ export const identityJwtAuthServiceFactory = ({actorOrgId,isActorSuperAdmin}: TAttachJwtAuthDTO) => {- await validateIdentityUpdateForSuperAdminPrivileges(identityId, isActorSuperAdmin);-const identityMembershipOrg = await membershipIdentityDAL.getIdentityById({scopeData: {scope: AccessScope.Organization,@@ -449,6 +447,7 @@ export const identityJwtAuthServiceFactory = ({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)) {throw new BadRequestError({message: "Failed to add JWT Auth to already configured identity"@@ -489,6 +488,8 @@ export const identityJwtAuthServiceFactory = ({);}+ await validateIdentityUpdateForSuperAdminPrivileges(identityId, isActorSuperAdmin);+const plan = await licenseService.getPlan(identityMembershipOrg.scopeOrgId);const reformattedAccessTokenTrustedIps = accessTokenTrustedIps.map((accessTokenTrustedIp) => {if (@@ -570,8 +571,6 @@ export const identityJwtAuthServiceFactory = ({actorOrgId,isActorSuperAdmin}: TUpdateJwtAuthDTO) => {- await validateIdentityUpdateForSuperAdminPrivileges(identityId, isActorSuperAdmin);-const identityMembershipOrg = await membershipIdentityDAL.getIdentityById({scopeData: {scope: AccessScope.Organization,@@ -628,6 +627,8 @@ export const identityJwtAuthServiceFactory = ({OrgPermissionSubjects.Identity);}++ await validateIdentityUpdateForSuperAdminPrivileges(identityId, isActorSuperAdmin);const plan = await licenseService.getPlan(identityMembershipOrg.scopeOrgId);const reformattedAccessTokenTrustedIps = accessTokenTrustedIps?.map((accessTokenTrustedIp) => {if (@@ -775,8 +776,6 @@ export const identityJwtAuthServiceFactory = ({actorOrgId,isActorSuperAdmin}: TRevokeJwtAuthDTO) => {- await validateIdentityUpdateForSuperAdminPrivileges(identityId, isActorSuperAdmin);-const identityMembershipOrg = await membershipIdentityDAL.getIdentityById({scopeData: {scope: AccessScope.Organization,@@ -854,6 +853,8 @@ export const identityJwtAuthServiceFactory = ({details: { missingPermissions: permissionBoundary.missingPermissions }});}++ await validateIdentityUpdateForSuperAdminPrivileges(identityId, isActorSuperAdmin);const revokedIdentityJwtAuth = await identityJwtAuthDAL.transaction(async (tx) => {const deletedJwtAuth = await identityJwtAuthDAL.delete({ identityId }, tx);await identityAccessTokenDAL.delete({ identityId, authMethod: IdentityAuthMethod.JWT_AUTH }, tx);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 d45a042ab9..62e27a2a37 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@@ -803,8 +803,6 @@ export const identityKubernetesAuthServiceFactory = ({actorOrgId,isActorSuperAdmin}: TAttachKubernetesAuthDTO) => {- await validateIdentityUpdateForSuperAdminPrivileges(identityId, isActorSuperAdmin);-const identityMembershipOrg = await membershipIdentityDAL.getIdentityById({scopeData: {scope: AccessScope.Organization,@@ -1000,6 +998,8 @@ export const identityKubernetesAuthServiceFactory = ({}}+ await validateIdentityUpdateForSuperAdminPrivileges(identityId, isActorSuperAdmin);+const { encryptor } = await kmsService.createCipherPairWithDataKey({type: KmsDataKey.Organization,orgId: identityMembershipOrg.scopeOrgId@@ -1073,8 +1073,6 @@ export const identityKubernetesAuthServiceFactory = ({actorOrgId,isActorSuperAdmin}: TUpdateKubernetesAuthDTO) => {- await validateIdentityUpdateForSuperAdminPrivileges(identityId, isActorSuperAdmin);-const identityMembershipOrg = await membershipIdentityDAL.getIdentityById({scopeData: {scope: AccessScope.Organization,@@ -1211,6 +1209,8 @@ export const identityKubernetesAuthServiceFactory = ({}}+ await validateIdentityUpdateForSuperAdminPrivileges(identityId, isActorSuperAdmin);+// Strict check to see if gateway ID is undefined. It should update the gateway ID to null if its strictly set to null.const shouldUpdateGatewayId = Boolean(gatewayId !== undefined || gatewayPoolId !== undefined);let gatewayIdValue: string | null | undefined = null;@@ -1501,8 +1501,6 @@ export const identityKubernetesAuthServiceFactory = ({actorOrgId,isActorSuperAdmin}: TRevokeKubernetesAuthDTO) => {- await validateIdentityUpdateForSuperAdminPrivileges(identityId, isActorSuperAdmin);-const identityMembershipOrg = await membershipIdentityDAL.getIdentityById({scopeData: {scope: AccessScope.Organization,@@ -1575,6 +1573,8 @@ export const identityKubernetesAuthServiceFactory = ({details: { missingPermissions: permissionBoundary.missingPermissions }});}++ await validateIdentityUpdateForSuperAdminPrivileges(identityId, isActorSuperAdmin);const revokedIdentityKubernetesAuth = await identityKubernetesAuthDAL.transaction(async (tx) => {const deletedKubernetesAuth = await identityKubernetesAuthDAL.delete({ identityId }, tx);await identityAccessTokenDAL.delete({ identityId, authMethod: IdentityAuthMethod.KUBERNETES_AUTH }, tx);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 d9ca10929d..ed86d70a9c 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@@ -344,8 +344,6 @@ export const identityLdapAuthServiceFactory = ({lockoutDurationSeconds,lockoutCounterResetSeconds}: TAttachLdapAuthDTO) => {- await validateIdentityUpdateForSuperAdminPrivileges(identityId, isActorSuperAdmin);-const identityMembershipOrg = await membershipIdentityDAL.getIdentityById({scopeData: {scope: AccessScope.Organization,@@ -409,6 +407,8 @@ export const identityLdapAuthServiceFactory = ({);}+ await validateIdentityUpdateForSuperAdminPrivileges(identityId, isActorSuperAdmin);+const plan = await licenseService.getPlan(identityMembershipOrg.scopeOrgId);if (!plan.ldap) {@@ -547,8 +547,6 @@ export const identityLdapAuthServiceFactory = ({lockoutCounterResetSeconds,isActorSuperAdmin}: TUpdateLdapAuthDTO) => {- await validateIdentityUpdateForSuperAdminPrivileges(identityId, isActorSuperAdmin);-const identityMembershipOrg = await membershipIdentityDAL.getIdentityById({scopeData: {scope: AccessScope.Organization,@@ -617,6 +615,8 @@ export const identityLdapAuthServiceFactory = ({);}+ await validateIdentityUpdateForSuperAdminPrivileges(identityId, isActorSuperAdmin);+const plan = await licenseService.getPlan(identityMembershipOrg.scopeOrgId);if (!plan.ldap) {@@ -809,8 +809,6 @@ export const identityLdapAuthServiceFactory = ({actorOrgId,isActorSuperAdmin}: TRevokeLdapAuthDTO) => {- await validateIdentityUpdateForSuperAdminPrivileges(identityId, isActorSuperAdmin);-const identityMembershipOrg = await membershipIdentityDAL.getIdentityById({scopeData: {scope: AccessScope.Organization,@@ -822,6 +820,7 @@ export const identityLdapAuthServiceFactory = ({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)) {throw new BadRequestError({message: "The identity does not have LDAP Auth attached"@@ -886,6 +885,8 @@ export const identityLdapAuthServiceFactory = ({});}+ await validateIdentityUpdateForSuperAdminPrivileges(identityId, isActorSuperAdmin);+const revokedIdentityLdapAuth = await identityLdapAuthDAL.transaction(async (tx) => {const [deletedLdapAuth] = await identityLdapAuthDAL.delete({ identityId }, tx);await identityAccessTokenDAL.delete({ identityId, authMethod: IdentityAuthMethod.LDAP_AUTH }, tx);@@ -1029,6 +1030,10 @@ export const identityLdapAuthServiceFactory = ({});if (!identityMembershipOrg) throw new NotFoundError({ message: `Failed to find identity with ID ${identityId}` });+ 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)) {throw new BadRequestError({message: "The identity does not have 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 a29855998c..b5fb8170ac 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@@ -284,8 +284,6 @@ export const identityOciAuthServiceFactory = ({actorOrgId,isActorSuperAdmin}: TAttachOciAuthDTO) => {- await validateIdentityUpdateForSuperAdminPrivileges(identityId, isActorSuperAdmin);-const identityMembershipOrg = await membershipIdentityDAL.getIdentityById({scopeData: {scope: AccessScope.Organization,@@ -337,6 +335,8 @@ export const identityOciAuthServiceFactory = ({);}+ await validateIdentityUpdateForSuperAdminPrivileges(identityId, isActorSuperAdmin);+const plan = await licenseService.getPlan(identityMembershipOrg.scopeOrgId);const reformattedAccessTokenTrustedIps = accessTokenTrustedIps.map((accessTokenTrustedIp) => {if (@@ -389,8 +389,6 @@ export const identityOciAuthServiceFactory = ({actorOrgId,isActorSuperAdmin}: TUpdateOciAuthDTO) => {- await validateIdentityUpdateForSuperAdminPrivileges(identityId, isActorSuperAdmin);-const identityMembershipOrg = await membershipIdentityDAL.getIdentityById({scopeData: {scope: AccessScope.Organization,@@ -447,6 +445,8 @@ export const identityOciAuthServiceFactory = ({);}+ await validateIdentityUpdateForSuperAdminPrivileges(identityId, isActorSuperAdmin);+const plan = await licenseService.getPlan(identityMembershipOrg.scopeOrgId);const reformattedAccessTokenTrustedIps = accessTokenTrustedIps?.map((accessTokenTrustedIp) => {if (@@ -537,8 +537,6 @@ export const identityOciAuthServiceFactory = ({actorOrgId,isActorSuperAdmin}: TRevokeOciAuthDTO) => {- await validateIdentityUpdateForSuperAdminPrivileges(identityId, isActorSuperAdmin);-const identityMembershipOrg = await membershipIdentityDAL.getIdentityById({scopeData: {scope: AccessScope.Organization,@@ -550,6 +548,7 @@ export const identityOciAuthServiceFactory = ({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)) {throw new BadRequestError({message: "The identity does not have OCI auth"@@ -613,6 +612,8 @@ export const identityOciAuthServiceFactory = ({});}+ await validateIdentityUpdateForSuperAdminPrivileges(identityId, isActorSuperAdmin);+const revokedIdentityOciAuth = await identityOciAuthDAL.transaction(async (tx) => {const deletedOciAuth = await identityOciAuthDAL.delete({ identityId }, tx);await identityAccessTokenDAL.delete({ identityId, authMethod: IdentityAuthMethod.OCI_AUTH }, tx);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 c075f49a1c..822a86996b 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@@ -609,7 +609,6 @@ export const identityOidcAuthServiceFactory = ({actorOrgId,isActorSuperAdmin}: TAttachOidcAuthDTO) => {- await validateIdentityUpdateForSuperAdminPrivileges(identityId, isActorSuperAdmin);const identityMembershipOrg = await membershipIdentityDAL.getIdentityById({scopeData: {scope: AccessScope.Organization,@@ -623,6 +622,7 @@ export const identityOidcAuthServiceFactory = ({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)) {throw new BadRequestError({message: "Failed to add OIDC Auth to already configured identity"@@ -663,6 +663,8 @@ export const identityOidcAuthServiceFactory = ({);}+ await validateIdentityUpdateForSuperAdminPrivileges(identityId, isActorSuperAdmin);+const plan = await licenseService.getPlan(identityMembershipOrg.scopeOrgId);const reformattedAccessTokenTrustedIps = accessTokenTrustedIps.map((accessTokenTrustedIp) => {if (@@ -731,8 +733,6 @@ export const identityOidcAuthServiceFactory = ({actorOrgId,isActorSuperAdmin}: TUpdateOidcAuthDTO) => {- await validateIdentityUpdateForSuperAdminPrivileges(identityId, isActorSuperAdmin);-const identityMembershipOrg = await membershipIdentityDAL.getIdentityById({scopeData: {scope: AccessScope.Organization,@@ -790,6 +790,8 @@ export const identityOidcAuthServiceFactory = ({);}+ await validateIdentityUpdateForSuperAdminPrivileges(identityId, isActorSuperAdmin);+const plan = await licenseService.getPlan(identityMembershipOrg.scopeOrgId);const reformattedAccessTokenTrustedIps = accessTokenTrustedIps?.map((accessTokenTrustedIp) => {if (@@ -916,8 +918,6 @@ export const identityOidcAuthServiceFactory = ({actorOrgId,isActorSuperAdmin}: TRevokeOidcAuthDTO) => {- await validateIdentityUpdateForSuperAdminPrivileges(identityId, isActorSuperAdmin);-const identityMembershipOrg = await membershipIdentityDAL.getIdentityById({scopeData: {scope: AccessScope.Organization,@@ -997,6 +997,8 @@ export const identityOidcAuthServiceFactory = ({});}+ await validateIdentityUpdateForSuperAdminPrivileges(identityId, isActorSuperAdmin);+const revokedIdentityOidcAuth = await identityOidcAuthDAL.transaction(async (tx) => {const deletedOidcAuth = await identityOidcAuthDAL.delete({ identityId }, tx);await identityAccessTokenDAL.delete({ identityId, authMethod: IdentityAuthMethod.OIDC_AUTH }, tx);diff --git a/backend/src/services/identity-spiffe-auth/identity-spiffe-auth-service.ts b/backend/src/services/identity-spiffe-auth/identity-spiffe-auth-service.tsindex 79a29c8f15..7bf5670104 100644--- a/backend/src/services/identity-spiffe-auth/identity-spiffe-auth-service.ts+++ b/backend/src/services/identity-spiffe-auth/identity-spiffe-auth-service.ts@@ -510,8 +510,6 @@ export const identitySpiffeAuthServiceFactory = ({actorOrgId,isActorSuperAdmin}: TAttachSpiffeAuthDTO) => {- await validateIdentityUpdateForSuperAdminPrivileges(identityId, isActorSuperAdmin);-const identityMembershipOrg = await membershipIdentityDAL.getIdentityById({scopeData: {scope: AccessScope.Organization,@@ -523,6 +521,7 @@ export const identitySpiffeAuthServiceFactory = ({if (identityMembershipOrg.identity.orgId !== actorOrgId) {throw new ForbiddenRequestError({ message: "Sub organization not authorized to access this identity" });}+if (identityMembershipOrg.identity.authMethods.includes(IdentityAuthMethod.SPIFFE_AUTH)) {throw new BadRequestError({message: "Failed to add SPIFFE Auth to already configured identity"@@ -563,6 +562,8 @@ export const identitySpiffeAuthServiceFactory = ({);}+ await validateIdentityUpdateForSuperAdminPrivileges(identityId, isActorSuperAdmin);+const plan = await licenseService.getPlan(identityMembershipOrg.scopeOrgId);const reformattedAccessTokenTrustedIps = accessTokenTrustedIps.map((accessTokenTrustedIp) => {if (@@ -653,8 +654,6 @@ export const identitySpiffeAuthServiceFactory = ({actorOrgId,isActorSuperAdmin}: TUpdateSpiffeAuthDTO) => {- await validateIdentityUpdateForSuperAdminPrivileges(identityId, isActorSuperAdmin);-const identityMembershipOrg = await membershipIdentityDAL.getIdentityById({scopeData: {scope: AccessScope.Organization,@@ -711,6 +710,8 @@ export const identitySpiffeAuthServiceFactory = ({);}+ await validateIdentityUpdateForSuperAdminPrivileges(identityId, isActorSuperAdmin);+const plan = await licenseService.getPlan(identityMembershipOrg.scopeOrgId);const reformattedAccessTokenTrustedIps = accessTokenTrustedIps?.map((accessTokenTrustedIp) => {if (@@ -865,8 +866,6 @@ export const identitySpiffeAuthServiceFactory = ({actorOrgId,isActorSuperAdmin}: TRevokeSpiffeAuthDTO) => {- await validateIdentityUpdateForSuperAdminPrivileges(identityId, isActorSuperAdmin);-const identityMembershipOrg = await membershipIdentityDAL.getIdentityById({scopeData: {scope: AccessScope.Organization,@@ -943,6 +942,8 @@ export const identitySpiffeAuthServiceFactory = ({});}+ await validateIdentityUpdateForSuperAdminPrivileges(identityId, isActorSuperAdmin);+const revokedIdentitySpiffeAuth = await identitySpiffeAuthDAL.transaction(async (tx) => {const deletedSpiffeAuth = await identitySpiffeAuthDAL.delete({ identityId }, tx);await identityAccessTokenDAL.delete({ identityId, authMethod: IdentityAuthMethod.SPIFFE_AUTH }, tx);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 9a27bb9c66..6796b87f93 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@@ -395,8 +395,6 @@ export const identityTlsCertAuthServiceFactory = ({allowedSubjectAltNames,verifyClientCertificateChain: verifyClientCertificateChainOpt}) => {- await validateIdentityUpdateForSuperAdminPrivileges(identityId, isActorSuperAdmin);-const identityMembershipOrg = await membershipIdentityDAL.getIdentityById({scopeData: {scope: AccessScope.Organization,@@ -448,6 +446,8 @@ export const identityTlsCertAuthServiceFactory = ({);}+ await validateIdentityUpdateForSuperAdminPrivileges(identityId, isActorSuperAdmin);+const plan = await licenseService.getPlan(identityMembershipOrg.scopeOrgId);const reformattedAccessTokenTrustedIps = accessTokenTrustedIps.map((accessTokenTrustedIp) => {if (@@ -508,8 +508,6 @@ export const identityTlsCertAuthServiceFactory = ({actorOrgId,isActorSuperAdmin}) => {- await validateIdentityUpdateForSuperAdminPrivileges(identityId, isActorSuperAdmin);-const identityMembershipOrg = await membershipIdentityDAL.getIdentityById({scopeData: {scope: AccessScope.Organization,@@ -567,6 +565,8 @@ export const identityTlsCertAuthServiceFactory = ({);}+ await validateIdentityUpdateForSuperAdminPrivileges(identityId, isActorSuperAdmin);+const plan = await licenseService.getPlan(identityMembershipOrg.scopeOrgId);const reformattedAccessTokenTrustedIps = accessTokenTrustedIps?.map((accessTokenTrustedIp) => {if (@@ -681,8 +681,6 @@ export const identityTlsCertAuthServiceFactory = ({actorOrgId,isActorSuperAdmin}) => {- await validateIdentityUpdateForSuperAdminPrivileges(identityId, isActorSuperAdmin);-const identityMembershipOrg = await membershipIdentityDAL.getIdentityById({scopeData: {scope: AccessScope.Organization,@@ -694,6 +692,7 @@ export const identityTlsCertAuthServiceFactory = ({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)) {throw new BadRequestError({message: "The identity does not have TLS Certificate auth"@@ -754,6 +753,8 @@ export const identityTlsCertAuthServiceFactory = ({});}+ await validateIdentityUpdateForSuperAdminPrivileges(identityId, isActorSuperAdmin);+const revokedIdentityTlsCertAuth = await identityTlsCertAuthDAL.transaction(async (tx) => {const deletedTlsCertAuth = await identityTlsCertAuthDAL.delete({ identityId }, tx);await identityAccessTokenDAL.delete({ identityId, authMethod: IdentityAuthMethod.TLS_CERT_AUTH }, tx);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 a4d59d7665..c5eb38c4d0 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@@ -91,8 +91,6 @@ export const identityTokenAuthServiceFactory = ({actorOrgId,isActorSuperAdmin}: TAttachTokenAuthDTO) => {- await validateIdentityUpdateForSuperAdminPrivileges(identityId, isActorSuperAdmin);-const identityMembershipOrg = await membershipIdentityDAL.getIdentityById({scopeData: {scope: AccessScope.Organization,@@ -144,6 +142,8 @@ export const identityTokenAuthServiceFactory = ({);}+ await validateIdentityUpdateForSuperAdminPrivileges(identityId, isActorSuperAdmin);+const plan = await licenseService.getPlan(identityMembershipOrg.scopeOrgId);const reformattedAccessTokenTrustedIps = accessTokenTrustedIps.map((accessTokenTrustedIp) => {if (@@ -191,8 +191,6 @@ export const identityTokenAuthServiceFactory = ({actorOrgId,isActorSuperAdmin}: TUpdateTokenAuthDTO) => {- await validateIdentityUpdateForSuperAdminPrivileges(identityId, isActorSuperAdmin);-const identityMembershipOrg = await membershipIdentityDAL.getIdentityById({scopeData: {scope: AccessScope.Organization,@@ -250,6 +248,8 @@ export const identityTokenAuthServiceFactory = ({);}+ await validateIdentityUpdateForSuperAdminPrivileges(identityId, isActorSuperAdmin);+const plan = await licenseService.getPlan(identityMembershipOrg.scopeOrgId);const reformattedAccessTokenTrustedIps = accessTokenTrustedIps?.map((accessTokenTrustedIp) => {if (@@ -342,8 +342,6 @@ export const identityTokenAuthServiceFactory = ({actorOrgId,isActorSuperAdmin}: TRevokeTokenAuthDTO) => {- await validateIdentityUpdateForSuperAdminPrivileges(identityId, isActorSuperAdmin);-const identityMembershipOrg = await membershipIdentityDAL.getIdentityById({scopeData: {scope: AccessScope.Organization,@@ -419,6 +417,8 @@ export const identityTokenAuthServiceFactory = ({});}+ await validateIdentityUpdateForSuperAdminPrivileges(identityId, isActorSuperAdmin);+const revokedIdentityTokenAuth = await identityTokenAuthDAL.transaction(async (tx) => {const deletedTokenAuth = await identityTokenAuthDAL.delete({ identityId }, tx);await identityAccessTokenDAL.delete({@@ -451,8 +451,6 @@ export const identityTokenAuthServiceFactory = ({isActorSuperAdmin,organizationSlug}: TCreateTokenAuthTokenDTO) => {- await validateIdentityUpdateForSuperAdminPrivileges(identityId, isActorSuperAdmin);-const identityMembershipOrg = await membershipIdentityDAL.getIdentityById({scopeData: {scope: AccessScope.Organization,@@ -529,6 +527,8 @@ export const identityTokenAuthServiceFactory = ({});}+ await validateIdentityUpdateForSuperAdminPrivileges(identityId, isActorSuperAdmin);+const identityTokenAuth = await identityTokenAuthDAL.findOne({ identityId });const { identity } = identityMembershipOrg;@@ -624,8 +624,6 @@ export const identityTokenAuthServiceFactory = ({actorOrgId,isActorSuperAdmin}: TGetTokenAuthTokensDTO) => {- await validateIdentityUpdateForSuperAdminPrivileges(identityId, isActorSuperAdmin);-const identityMembershipOrg = await membershipIdentityDAL.getIdentityById({scopeData: {scope: AccessScope.Organization,@@ -635,6 +633,10 @@ export const identityTokenAuthServiceFactory = ({});if (!identityMembershipOrg) throw new NotFoundError({ message: `Failed to find identity with ID ${identityId}` });+ if (identityMembershipOrg.identity.orgId !== actorOrgId) {+ throw new ForbiddenRequestError({ message: "Sub organization not authorized to access this identity" });+ }+if (!identityMembershipOrg.identity.authMethods.includes(IdentityAuthMethod.TOKEN_AUTH)) {throw new BadRequestError({message: "The identity does not have Token Auth"@@ -667,6 +669,8 @@ export const identityTokenAuthServiceFactory = ({ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Read, OrgPermissionSubjects.Identity);}+ await validateIdentityUpdateForSuperAdminPrivileges(identityId, isActorSuperAdmin);+const tokens = await identityAccessTokenDAL.find({identityId,@@ -702,6 +706,10 @@ export const identityTokenAuthServiceFactory = ({throw new NotFoundError({ message: `Failed to find identity with ID ${foundToken.identityId}` });}+ if (identityMembershipOrg.identity.orgId !== actorOrgId) {+ throw new ForbiddenRequestError({ message: "Sub organization not authorized to access this identity" });+ }+if (!identityMembershipOrg.identity.authMethods.includes(IdentityAuthMethod.TOKEN_AUTH)) {throw new BadRequestError({message: "The identity does not have Token Auth"@@ -763,7 +771,10 @@ export const identityTokenAuthServiceFactory = ({throw new NotFoundError({ message: `Failed to find identity with ID ${foundToken.identityId}` });}- await validateIdentityUpdateForSuperAdminPrivileges(foundToken.identityId, isActorSuperAdmin);+ if (identityMembershipOrg.identity.orgId !== actorOrgId) {+ throw new ForbiddenRequestError({ message: "Sub organization not authorized to access this identity" });+ }+if (!identityMembershipOrg.identity.authMethods.includes(IdentityAuthMethod.TOKEN_AUTH)) {throw new BadRequestError({message: "The identity does not have Token Auth"@@ -826,6 +837,8 @@ export const identityTokenAuthServiceFactory = ({});}+ await validateIdentityUpdateForSuperAdminPrivileges(foundToken.identityId, isActorSuperAdmin);+const [token] = await identityAccessTokenDAL.update({authMethod: IdentityAuthMethod.TOKEN_AUTH,@@ -859,8 +872,6 @@ export const identityTokenAuthServiceFactory = ({message: `Token with ID ${tokenId} not found or already revoked`});- await validateIdentityUpdateForSuperAdminPrivileges(identityAccessToken.identityId, isActorSuperAdmin);-const identityOrgMembership = await membershipIdentityDAL.getIdentityById({scopeData: {scope: AccessScope.Organization,@@ -873,6 +884,10 @@ export const identityTokenAuthServiceFactory = ({throw new NotFoundError({ message: `Failed to find identity with ID ${identityAccessToken.identityId}` });}+ if (identityOrgMembership.identity.orgId !== actorOrgId) {+ throw new ForbiddenRequestError({ message: "Sub organization not authorized to access this identity" });+ }+if (identityOrgMembership.identity.projectId) {const { permission } = await permissionService.getProjectPermission({actionProjectType: ActionProjectType.Any,@@ -899,6 +914,8 @@ export const identityTokenAuthServiceFactory = ({ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Edit, OrgPermissionSubjects.Identity);}+ await validateIdentityUpdateForSuperAdminPrivileges(identityAccessToken.identityId, isActorSuperAdmin);+const [revokedToken] = await identityAccessTokenDAL.update({id: identityAccessToken.id,diff --git a/backend/src/services/identity-ua/identity-ua-service.ts b/backend/src/services/identity-ua/identity-ua-service.tsindex 205aad0cf2..eb3635f5f6 100644--- a/backend/src/services/identity-ua/identity-ua-service.ts+++ b/backend/src/services/identity-ua/identity-ua-service.ts@@ -446,8 +446,6 @@ export const identityUaServiceFactory = ({lockoutDurationSeconds,lockoutCounterResetSeconds}: TAttachUaDTO) => {- await validateIdentityUpdateForSuperAdminPrivileges(identityId, isActorSuperAdmin);-const identityMembershipOrg = await membershipIdentityDAL.getIdentityById({scopeData: {scope: AccessScope.Organization,@@ -500,6 +498,8 @@ export const identityUaServiceFactory = ({);}+ await validateIdentityUpdateForSuperAdminPrivileges(identityId, isActorSuperAdmin);+const plan = await licenseService.getPlan(identityMembershipOrg.scopeOrgId);const reformattedClientSecretTrustedIps = clientSecretTrustedIps.map((clientSecretTrustedIp) => {if (@@ -579,8 +579,6 @@ export const identityUaServiceFactory = ({lockoutCounterResetSeconds,isActorSuperAdmin}: TUpdateUaDTO) => {- await validateIdentityUpdateForSuperAdminPrivileges(identityId, isActorSuperAdmin);-const identityMembershipOrg = await membershipIdentityDAL.getIdentityById({scopeData: {scope: AccessScope.Organization,@@ -641,6 +639,8 @@ export const identityUaServiceFactory = ({);}+ await validateIdentityUpdateForSuperAdminPrivileges(identityId, isActorSuperAdmin);+const plan = await licenseService.getPlan(identityMembershipOrg.scopeOrgId);const reformattedClientSecretTrustedIps = clientSecretTrustedIps?.map((clientSecretTrustedIp) => {if (@@ -755,8 +755,6 @@ export const identityUaServiceFactory = ({actorOrgId,isActorSuperAdmin}: TRevokeUaDTO) => {- await validateIdentityUpdateForSuperAdminPrivileges(identityId, isActorSuperAdmin);-const identityMembershipOrg = await membershipIdentityDAL.getIdentityById({scopeData: {scope: AccessScope.Organization,@@ -830,6 +828,8 @@ export const identityUaServiceFactory = ({details: { missingPermissions: permissionBoundary.missingPermissions }});}++ await validateIdentityUpdateForSuperAdminPrivileges(identityId, isActorSuperAdmin);const revokedIdentityUniversalAuth = await identityUaDAL.transaction(async (tx) => {const deletedUniversalAuth = await identityUaDAL.delete({ identityId }, tx);return { ...deletedUniversalAuth?.[0], orgId: identityMembershipOrg.scopeOrgId };diff --git a/backend/src/services/identity/identity-service.ts b/backend/src/services/identity/identity-service.tsindex 0faad55880..a81f8f5ab4 100644--- a/backend/src/services/identity/identity-service.ts+++ b/backend/src/services/identity/identity-service.ts@@ -213,8 +213,6 @@ export const identityServiceFactory = ({metadata,isActorSuperAdmin}: TUpdateIdentityDTO) => {- await validateIdentityUpdateForSuperAdminPrivileges(id, isActorSuperAdmin);-const identityOrgMembership = await orgDAL.findEffectiveOrgMembership({actorType: ActorType.IDENTITY,actorId: id,@@ -269,6 +267,8 @@ export const identityServiceFactory = ({if (isCustomRole) customRole = rolePermissionDetails?.role;}+ await validateIdentityUpdateForSuperAdminPrivileges(id, isActorSuperAdmin);+const identityDetails = await requestMemoize(requestMemoKeys.identityFindById(id), () => identityDAL.findById(id));if (identityDetails.projectId) {@@ -357,7 +357,6 @@ export const identityServiceFactory = ({id,isActorSuperAdmin}: TDeleteIdentityDTO) => {- await validateIdentityUpdateForSuperAdminPrivileges(id, isActorSuperAdmin);const identityOrgMembership = await membershipIdentityDAL.getIdentityById({scopeData: {scope: AccessScope.Organization,@@ -378,6 +377,8 @@ export const identityServiceFactory = ({ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Delete, OrgPermissionSubjects.Identity);+ await validateIdentityUpdateForSuperAdminPrivileges(id, isActorSuperAdmin);+if (identityOrgMembership.identity.projectId) {throw new BadRequestError({ message: `Identity is managed by project` });}