Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

fix(PLATFOR-359): scope auth-method removal to only revoke that method's tokens

Tre Dubrava9250ab5ff652
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.ts
index cbeb029e54..bb0c91e244 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
@@ -58,7 +58,7 @@ type TIdentityAliCloudAuthServiceFactoryDep = {
orgDAL: Pick<TOrgDALFactory, "findById" | "findOne" | "findEffectiveOrgMembership">;
identityAccessTokenService: Pick<
TIdentityAccessTokenServiceFactory,
- "issueIdentityAccessToken" | "revokeAllTokensForIdentity"
+ "issueIdentityAccessToken" | "revokeTokensForIdentityAuthMethod"
>;
};
@@ -575,7 +575,10 @@ export const identityAliCloudAuthServiceFactory = ({
// Detaching the auth method must invalidate any tokens already issued
// through it; without this, leaked tokens authenticate up to MAX_AGE
// even after the admin pulled the auth method.
- await identityAccessTokenService.revokeAllTokensForIdentity(identityId);
+ await identityAccessTokenService.revokeTokensForIdentityAuthMethod({
+ identityId,
+ authMethod: IdentityAuthMethod.ALICLOUD_AUTH
+ });
return revokedIdentityAliCloudAuth;
};
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.ts
index 6dbcbcf209..87dc278c9f 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
@@ -58,7 +58,7 @@ type TIdentityAwsAuthServiceFactoryDep = {
orgDAL: Pick<TOrgDALFactory, "findById" | "findOne" | "findEffectiveOrgMembership">;
identityAccessTokenService: Pick<
TIdentityAccessTokenServiceFactory,
- "issueIdentityAccessToken" | "revokeAllTokensForIdentity"
+ "issueIdentityAccessToken" | "revokeTokensForIdentityAuthMethod"
>;
};
@@ -677,7 +677,10 @@ export const identityAwsAuthServiceFactory = ({
// Detaching the auth method must invalidate any tokens already issued
// through it; without this, leaked tokens authenticate up to MAX_AGE
// even after the admin pulled the auth method.
- await identityAccessTokenService.revokeAllTokensForIdentity(identityId);
+ await identityAccessTokenService.revokeTokensForIdentityAuthMethod({
+ identityId,
+ authMethod: IdentityAuthMethod.AWS_AUTH
+ });
return revokedIdentityAwsAuth;
};
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.ts
index ee240a2218..684ba7e325 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
@@ -54,7 +54,7 @@ type TIdentityAzureAuthServiceFactoryDep = {
orgDAL: Pick<TOrgDALFactory, "findById" | "findOne" | "findEffectiveOrgMembership">;
identityAccessTokenService: Pick<
TIdentityAccessTokenServiceFactory,
- "issueIdentityAccessToken" | "revokeAllTokensForIdentity"
+ "issueIdentityAccessToken" | "revokeTokensForIdentityAuthMethod"
>;
};
@@ -578,7 +578,10 @@ export const identityAzureAuthServiceFactory = ({
// Detaching the auth method must invalidate any tokens already issued
// through it; without this, leaked tokens authenticate up to MAX_AGE
// even after the admin pulled the auth method.
- await identityAccessTokenService.revokeAllTokensForIdentity(identityId);
+ await identityAccessTokenService.revokeTokensForIdentityAuthMethod({
+ identityId,
+ authMethod: IdentityAuthMethod.AZURE_AUTH
+ });
return revokedIdentityAzureAuth;
};
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.ts
index 421528c208..67c550a1f7 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
@@ -52,7 +52,7 @@ type TIdentityGcpAuthServiceFactoryDep = {
orgDAL: Pick<TOrgDALFactory, "findById" | "findOne" | "findEffectiveOrgMembership">;
identityAccessTokenService: Pick<
TIdentityAccessTokenServiceFactory,
- "issueIdentityAccessToken" | "revokeAllTokensForIdentity"
+ "issueIdentityAccessToken" | "revokeTokensForIdentityAuthMethod"
>;
};
@@ -627,7 +627,10 @@ export const identityGcpAuthServiceFactory = ({
// Detaching the auth method must invalidate any tokens already issued
// through it; without this, leaked tokens authenticate up to MAX_AGE
// even after the admin pulled the auth method.
- await identityAccessTokenService.revokeAllTokensForIdentity(identityId);
+ await identityAccessTokenService.revokeTokensForIdentityAuthMethod({
+ identityId,
+ authMethod: IdentityAuthMethod.GCP_AUTH
+ });
return revokedIdentityGcpAuth;
};
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.ts
index 60b014bb94..e71325f9e3 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
@@ -67,7 +67,7 @@ type TIdentityJwtAuthServiceFactoryDep = {
orgDAL: Pick<TOrgDALFactory, "findById" | "findOne" | "findEffectiveOrgMembership">;
identityAccessTokenService: Pick<
TIdentityAccessTokenServiceFactory,
- "issueIdentityAccessToken" | "revokeAllTokensForIdentity"
+ "issueIdentityAccessToken" | "revokeTokensForIdentityAuthMethod"
>;
};
@@ -826,7 +826,10 @@ export const identityJwtAuthServiceFactory = ({
// Detaching the auth method must invalidate any tokens already issued
// through it; without this, leaked tokens authenticate up to MAX_AGE
// even after the admin pulled the auth method.
- await identityAccessTokenService.revokeAllTokensForIdentity(identityId);
+ await identityAccessTokenService.revokeTokensForIdentityAuthMethod({
+ identityId,
+ authMethod: IdentityAuthMethod.JWT_AUTH
+ });
return revokedIdentityJwtAuth;
};
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.ts
index 08641260da..2275bcca0e 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
@@ -99,7 +99,7 @@ type TIdentityKubernetesAuthServiceFactoryDep = {
orgDAL: Pick<TOrgDALFactory, "findById" | "findOne" | "findEffectiveOrgMembership">;
identityAccessTokenService: Pick<
TIdentityAccessTokenServiceFactory,
- "issueIdentityAccessToken" | "revokeAllTokensForIdentity"
+ "issueIdentityAccessToken" | "revokeTokensForIdentityAuthMethod"
>;
};
@@ -1552,7 +1552,10 @@ export const identityKubernetesAuthServiceFactory = ({
// Detaching the auth method must invalidate any tokens already issued
// through it; without this, leaked tokens authenticate up to MAX_AGE
// even after the admin pulled the auth method.
- await identityAccessTokenService.revokeAllTokensForIdentity(identityId);
+ await identityAccessTokenService.revokeTokensForIdentityAuthMethod({
+ identityId,
+ authMethod: IdentityAuthMethod.KUBERNETES_AUTH
+ });
return revokedIdentityKubernetesAuth;
};
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.ts
index 2c5f1ade82..5816699821 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
@@ -76,7 +76,7 @@ type TIdentityLdapAuthServiceFactoryDep = {
orgDAL: Pick<TOrgDALFactory, "findById" | "findOne" | "findEffectiveOrgMembership">;
identityAccessTokenService: Pick<
TIdentityAccessTokenServiceFactory,
- "issueIdentityAccessToken" | "revokeAllTokensForIdentity"
+ "issueIdentityAccessToken" | "revokeTokensForIdentityAuthMethod"
>;
};
@@ -867,7 +867,10 @@ export const identityLdapAuthServiceFactory = ({
// Detaching the auth method must invalidate any tokens already issued
// through it; without this, leaked tokens authenticate up to MAX_AGE
// even after the admin pulled the auth method.
- await identityAccessTokenService.revokeAllTokensForIdentity(identityId);
+ await identityAccessTokenService.revokeTokensForIdentityAuthMethod({
+ identityId,
+ authMethod: IdentityAuthMethod.LDAP_AUTH
+ });
return revokedIdentityLdapAuth;
};
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.ts
index bc432609a4..62f3665d87 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
@@ -56,7 +56,7 @@ type TIdentityOciAuthServiceFactoryDep = {
orgDAL: Pick<TOrgDALFactory, "findById" | "findOne" | "findEffectiveOrgMembership">;
identityAccessTokenService: Pick<
TIdentityAccessTokenServiceFactory,
- "issueIdentityAccessToken" | "revokeAllTokensForIdentity"
+ "issueIdentityAccessToken" | "revokeTokensForIdentityAuthMethod"
>;
};
@@ -591,7 +591,10 @@ export const identityOciAuthServiceFactory = ({
// Detaching the auth method must invalidate any tokens already issued
// through it; without this, leaked tokens authenticate up to MAX_AGE
// even after the admin pulled the auth method.
- await identityAccessTokenService.revokeAllTokensForIdentity(identityId);
+ await identityAccessTokenService.revokeTokensForIdentityAuthMethod({
+ identityId,
+ authMethod: IdentityAuthMethod.OCI_AUTH
+ });
return revokedIdentityOciAuth;
};
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.ts
index 4cb7e2a9a8..ebb2d19dff 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
@@ -68,7 +68,7 @@ type TIdentityOidcAuthServiceFactoryDep = {
orgDAL: Pick<TOrgDALFactory, "findById" | "findOne" | "findEffectiveOrgMembership">;
identityAccessTokenService: Pick<
TIdentityAccessTokenServiceFactory,
- "issueIdentityAccessToken" | "revokeAllTokensForIdentity"
+ "issueIdentityAccessToken" | "revokeTokensForIdentityAuthMethod"
>;
};
@@ -969,7 +969,10 @@ export const identityOidcAuthServiceFactory = ({
// Detaching the auth method must invalidate any tokens already issued
// through it; without this, leaked tokens authenticate up to MAX_AGE
// even after the admin pulled the auth method.
- await identityAccessTokenService.revokeAllTokensForIdentity(identityId);
+ await identityAccessTokenService.revokeTokensForIdentityAuthMethod({
+ identityId,
+ authMethod: IdentityAuthMethod.OIDC_AUTH
+ });
return revokedIdentityOidcAuth;
};
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.ts
index d4b5a02afd..5418a813ea 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
@@ -73,7 +73,7 @@ type TIdentitySpiffeAuthServiceFactoryDep = {
orgDAL: Pick<TOrgDALFactory, "findById" | "findOne" | "findEffectiveOrgMembership">;
identityAccessTokenService: Pick<
TIdentityAccessTokenServiceFactory,
- "issueIdentityAccessToken" | "revokeAllTokensForIdentity"
+ "issueIdentityAccessToken" | "revokeTokensForIdentityAuthMethod"
>;
};
@@ -921,7 +921,10 @@ export const identitySpiffeAuthServiceFactory = ({
// Detaching the auth method must invalidate any tokens already issued
// through it; without this, leaked tokens authenticate up to MAX_AGE
// even after the admin pulled the auth method.
- await identityAccessTokenService.revokeAllTokensForIdentity(identityId);
+ await identityAccessTokenService.revokeTokensForIdentityAuthMethod({
+ identityId,
+ authMethod: IdentityAuthMethod.SPIFFE_AUTH
+ });
const { decryptor: orgDataKeyDecryptor } = await kmsService.createCipherPairWithDataKey({
type: KmsDataKey.Organization,
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.ts
index d55528a652..35358d22bf 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
@@ -52,7 +52,7 @@ type TIdentityTlsCertAuthServiceFactoryDep = {
orgDAL: Pick<TOrgDALFactory, "findById" | "findOne" | "findEffectiveOrgMembership">;
identityAccessTokenService: Pick<
TIdentityAccessTokenServiceFactory,
- "issueIdentityAccessToken" | "revokeAllTokensForIdentity"
+ "issueIdentityAccessToken" | "revokeTokensForIdentityAuthMethod"
>;
};
@@ -654,7 +654,10 @@ export const identityTlsCertAuthServiceFactory = ({
// Detaching the auth method must invalidate any tokens already issued
// through it; without this, leaked tokens authenticate up to MAX_AGE
// even after the admin pulled the auth method.
- await identityAccessTokenService.revokeAllTokensForIdentity(identityId);
+ await identityAccessTokenService.revokeTokensForIdentityAuthMethod({
+ identityId,
+ authMethod: IdentityAuthMethod.TLS_CERT_AUTH
+ });
return revokedIdentityTlsCertAuth;
};
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.ts
index 0e5abfa0ac..ec71a9c3f1 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
@@ -58,7 +58,7 @@ type TIdentityTokenAuthServiceFactoryDep = {
>;
identityAccessTokenService: Pick<
TIdentityAccessTokenServiceFactory,
- "issueIdentityAccessToken" | "revokeAllTokensForIdentity" | "markPerTokenRevocation"
+ "issueIdentityAccessToken" | "revokeTokensForIdentityAuthMethod" | "markPerTokenRevocation"
>;
permissionService: Pick<TPermissionServiceFactory, "getOrgPermission" | "getProjectPermission">;
licenseService: Pick<TLicenseServiceFactory, "getPlan">;
@@ -424,7 +424,10 @@ export const identityTokenAuthServiceFactory = ({
// Detaching the auth method must invalidate any tokens already issued
// through it; without this, leaked tokens authenticate up to MAX_AGE
// even after the admin pulled the auth method.
- await identityAccessTokenService.revokeAllTokensForIdentity(identityId);
+ await identityAccessTokenService.revokeTokensForIdentityAuthMethod({
+ identityId,
+ authMethod: IdentityAuthMethod.TOKEN_AUTH
+ });
return revokedIdentityTokenAuth;
};
diff --git a/backend/src/services/identity-ua/identity-ua-service.ts b/backend/src/services/identity-ua/identity-ua-service.ts
index 0a793ff573..babc162ac2 100644
--- a/backend/src/services/identity-ua/identity-ua-service.ts
+++ b/backend/src/services/identity-ua/identity-ua-service.ts
@@ -59,7 +59,7 @@ type TIdentityUaServiceFactoryDep = {
orgDAL: Pick<TOrgDALFactory, "findById" | "findOne" | "findEffectiveOrgMembership">;
identityAccessTokenService: Pick<
TIdentityAccessTokenServiceFactory,
- "issueIdentityAccessToken" | "revokeAllTokensForIdentity" | "revokeAllTokensForClientSecret"
+ "issueIdentityAccessToken" | "revokeTokensForIdentityAuthMethod" | "revokeAllTokensForClientSecret"
>;
keyStore: Pick<
TKeyStoreFactory,
@@ -775,13 +775,13 @@ export const identityUaServiceFactory = ({
return { ...deletedUniversalAuth?.[0], orgId: identityMembershipOrg.scopeOrgId };
});
- // Revoking the auth method must invalidate any access tokens already
- // issued via it — without this, leaked tokens keep authenticating up
- // to MAX_MACHINE_IDENTITY_TOKEN_AGE even after an admin pulled the
- // method. The marker is identity-wide (matches the existing semantics
- // of identity deletion) which is acceptable here because detaching an
- // auth method is a high-trust admin action.
- await identityAccessTokenService.revokeAllTokensForIdentity(identityId);
+ // Scoped marker so leaked tokens issued via UA stop authenticating once an
+ // admin detaches the method; tokens minted via other still-attached methods
+ // on the same identity stay valid (PLATFOR-359).
+ await identityAccessTokenService.revokeTokensForIdentityAuthMethod({
+ identityId,
+ authMethod: IdentityAuthMethod.UNIVERSAL_AUTH
+ });
return revokedIdentityUniversalAuth;
};