Skip to content

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

add edit-auth permission

Thiago Araujo da Silva841ea03e7f2b
diff --git a/backend/src/db/migrations/20260707000000_identity-edit-auth-permission.ts b/backend/src/db/migrations/20260707000000_identity-edit-auth-permission.ts
new file mode 100644
index 0000000000..9007fa0d58
--- /dev/null
+++ b/backend/src/db/migrations/20260707000000_identity-edit-auth-permission.ts
@@ -0,0 +1,134 @@
+import { packRules, unpackRules } from "@casl/ability/extra";
+import { Knex } from "knex";
+
+import { TableName } from "../schemas";
+
+// Auth-method configuration (attach/update) used to reuse the generic identity
+// `create`/`edit` actions. It now requires the dedicated `edit-auth` action. To
+// avoid silently stripping this ability from existing custom roles on upgrade,
+// grandfather `edit-auth` onto any custom role that could already configure auth
+// methods (i.e. has a non-inverted identity rule granting `create` or `edit`),
+// preserving that rule's conditions so identity-scoping is retained.
+//
+// Both org roles (projectId IS NULL) and project roles live in the `roles`
+// table and use the same `identity` subject + action strings, so a single pass
+// covers both. Built-in roles (admin/member/no-access) are handled in code and
+// are not stored here, so they are unaffected.
+
+const IDENTITY_SUBJECT = "identity";
+const CREATE_ACTION = "create";
+const EDIT_ACTION = "edit";
+const EDIT_AUTH_ACTION = "edit-auth";
+
+type CaslRule = {
+ action: string | string[];
+ subject: string | string[];
+ conditions?: unknown;
+ inverted?: boolean;
+};
+
+// `unpackRules` normalises `subject`/`action` to array form, so accept either shape.
+const includes = (value: string | string[] | undefined, target: string) =>
+ value === target || (Array.isArray(value) && value.includes(target));
+
+const conditionSignature = (conditions: unknown) =>
+ conditions === undefined ? "__none__" : JSON.stringify(conditions);
+
+export async function up(knex: Knex): Promise<void> {
+ await knex.transaction(async (trx) => {
+ const customRoles = await trx(TableName.Role).select("*");
+
+ const toUpdate = customRoles
+ .map((role) => {
+ const rules = unpackRules((role.permissions ?? []) as Parameters<typeof unpackRules>[0]) as CaslRule[];
+
+ // Condition signatures for which edit-auth is already granted (non-inverted).
+ const existingEditAuth = new Set(
+ rules
+ .filter(
+ (rule) =>
+ !rule.inverted && includes(rule.subject, IDENTITY_SUBJECT) && includes(rule.action, EDIT_AUTH_ACTION)
+ )
+ .map((rule) => conditionSignature(rule.conditions))
+ );
+
+ // Source rules that granted the ability to configure auth methods.
+ const sourceRules = rules.filter(
+ (rule) =>
+ !rule.inverted &&
+ includes(rule.subject, IDENTITY_SUBJECT) &&
+ (includes(rule.action, CREATE_ACTION) || includes(rule.action, EDIT_ACTION))
+ );
+
+ const rulesToAdd: CaslRule[] = [];
+ const addedSignatures = new Set<string>();
+ for (const rule of sourceRules) {
+ const signature = conditionSignature(rule.conditions);
+ if (!existingEditAuth.has(signature) && !addedSignatures.has(signature)) {
+ addedSignatures.add(signature);
+ rulesToAdd.push(
+ rule.conditions === undefined
+ ? { action: EDIT_AUTH_ACTION, subject: IDENTITY_SUBJECT }
+ : { action: EDIT_AUTH_ACTION, subject: IDENTITY_SUBJECT, conditions: rule.conditions }
+ );
+ }
+ }
+
+ if (rulesToAdd.length === 0) return null;
+
+ return {
+ ...role,
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
+ // @ts-ignore-error packRules type mismatch
+ permissions: JSON.stringify(packRules([...rules, ...rulesToAdd]))
+ };
+ })
+ .filter(Boolean) as typeof customRoles;
+
+ if (toUpdate.length > 0) {
+ await trx(TableName.Role).insert(toUpdate).onConflict("id").merge();
+ }
+ });
+}
+
+export async function down(knex: Knex): Promise<void> {
+ await knex.transaction(async (trx) => {
+ const customRoles = await trx(TableName.Role).select("*");
+
+ const toUpdate = customRoles
+ .map((role) => {
+ const rules = unpackRules((role.permissions ?? []) as Parameters<typeof unpackRules>[0]) as CaslRule[];
+
+ let wasModified = false;
+ const filteredRules = rules.filter((rule) => {
+ if (rule.inverted || !includes(rule.subject, IDENTITY_SUBJECT) || !includes(rule.action, EDIT_AUTH_ACTION))
+ return true;
+
+ wasModified = true;
+ if (Array.isArray(rule.action)) {
+ const withoutEditAuth = rule.action.filter((a) => a !== EDIT_AUTH_ACTION);
+ if (withoutEditAuth.length === 0) return false;
+ // eslint-disable-next-line no-param-reassign
+ rule.action = withoutEditAuth;
+ return true;
+ }
+ // Single action that is edit-auth, remove the rule entirely.
+ return false;
+ });
+
+ if (!wasModified) return null;
+
+ return {
+ ...role,
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
+ // @ts-ignore-error packRules type mismatch
+ permissions: JSON.stringify(packRules(filteredRules))
+ };
+ })
+ .filter(Boolean) as typeof customRoles;
+
+ if (toUpdate.length > 0) {
+ await trx(TableName.Role).insert(toUpdate).onConflict("id").merge();
+ }
+ });
+}
diff --git a/backend/src/ee/services/permission/default-roles.ts b/backend/src/ee/services/permission/default-roles.ts
index a97e8b54e3..699e7efd98 100644
--- a/backend/src/ee/services/permission/default-roles.ts
+++ b/backend/src/ee/services/permission/default-roles.ts
@@ -224,7 +224,8 @@ const buildAdminPermissionRules = () => {
ProjectPermissionIdentityActions.GetToken,
ProjectPermissionIdentityActions.CreateToken,
ProjectPermissionIdentityActions.DeleteToken,
- ProjectPermissionIdentityActions.RevokeAuth
+ ProjectPermissionIdentityActions.RevokeAuth,
+ ProjectPermissionIdentityActions.EditAuth
],
ProjectPermissionSub.Identity
);
diff --git a/backend/src/ee/services/permission/identity-edit-auth-permission.test.ts b/backend/src/ee/services/permission/identity-edit-auth-permission.test.ts
new file mode 100644
index 0000000000..3d15fdc26d
--- /dev/null
+++ b/backend/src/ee/services/permission/identity-edit-auth-permission.test.ts
@@ -0,0 +1,53 @@
+import { createMongoAbility, MongoAbility } from "@casl/ability";
+
+import { projectAdminPermissions, projectMemberPermissions } from "./default-roles";
+import {
+ orgAdminPermissions,
+ orgMemberPermissions,
+ OrgPermissionIdentityActions,
+ OrgPermissionSet,
+ OrgPermissionSubjects
+} from "./org-permission";
+import { ProjectPermissionIdentityActions, ProjectPermissionSet, ProjectPermissionSub } from "./project-permission";
+
+// Regression guard for the identity auth-method privilege-escalation fix.
+// Configuring an identity's auth methods (attach/update) is gated behind the
+// dedicated `edit-auth` action. The built-in Member role must NOT receive it,
+// otherwise a member could attach a trust-based auth method to a more-privileged
+// identity and authenticate as it. Admins must retain it.
+
+describe("Identity edit-auth permission decoupling", () => {
+ describe("Project roles", () => {
+ const admin = createMongoAbility<MongoAbility<ProjectPermissionSet>>(projectAdminPermissions);
+ const member = createMongoAbility<MongoAbility<ProjectPermissionSet>>(projectMemberPermissions);
+
+ test("admin can configure identity auth methods", () => {
+ expect(admin.can(ProjectPermissionIdentityActions.EditAuth, ProjectPermissionSub.Identity)).toBe(true);
+ });
+
+ test("member cannot configure identity auth methods", () => {
+ expect(member.can(ProjectPermissionIdentityActions.EditAuth, ProjectPermissionSub.Identity)).toBe(false);
+ });
+
+ test("member still has generic edit on identities (decoupled from auth config)", () => {
+ expect(member.can(ProjectPermissionIdentityActions.Edit, ProjectPermissionSub.Identity)).toBe(true);
+ });
+ });
+
+ describe("Organization roles", () => {
+ const admin = createMongoAbility<MongoAbility<OrgPermissionSet>>(orgAdminPermissions);
+ const member = createMongoAbility<MongoAbility<OrgPermissionSet>>(orgMemberPermissions);
+
+ test("admin can configure identity auth methods", () => {
+ expect(admin.can(OrgPermissionIdentityActions.EditAuth, OrgPermissionSubjects.Identity)).toBe(true);
+ });
+
+ test("member cannot configure identity auth methods", () => {
+ expect(member.can(OrgPermissionIdentityActions.EditAuth, OrgPermissionSubjects.Identity)).toBe(false);
+ });
+
+ test("member still has generic edit on identities (decoupled from auth config)", () => {
+ expect(member.can(OrgPermissionIdentityActions.Edit, OrgPermissionSubjects.Identity)).toBe(true);
+ });
+ });
+});
diff --git a/backend/src/ee/services/permission/org-permission.ts b/backend/src/ee/services/permission/org-permission.ts
index 11ba19aa31..37258fad28 100644
--- a/backend/src/ee/services/permission/org-permission.ts
+++ b/backend/src/ee/services/permission/org-permission.ts
@@ -108,6 +108,7 @@ export enum OrgPermissionIdentityActions {
Delete = "delete",
GrantPrivileges = "grant-privileges",
RevokeAuth = "revoke-auth",
+ EditAuth = "edit-auth",
CreateToken = "create-token",
GetToken = "get-token",
DeleteToken = "delete-token"
@@ -503,6 +504,7 @@ const buildAdminPermission = () => {
can(OrgPermissionIdentityActions.Delete, OrgPermissionSubjects.Identity);
can(OrgPermissionIdentityActions.GrantPrivileges, OrgPermissionSubjects.Identity);
can(OrgPermissionIdentityActions.RevokeAuth, OrgPermissionSubjects.Identity);
+ can(OrgPermissionIdentityActions.EditAuth, OrgPermissionSubjects.Identity);
can(OrgPermissionIdentityActions.CreateToken, OrgPermissionSubjects.Identity);
can(OrgPermissionIdentityActions.GetToken, OrgPermissionSubjects.Identity);
can(OrgPermissionIdentityActions.DeleteToken, OrgPermissionSubjects.Identity);
diff --git a/backend/src/ee/services/permission/project-permission.ts b/backend/src/ee/services/permission/project-permission.ts
index 30ec85a757..316dc2505f 100644
--- a/backend/src/ee/services/permission/project-permission.ts
+++ b/backend/src/ee/services/permission/project-permission.ts
@@ -84,6 +84,7 @@ export enum ProjectPermissionIdentityActions {
AssignAdditionalPrivileges = "assign-additional-privileges",
AssumePrivileges = "assume-privileges",
RevokeAuth = "revoke-auth",
+ EditAuth = "edit-auth",
CreateToken = "create-token",
GetToken = "get-token",
DeleteToken = "delete-token"
@@ -396,6 +397,7 @@ export const ActionAllowedConditions: ActionAllowedConditionsType = {
],
[ProjectPermissionIdentityActions.AssumePrivileges]: ["identityId"],
[ProjectPermissionIdentityActions.RevokeAuth]: ["identityId"],
+ [ProjectPermissionIdentityActions.EditAuth]: ["identityId"],
[ProjectPermissionIdentityActions.CreateToken]: ["identityId"],
[ProjectPermissionIdentityActions.GetToken]: ["identityId"],
[ProjectPermissionIdentityActions.DeleteToken]: ["identityId"]
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 f211770724..7dd613be70 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
@@ -307,7 +307,7 @@ export const identityAliCloudAuthServiceFactory = ({
});
ForbiddenError.from(permission).throwUnlessCan(
- ProjectPermissionIdentityActions.Create,
+ ProjectPermissionIdentityActions.EditAuth,
subject(ProjectPermissionSub.Identity, { identityId })
);
} else {
@@ -320,7 +320,7 @@ export const identityAliCloudAuthServiceFactory = ({
actorOrgId
});
ForbiddenError.from(permission).throwUnlessCan(
- OrgPermissionIdentityActions.Create,
+ OrgPermissionIdentityActions.EditAuth,
OrgPermissionSubjects.Identity
);
}
@@ -412,7 +412,7 @@ export const identityAliCloudAuthServiceFactory = ({
});
ForbiddenError.from(permission).throwUnlessCan(
- ProjectPermissionIdentityActions.Edit,
+ ProjectPermissionIdentityActions.EditAuth,
subject(ProjectPermissionSub.Identity, { identityId })
);
} else {
@@ -424,7 +424,7 @@ export const identityAliCloudAuthServiceFactory = ({
actorAuthMethod,
actorOrgId
});
- ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Edit, OrgPermissionSubjects.Identity);
+ ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.EditAuth, OrgPermissionSubjects.Identity);
}
const plan = await licenseService.getPlan(identityMembershipOrg.scopeOrgId);
const reformattedAccessTokenTrustedIps = accessTokenTrustedIps?.map((accessTokenTrustedIp) => {
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 8301d7a16c..bb13c13d84 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
@@ -405,7 +405,7 @@ export const identityAwsAuthServiceFactory = ({
});
ForbiddenError.from(permission).throwUnlessCan(
- ProjectPermissionIdentityActions.Create,
+ ProjectPermissionIdentityActions.EditAuth,
subject(ProjectPermissionSub.Identity, { identityId })
);
} else {
@@ -418,7 +418,7 @@ export const identityAwsAuthServiceFactory = ({
scope: OrganizationActionScope.Any
});
ForbiddenError.from(permission).throwUnlessCan(
- OrgPermissionIdentityActions.Create,
+ OrgPermissionIdentityActions.EditAuth,
OrgPermissionSubjects.Identity
);
}
@@ -513,7 +513,7 @@ export const identityAwsAuthServiceFactory = ({
});
ForbiddenError.from(permission).throwUnlessCan(
- ProjectPermissionIdentityActions.Edit,
+ ProjectPermissionIdentityActions.EditAuth,
subject(ProjectPermissionSub.Identity, { identityId })
);
} else {
@@ -525,7 +525,7 @@ export const identityAwsAuthServiceFactory = ({
actorAuthMethod,
actorOrgId
});
- ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Edit, OrgPermissionSubjects.Identity);
+ ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.EditAuth, OrgPermissionSubjects.Identity);
}
const plan = await licenseService.getPlan(identityMembershipOrg.scopeOrgId);
const reformattedAccessTokenTrustedIps = accessTokenTrustedIps?.map((accessTokenTrustedIp) => {
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 10e8e5a377..f823466fd4 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
@@ -306,7 +306,7 @@ export const identityAzureAuthServiceFactory = ({
});
ForbiddenError.from(permission).throwUnlessCan(
- ProjectPermissionIdentityActions.Create,
+ ProjectPermissionIdentityActions.EditAuth,
subject(ProjectPermissionSub.Identity, { identityId })
);
} else {
@@ -319,7 +319,7 @@ export const identityAzureAuthServiceFactory = ({
actorOrgId
});
ForbiddenError.from(permission).throwUnlessCan(
- OrgPermissionIdentityActions.Create,
+ OrgPermissionIdentityActions.EditAuth,
OrgPermissionSubjects.Identity
);
}
@@ -413,7 +413,7 @@ export const identityAzureAuthServiceFactory = ({
});
ForbiddenError.from(permission).throwUnlessCan(
- ProjectPermissionIdentityActions.Edit,
+ ProjectPermissionIdentityActions.EditAuth,
subject(ProjectPermissionSub.Identity, { identityId })
);
} else {
@@ -425,7 +425,7 @@ export const identityAzureAuthServiceFactory = ({
actorAuthMethod,
actorOrgId
});
- ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Edit, OrgPermissionSubjects.Identity);
+ ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.EditAuth, OrgPermissionSubjects.Identity);
}
const plan = await licenseService.getPlan(identityMembershipOrg.scopeOrgId);
const reformattedAccessTokenTrustedIps = accessTokenTrustedIps?.map((accessTokenTrustedIp) => {
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 f935c40591..6bc44ccaf0 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
@@ -351,7 +351,7 @@ export const identityGcpAuthServiceFactory = ({
});
ForbiddenError.from(permission).throwUnlessCan(
- ProjectPermissionIdentityActions.Create,
+ ProjectPermissionIdentityActions.EditAuth,
subject(ProjectPermissionSub.Identity, { identityId })
);
} else {
@@ -364,7 +364,7 @@ export const identityGcpAuthServiceFactory = ({
actorOrgId
});
ForbiddenError.from(permission).throwUnlessCan(
- OrgPermissionIdentityActions.Create,
+ OrgPermissionIdentityActions.EditAuth,
OrgPermissionSubjects.Identity
);
}
@@ -460,7 +460,7 @@ export const identityGcpAuthServiceFactory = ({
});
ForbiddenError.from(permission).throwUnlessCan(
- ProjectPermissionIdentityActions.Edit,
+ ProjectPermissionIdentityActions.EditAuth,
subject(ProjectPermissionSub.Identity, { identityId })
);
} else {
@@ -472,7 +472,7 @@ export const identityGcpAuthServiceFactory = ({
actorAuthMethod,
actorOrgId
});
- ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Edit, OrgPermissionSubjects.Identity);
+ ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.EditAuth, OrgPermissionSubjects.Identity);
}
const plan = await licenseService.getPlan(identityMembershipOrg.scopeOrgId);
const reformattedAccessTokenTrustedIps = accessTokenTrustedIps?.map((accessTokenTrustedIp) => {
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 8a22b4a529..441149832d 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
@@ -470,7 +470,7 @@ export const identityJwtAuthServiceFactory = ({
});
ForbiddenError.from(permission).throwUnlessCan(
- ProjectPermissionIdentityActions.Create,
+ ProjectPermissionIdentityActions.EditAuth,
subject(ProjectPermissionSub.Identity, { identityId })
);
} else {
@@ -484,7 +484,7 @@ export const identityJwtAuthServiceFactory = ({
});
ForbiddenError.from(permission).throwUnlessCan(
- OrgPermissionIdentityActions.Create,
+ OrgPermissionIdentityActions.EditAuth,
OrgPermissionSubjects.Identity
);
}
@@ -607,7 +607,7 @@ export const identityJwtAuthServiceFactory = ({
});
ForbiddenError.from(permission).throwUnlessCan(
- ProjectPermissionIdentityActions.Edit,
+ ProjectPermissionIdentityActions.EditAuth,
subject(ProjectPermissionSub.Identity, { identityId })
);
} else {
@@ -620,7 +620,7 @@ export const identityJwtAuthServiceFactory = ({
actorOrgId
});
- ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Edit, OrgPermissionSubjects.Identity);
+ ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.EditAuth, OrgPermissionSubjects.Identity);
}
const plan = await licenseService.getPlan(identityMembershipOrg.scopeOrgId);
const reformattedAccessTokenTrustedIps = accessTokenTrustedIps?.map((accessTokenTrustedIp) => {
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 6dd1db4ccc..d434b27acb 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
@@ -838,7 +838,7 @@ export const identityKubernetesAuthServiceFactory = ({
});
ForbiddenError.from(permission).throwUnlessCan(
- ProjectPermissionIdentityActions.Create,
+ ProjectPermissionIdentityActions.EditAuth,
subject(ProjectPermissionSub.Identity, { identityId })
);
} else {
@@ -851,7 +851,7 @@ export const identityKubernetesAuthServiceFactory = ({
actorOrgId
});
ForbiddenError.from(permission).throwUnlessCan(
- OrgPermissionIdentityActions.Create,
+ OrgPermissionIdentityActions.EditAuth,
OrgPermissionSubjects.Identity
);
}
@@ -1111,7 +1111,7 @@ export const identityKubernetesAuthServiceFactory = ({
});
ForbiddenError.from(permission).throwUnlessCan(
- ProjectPermissionIdentityActions.Edit,
+ ProjectPermissionIdentityActions.EditAuth,
subject(ProjectPermissionSub.Identity, { identityId })
);
} else {
@@ -1123,7 +1123,7 @@ export const identityKubernetesAuthServiceFactory = ({
actorAuthMethod,
actorOrgId
});
- ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Edit, OrgPermissionSubjects.Identity);
+ ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.EditAuth, OrgPermissionSubjects.Identity);
}
const plan = await licenseService.getPlan(identityMembershipOrg.scopeOrgId);
const reformattedAccessTokenTrustedIps = accessTokenTrustedIps?.map((accessTokenTrustedIp) => {
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 504ac458b8..6b35b7887c 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
@@ -392,12 +392,12 @@ export const identityLdapAuthServiceFactory = ({
});
ForbiddenError.from(projectPermission).throwUnlessCan(
- ProjectPermissionIdentityActions.Create,
+ ProjectPermissionIdentityActions.EditAuth,
subject(ProjectPermissionSub.Identity, { identityId })
);
} else {
ForbiddenError.from(orgPermission).throwUnlessCan(
- OrgPermissionIdentityActions.Create,
+ OrgPermissionIdentityActions.EditAuth,
OrgPermissionSubjects.Identity
);
}
@@ -597,12 +597,12 @@ export const identityLdapAuthServiceFactory = ({
});
ForbiddenError.from(projectPermission).throwUnlessCan(
- ProjectPermissionIdentityActions.Create,
+ ProjectPermissionIdentityActions.EditAuth,
subject(ProjectPermissionSub.Identity, { identityId })
);
} else {
ForbiddenError.from(orgPermission).throwUnlessCan(
- OrgPermissionIdentityActions.Edit,
+ OrgPermissionIdentityActions.EditAuth,
OrgPermissionSubjects.Identity
);
}
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 cc61ff485a..739e6ef782 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
@@ -319,7 +319,7 @@ export const identityOciAuthServiceFactory = ({
});
ForbiddenError.from(permission).throwUnlessCan(
- ProjectPermissionIdentityActions.Create,
+ ProjectPermissionIdentityActions.EditAuth,
subject(ProjectPermissionSub.Identity, { identityId })
);
} else {
@@ -332,7 +332,7 @@ export const identityOciAuthServiceFactory = ({
actorOrgId
});
ForbiddenError.from(permission).throwUnlessCan(
- OrgPermissionIdentityActions.Create,
+ OrgPermissionIdentityActions.EditAuth,
OrgPermissionSubjects.Identity
);
}
@@ -426,7 +426,7 @@ export const identityOciAuthServiceFactory = ({
});
ForbiddenError.from(permission).throwUnlessCan(
- ProjectPermissionIdentityActions.Edit,
+ ProjectPermissionIdentityActions.EditAuth,
subject(ProjectPermissionSub.Identity, { identityId })
);
} else {
@@ -438,7 +438,7 @@ export const identityOciAuthServiceFactory = ({
actorAuthMethod,
actorOrgId
});
- ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Edit, OrgPermissionSubjects.Identity);
+ ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.EditAuth, OrgPermissionSubjects.Identity);
}
const plan = await licenseService.getPlan(identityMembershipOrg.scopeOrgId);
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 77b730a6f6..c0c1437d0c 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
@@ -644,7 +644,7 @@ export const identityOidcAuthServiceFactory = ({
});
ForbiddenError.from(permission).throwUnlessCan(
- ProjectPermissionIdentityActions.Create,
+ ProjectPermissionIdentityActions.EditAuth,
subject(ProjectPermissionSub.Identity, { identityId })
);
} else {
@@ -658,7 +658,7 @@ export const identityOidcAuthServiceFactory = ({
});
ForbiddenError.from(permission).throwUnlessCan(
- OrgPermissionIdentityActions.Create,
+ OrgPermissionIdentityActions.EditAuth,
OrgPermissionSubjects.Identity
);
}
@@ -768,7 +768,7 @@ export const identityOidcAuthServiceFactory = ({
});
ForbiddenError.from(permission).throwUnlessCan(
- ProjectPermissionIdentityActions.Edit,
+ ProjectPermissionIdentityActions.EditAuth,
subject(ProjectPermissionSub.Identity, { identityId })
);
} else {
@@ -781,7 +781,7 @@ export const identityOidcAuthServiceFactory = ({
actorOrgId
});
- ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Edit, OrgPermissionSubjects.Identity);
+ ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.EditAuth, OrgPermissionSubjects.Identity);
}
const plan = await licenseService.getPlan(identityMembershipOrg.scopeOrgId);
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 fd826dd887..3df762a8b9 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
@@ -544,7 +544,7 @@ export const identitySpiffeAuthServiceFactory = ({
});
ForbiddenError.from(permission).throwUnlessCan(
- ProjectPermissionIdentityActions.Create,
+ ProjectPermissionIdentityActions.EditAuth,
subject(ProjectPermissionSub.Identity, { identityId })
);
} else {
@@ -558,7 +558,7 @@ export const identitySpiffeAuthServiceFactory = ({
});
ForbiddenError.from(permission).throwUnlessCan(
- OrgPermissionIdentityActions.Create,
+ OrgPermissionIdentityActions.EditAuth,
OrgPermissionSubjects.Identity
);
}
@@ -689,7 +689,7 @@ export const identitySpiffeAuthServiceFactory = ({
});
ForbiddenError.from(permission).throwUnlessCan(
- ProjectPermissionIdentityActions.Edit,
+ ProjectPermissionIdentityActions.EditAuth,
subject(ProjectPermissionSub.Identity, { identityId })
);
} else {
@@ -702,7 +702,7 @@ export const identitySpiffeAuthServiceFactory = ({
actorOrgId
});
- ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Edit, OrgPermissionSubjects.Identity);
+ ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.EditAuth, OrgPermissionSubjects.Identity);
}
const plan = await licenseService.getPlan(identityMembershipOrg.scopeOrgId);
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 b8e2c94001..c269c28153 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
@@ -430,7 +430,7 @@ export const identityTlsCertAuthServiceFactory = ({
});
ForbiddenError.from(permission).throwUnlessCan(
- ProjectPermissionIdentityActions.Create,
+ ProjectPermissionIdentityActions.EditAuth,
subject(ProjectPermissionSub.Identity, { identityId })
);
} else {
@@ -443,7 +443,7 @@ export const identityTlsCertAuthServiceFactory = ({
actorOrgId
});
ForbiddenError.from(permission).throwUnlessCan(
- OrgPermissionIdentityActions.Create,
+ OrgPermissionIdentityActions.EditAuth,
OrgPermissionSubjects.Identity
);
}
@@ -546,7 +546,7 @@ export const identityTlsCertAuthServiceFactory = ({
});
ForbiddenError.from(permission).throwUnlessCan(
- ProjectPermissionIdentityActions.Edit,
+ ProjectPermissionIdentityActions.EditAuth,
subject(ProjectPermissionSub.Identity, { identityId })
);
} else {
@@ -558,7 +558,7 @@ export const identityTlsCertAuthServiceFactory = ({
actorAuthMethod,
actorOrgId
});
- ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Edit, OrgPermissionSubjects.Identity);
+ ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.EditAuth, OrgPermissionSubjects.Identity);
}
const plan = await licenseService.getPlan(identityMembershipOrg.scopeOrgId);
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 af1bf7826c..a4d59d7665 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
@@ -126,7 +126,7 @@ export const identityTokenAuthServiceFactory = ({
});
ForbiddenError.from(permission).throwUnlessCan(
- ProjectPermissionIdentityActions.Create,
+ ProjectPermissionIdentityActions.EditAuth,
subject(ProjectPermissionSub.Identity, { identityId })
);
} else {
@@ -139,7 +139,7 @@ export const identityTokenAuthServiceFactory = ({
actorOrgId
});
ForbiddenError.from(permission).throwUnlessCan(
- OrgPermissionIdentityActions.Create,
+ OrgPermissionIdentityActions.EditAuth,
OrgPermissionSubjects.Identity
);
}
@@ -232,7 +232,7 @@ export const identityTokenAuthServiceFactory = ({
});
ForbiddenError.from(permission).throwUnlessCan(
- ProjectPermissionIdentityActions.Edit,
+ ProjectPermissionIdentityActions.EditAuth,
subject(ProjectPermissionSub.Identity, { identityId })
);
} else {
@@ -244,7 +244,10 @@ export const identityTokenAuthServiceFactory = ({
actorAuthMethod,
actorOrgId
});
- ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Edit, OrgPermissionSubjects.Identity);
+ ForbiddenError.from(permission).throwUnlessCan(
+ OrgPermissionIdentityActions.EditAuth,
+ OrgPermissionSubjects.Identity
+ );
}
const plan = await licenseService.getPlan(identityMembershipOrg.scopeOrgId);
diff --git a/backend/src/services/identity-ua/identity-ua-service.ts b/backend/src/services/identity-ua/identity-ua-service.ts
index 84285087d5..2e5afc28d7 100644
--- a/backend/src/services/identity-ua/identity-ua-service.ts
+++ b/backend/src/services/identity-ua/identity-ua-service.ts
@@ -481,7 +481,7 @@ export const identityUaServiceFactory = ({
});
ForbiddenError.from(permission).throwUnlessCan(
- ProjectPermissionIdentityActions.Create,
+ ProjectPermissionIdentityActions.EditAuth,
subject(ProjectPermissionSub.Identity, { identityId })
);
} else {
@@ -495,7 +495,7 @@ export const identityUaServiceFactory = ({
});
ForbiddenError.from(permission).throwUnlessCan(
- OrgPermissionIdentityActions.Create,
+ OrgPermissionIdentityActions.EditAuth,
OrgPermissionSubjects.Identity
);
}
@@ -620,7 +620,7 @@ export const identityUaServiceFactory = ({
});
ForbiddenError.from(permission).throwUnlessCan(
- ProjectPermissionIdentityActions.Edit,
+ ProjectPermissionIdentityActions.EditAuth,
subject(ProjectPermissionSub.Identity, { identityId })
);
} else {
@@ -632,7 +632,10 @@ export const identityUaServiceFactory = ({
actorAuthMethod,
actorOrgId
});
- ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Edit, OrgPermissionSubjects.Identity);
+ ForbiddenError.from(permission).throwUnlessCan(
+ OrgPermissionIdentityActions.EditAuth,
+ OrgPermissionSubjects.Identity
+ );
}
const plan = await licenseService.getPlan(identityMembershipOrg.scopeOrgId);
diff --git a/frontend/src/context/OrgPermissionContext/types.ts b/frontend/src/context/OrgPermissionContext/types.ts
index da56b8b1b1..d131d6e253 100644
--- a/frontend/src/context/OrgPermissionContext/types.ts
+++ b/frontend/src/context/OrgPermissionContext/types.ts
@@ -154,6 +154,7 @@ export enum OrgPermissionIdentityActions {
Delete = "delete",
GrantPrivileges = "grant-privileges",
RevokeAuth = "revoke-auth",
+ EditAuth = "edit-auth",
CreateToken = "create-token",
GetToken = "get-token",
DeleteToken = "delete-token"
diff --git a/frontend/src/context/ProjectPermissionContext/types.ts b/frontend/src/context/ProjectPermissionContext/types.ts
index 238283a4e7..bf874b1457 100644
--- a/frontend/src/context/ProjectPermissionContext/types.ts
+++ b/frontend/src/context/ProjectPermissionContext/types.ts
@@ -112,6 +112,7 @@ export enum ProjectPermissionIdentityActions {
AssignAdditionalPrivileges = "assign-additional-privileges",
AssumePrivileges = "assume-privileges",
RevokeAuth = "revoke-auth",
+ EditAuth = "edit-auth",
CreateToken = "create-token",
GetToken = "get-token",
DeleteToken = "delete-token"
diff --git a/frontend/src/pages/organization/IdentityDetailsByIDPage/components/IdentityAuthenticationSection/IdentityAuthenticationSection.tsx b/frontend/src/pages/organization/IdentityDetailsByIDPage/components/IdentityAuthenticationSection/IdentityAuthenticationSection.tsx
index f9a896211a..f8d57e75a9 100644
--- a/frontend/src/pages/organization/IdentityDetailsByIDPage/components/IdentityAuthenticationSection/IdentityAuthenticationSection.tsx
+++ b/frontend/src/pages/organization/IdentityDetailsByIDPage/components/IdentityAuthenticationSection/IdentityAuthenticationSection.tsx
@@ -46,7 +46,7 @@ export const IdentityAuthenticationSection = ({ identityId, handlePopUpOpen }: P
) && (
<CardAction>
<OrgPermissionCan
- I={OrgPermissionIdentityActions.Edit}
+ I={OrgPermissionIdentityActions.EditAuth}
a={OrgPermissionSubjects.Identity}
>
{(isAllowed) => (
@@ -88,7 +88,7 @@ export const IdentityAuthenticationSection = ({ identityId, handlePopUpOpen }: P
</EmptyHeader>
<EmptyContent>
<OrgPermissionCan
- I={OrgPermissionIdentityActions.Edit}
+ I={OrgPermissionIdentityActions.EditAuth}
a={OrgPermissionSubjects.Identity}
>
{(isAllowed) => (
diff --git a/frontend/src/pages/organization/RoleByIDPage/components/OrgRoleModifySection.utils.ts b/frontend/src/pages/organization/RoleByIDPage/components/OrgRoleModifySection.utils.ts
index 3fc9e15413..d48f96906d 100644
--- a/frontend/src/pages/organization/RoleByIDPage/components/OrgRoleModifySection.utils.ts
+++ b/frontend/src/pages/organization/RoleByIDPage/components/OrgRoleModifySection.utils.ts
@@ -86,6 +86,7 @@ const identityPermissionSchema = z
[OrgPermissionIdentityActions.Create]: z.boolean().optional(),
[OrgPermissionIdentityActions.GrantPrivileges]: z.boolean().optional(),
[OrgPermissionIdentityActions.RevokeAuth]: z.boolean().optional(),
+ [OrgPermissionIdentityActions.EditAuth]: z.boolean().optional(),
[OrgPermissionIdentityActions.CreateToken]: z.boolean().optional(),
[OrgPermissionIdentityActions.GetToken]: z.boolean().optional(),
[OrgPermissionIdentityActions.DeleteToken]: z.boolean().optional()
@@ -629,6 +630,11 @@ export const ORG_PERMISSION_OBJECT: Record<string, TOrgPermissionConfig> = {
label: "Revoke Auth",
description: "Revoke authentication for a machine identity"
},
+ {
+ value: OrgPermissionIdentityActions.EditAuth,
+ label: "Configure Auth Methods",
+ description: "Add or update authentication methods for a machine identity"
+ },
{
value: OrgPermissionIdentityActions.CreateToken,
label: "Create Token",
diff --git a/frontend/src/pages/project/IdentityDetailsByIDPage/components/ProjectIdentityAuthSection.tsx b/frontend/src/pages/project/IdentityDetailsByIDPage/components/ProjectIdentityAuthSection.tsx
index 69b813f73c..4bca32ba7d 100644
--- a/frontend/src/pages/project/IdentityDetailsByIDPage/components/ProjectIdentityAuthSection.tsx
+++ b/frontend/src/pages/project/IdentityDetailsByIDPage/components/ProjectIdentityAuthSection.tsx
@@ -61,7 +61,7 @@ export const ProjectIdentityAuthenticationSection = ({ identity, refetchIdentity
) && (
<CardAction>
<ProjectPermissionCan
- I={ProjectPermissionIdentityActions.Edit}
+ I={ProjectPermissionIdentityActions.EditAuth}
a={subject(ProjectPermissionSub.Identity, {
identityId: identity.id
})}
@@ -105,7 +105,7 @@ export const ProjectIdentityAuthenticationSection = ({ identity, refetchIdentity
</EmptyHeader>
<EmptyContent>
<ProjectPermissionCan
- I={ProjectPermissionIdentityActions.Edit}
+ I={ProjectPermissionIdentityActions.EditAuth}
a={subject(ProjectPermissionSub.Identity, {
identityId: identity.id
})}
diff --git a/frontend/src/pages/project/RoleDetailsBySlugPage/components/ProjectRoleModifySection.utils.tsx b/frontend/src/pages/project/RoleDetailsBySlugPage/components/ProjectRoleModifySection.utils.tsx
index ae0c636d9c..5892631352 100644
--- a/frontend/src/pages/project/RoleDetailsBySlugPage/components/ProjectRoleModifySection.utils.tsx
+++ b/frontend/src/pages/project/RoleDetailsBySlugPage/components/ProjectRoleModifySection.utils.tsx
@@ -477,6 +477,7 @@ export const ACTION_ALLOWED_CONDITIONS: ActionAllowedConditionsType = {
],
[ProjectPermissionIdentityActions.AssumePrivileges]: ["identityId"],
[ProjectPermissionIdentityActions.RevokeAuth]: ["identityId"],
+ [ProjectPermissionIdentityActions.EditAuth]: ["identityId"],
[ProjectPermissionIdentityActions.CreateToken]: ["identityId"],
[ProjectPermissionIdentityActions.GetToken]: ["identityId"],
[ProjectPermissionIdentityActions.DeleteToken]: ["identityId"]
@@ -595,6 +596,7 @@ const IdentityPolicyActionSchema = createPolicySchemaWithConditions(
[ProjectPermissionIdentityActions.AssignAdditionalPrivileges]: z.boolean().optional(),
[ProjectPermissionIdentityActions.AssumePrivileges]: z.boolean().optional(),
[ProjectPermissionIdentityActions.RevokeAuth]: z.boolean().optional(),
+ [ProjectPermissionIdentityActions.EditAuth]: z.boolean().optional(),
[ProjectPermissionIdentityActions.GetToken]: z.boolean().optional(),
[ProjectPermissionIdentityActions.CreateToken]: z.boolean().optional(),
[ProjectPermissionIdentityActions.DeleteToken]: z.boolean().optional()
@@ -1232,6 +1234,7 @@ export const rolePermission2Form = (permissions: TProjectPermission[] = []) => {
ProjectPermissionIdentityActions.AssumePrivileges
);
const canRevokeAuth = action.includes(ProjectPermissionIdentityActions.RevokeAuth);
+ const canEditAuth = action.includes(ProjectPermissionIdentityActions.EditAuth);
const canCreateToken = action.includes(ProjectPermissionIdentityActions.CreateToken);
const canGetToken = action.includes(ProjectPermissionIdentityActions.GetToken);
const canDeleteToken = action.includes(ProjectPermissionIdentityActions.DeleteToken);
@@ -1248,6 +1251,7 @@ export const rolePermission2Form = (permissions: TProjectPermission[] = []) => {
canAssignAdditionalPrivileges,
[ProjectPermissionIdentityActions.AssumePrivileges]: canAssumePrivileges,
[ProjectPermissionIdentityActions.RevokeAuth]: canRevokeAuth,
+ [ProjectPermissionIdentityActions.EditAuth]: canEditAuth,
[ProjectPermissionIdentityActions.CreateToken]: canCreateToken,
[ProjectPermissionIdentityActions.GetToken]: canGetToken,
[ProjectPermissionIdentityActions.DeleteToken]: canDeleteToken,
@@ -2267,6 +2271,11 @@ export const PROJECT_PERMISSION_OBJECT: TProjectPermissionObject = {
value: ProjectPermissionIdentityActions.RevokeAuth,
description: "Revoke authentication for a machine identity"
},
+ {
+ label: "Configure Auth Methods",
+ value: ProjectPermissionIdentityActions.EditAuth,
+ description: "Add or update authentication methods for a machine identity"
+ },
{
label: "Create Token",
value: ProjectPermissionIdentityActions.CreateToken,
diff --git a/frontend/src/views/IdentityAuthMethods/IdentityAuthMethodSheet.tsx b/frontend/src/views/IdentityAuthMethods/IdentityAuthMethodSheet.tsx
index 2f2be1f1a8..cc20807071 100644
--- a/frontend/src/views/IdentityAuthMethods/IdentityAuthMethodSheet.tsx
+++ b/frontend/src/views/IdentityAuthMethods/IdentityAuthMethodSheet.tsx
@@ -215,8 +215,8 @@ export const IdentityAuthMethodSheet = ({
type={projectId ? "project" : "org"}
I={
projectId
- ? ProjectPermissionIdentityActions.Edit
- : OrgPermissionIdentityActions.Edit
+ ? ProjectPermissionIdentityActions.EditAuth
+ : OrgPermissionIdentityActions.EditAuth
}
a={
projectId
diff --git a/frontend/src/views/IdentityAuthMethods/IdentityAuthMethodsTable.tsx b/frontend/src/views/IdentityAuthMethods/IdentityAuthMethodsTable.tsx
index 80af365e4d..762020bdc8 100644
--- a/frontend/src/views/IdentityAuthMethods/IdentityAuthMethodsTable.tsx
+++ b/frontend/src/views/IdentityAuthMethods/IdentityAuthMethodsTable.tsx
@@ -127,8 +127,8 @@ export const IdentityAuthMethodsTable = ({
type={projectId ? "project" : "org"}
I={
projectId
- ? ProjectPermissionIdentityActions.Edit
- : OrgPermissionIdentityActions.Edit
+ ? ProjectPermissionIdentityActions.EditAuth
+ : OrgPermissionIdentityActions.EditAuth
}
a={
projectId