Skip to content

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

edit auth to change template linked to existing identities

Thiago Araujo da Silvab1dfe840fb75
diff --git a/backend/CLAUDE.md b/backend/CLAUDE.md
index a794d18146..eda15f53c2 100644
--- a/backend/CLAUDE.md
+++ b/backend/CLAUDE.md
@@ -556,7 +556,7 @@ Built-in roles: `Admin`, `Member`, `Viewer`, `NoAccess`. For PAM and Agent Vault
**Privilege boundaries mean different things on the two privilege systems.** `organizations.shouldUseNewPrivilegeSystem` (default `true`, backfilled `false` for orgs predating March 2025) picks which. `validatePrivilegeChangeOperation` / `assertRoleSetBoundary` (`permission-fns.ts`) are the shim: on the new system they collapse to `actorPermission.can(action, subject)`, on the legacy one they run `validatePermissionBoundary`, requiring the actor to out-rank every role the target holds. So a boundary at a call site that already gated on the same action is a no-op for new-system orgs and the only protection for legacy ones. Two consequences: "the route checks the action" is not a substitute for a boundary, and adding one is not a behavior change for most tenants. Prefer `getOrgPermissionByRoles` / `getProjectPermissionByRoles` + `assertRoleSetBoundary` over fetching the target's merged ability. It bounds each role separately, and it avoids `getProjectPermission`, which stamps whichever actor it was called for onto the request context the audit log reads.
-**Identity auth-method access goes through `assertIdentityAuthAccessAllowed`** (`src/services/identity/identity-auth-permission-fns.ts`), because repointing an identity's auth trust lets the caller authenticate as that identity. All 13 auth services call it once per attach/update/revoke, after the `throwUnlessCan` gate and outside the `identity.projectId` branch so both scopes are covered. A new auth method calls it too. Credential issuance (`createTokenAuthToken`, `createUniversalAuthClientSecret`) goes through it under `create-token`, since minting a credential is the same escalation as repointing the trust, and so do the per-credential paths: `updateTokenAuthToken` under `create-token`, `getUniversalAuthClientSecrets` / `getUniversalAuthClientSecretById` under `get-token`, and `revokeUniversalAuthClientSecret` under `delete-token`. **`PROJECT_ACTION_BY_ORG_ACTION` must map the org action to the same project action the route's own `throwUnlessCan` already checks** — that identity is what keeps the helper a no-op for new-system orgs, so a new entry is only safe once you have confirmed the pair matches. `revokeTokenAuthToken` and `clearUniversalAuthLockouts` are still unbounded in both scopes (and the former gates on `edit` where its UA counterpart gates on `delete-token`); that predates the helper and is a deliberate gap, not an oversight to copy. The target's grants come from `permissionService.getActorGrantAbilities`, not from a membership lookup, and it returns one ability per grant rather than per role. Two things a role-slug resolver misses: a group-derived membership carries a NULL `actorIdentityId`, so `membershipIdentityDAL.getIdentityById` never sees it, and an additional privilege carries a raw permission blob with no slug at all, so no `*PermissionByRoles` path can express it. Either omission clears an actor that out-ranks the target's direct roles but not its effective access. `getActorGrantAbilities` reads the same `permissionDAL.getPermission` query the ability itself is built from, so the bounded set cannot drift from the effective one.
+**Identity auth-method access goes through `assertIdentityAuthAccessAllowed`** (`src/services/identity/identity-auth-permission-fns.ts`), because repointing an identity's auth trust lets the caller authenticate as that identity. It's both the gate and the boundary: it checks the identity action itself on both privilege systems, and on legacy also makes the actor out-rank every grant the target holds. The boundary alone isn't enough, since it passes for any target you cover, and for an org identity it only sees org-scope grants, so a no-access org identity that's admin in projects would be open to anyone. Callers don't repeat the action check. The 13 auth services and the template update call it once per attach/update/revoke, outside the `identity.projectId` branch so both scopes are covered, and a new auth method should too. Only the fine-grained action gates these paths, at both scopes; the old coarse org checks (`edit`, `create`, `read`, `delete`) are gone. Credential issuance (`createTokenAuthToken`, `createUniversalAuthClientSecret`) goes through it under `create-token`, since minting a credential is the same escalation as repointing the trust, and so do the per-credential paths: `updateTokenAuthToken` under `create-token`, `getUniversalAuthClientSecrets` / `getUniversalAuthClientSecretById` under `get-token`, and `revokeUniversalAuthClientSecret` under `delete-token`. **`PROJECT_ACTION_BY_ORG_ACTION` must map each org action to its project equivalent**, since project identities get checked against the mapped one. `revokeTokenAuthToken` and `clearUniversalAuthLockouts` are still unbounded in both scopes (and the former gates on `edit` where its UA counterpart gates on `delete-token`); that predates the helper and is a deliberate gap, not an oversight to copy. The target's grants come from `permissionService.getActorGrantAbilities`, not from a membership lookup, and it returns one ability per grant rather than per role. Two things a role-slug resolver misses: a group-derived membership carries a NULL `actorIdentityId`, so `membershipIdentityDAL.getIdentityById` never sees it, and an additional privilege carries a raw permission blob with no slug at all, so no `*PermissionByRoles` path can express it. Either omission clears an actor that out-ranks the target's direct roles but not its effective access. `getActorGrantAbilities` reads the same `permissionDAL.getPermission` query the ability itself is built from, so the bounded set cannot drift from the effective one.
**Deny an RBAC check by throwing through CASL, never with `ForbiddenRequestError`.** `audit-log-permission-denied.ts` records a permission-denied audit event for every CASL `ForbiddenError` and `PermissionBoundaryError` a request throws, and skips plain `ForbiddenRequestError` because most of those are auth-mode, plan and ownership refusals. A service that calls `permission.can()` and throws `ForbiddenRequestError` itself therefore produces no denial event, and nothing fails to tell you. When the check has a fallback (a second action, an approver, an application grant), test the fallbacks first and make `ForbiddenError.from(permission).throwUnlessCan(...)` the last check, so the denial is recorded with a real action and subject. Keep `ForbiddenRequestError` for refusals that are not about a permission.
diff --git a/backend/src/ee/routes/v1/identity-template-router.ts b/backend/src/ee/routes/v1/identity-template-router.ts
index 8b19ba1545..2ea8419c79 100644
--- a/backend/src/ee/routes/v1/identity-template-router.ts
+++ b/backend/src/ee/routes/v1/identity-template-router.ts
@@ -152,7 +152,8 @@ export const registerIdentityTemplateRouter = async (server: FastifyZodProvider)
actor: req.permission.type,
actorId: req.permission.id,
actorAuthMethod: req.permission.authMethod,
- actorOrgId: req.permission.orgId
+ actorOrgId: req.permission.orgId,
+ auditLogInfo: req.auditLogInfo
});
await server.services.auditLog.createAuditLog({
@@ -201,7 +202,8 @@ export const registerIdentityTemplateRouter = async (server: FastifyZodProvider)
actor: req.permission.type,
actorId: req.permission.id,
actorAuthMethod: req.permission.authMethod,
- actorOrgId: req.permission.orgId
+ actorOrgId: req.permission.orgId,
+ auditLogInfo: req.auditLogInfo
});
await server.services.auditLog.createAuditLog({
@@ -410,7 +412,8 @@ export const registerIdentityTemplateRouter = async (server: FastifyZodProvider)
actor: req.permission.type,
actorId: req.permission.id,
actorAuthMethod: req.permission.authMethod,
- actorOrgId: req.permission.orgId
+ actorOrgId: req.permission.orgId,
+ auditLogInfo: req.auditLogInfo
});
return templates;
diff --git a/backend/src/ee/services/identity-auth-template/identity-auth-template-dal.ts b/backend/src/ee/services/identity-auth-template/identity-auth-template-dal.ts
index 53ea39a8fc..cf6d982911 100644
--- a/backend/src/ee/services/identity-auth-template/identity-auth-template-dal.ts
+++ b/backend/src/ee/services/identity-auth-template/identity-auth-template-dal.ts
@@ -59,7 +59,8 @@ export const identityAuthTemplateDALFactory = (db: TDbClient) => {
.where(buildFindFilter({ templateId }, TableName.IdentityLdapAuth))
.select(
db.ref("identityId").withSchema(TableName.IdentityLdapAuth),
- db.ref("name").withSchema(TableName.Identity).as("identityName")
+ db.ref("name").withSchema(TableName.Identity).as("identityName"),
+ db.ref("projectId").withSchema(TableName.Identity).as("identityProjectId")
);
const docs = await query;
return docs;
@@ -70,7 +71,8 @@ export const identityAuthTemplateDALFactory = (db: TDbClient) => {
.where(buildFindFilter({ templateId }, TableName.IdentityKubernetesAuth))
.select(
db.ref("identityId").withSchema(TableName.IdentityKubernetesAuth),
- db.ref("name").withSchema(TableName.Identity).as("identityName")
+ db.ref("name").withSchema(TableName.Identity).as("identityName"),
+ db.ref("projectId").withSchema(TableName.Identity).as("identityProjectId")
);
const kubernetesDocs = await kubernetesQuery;
return kubernetesDocs;
@@ -81,7 +83,8 @@ export const identityAuthTemplateDALFactory = (db: TDbClient) => {
.where(buildFindFilter({ templateId }, TableName.IdentityOidcAuth))
.select(
db.ref("identityId").withSchema(TableName.IdentityOidcAuth),
- db.ref("name").withSchema(TableName.Identity).as("identityName")
+ db.ref("name").withSchema(TableName.Identity).as("identityName"),
+ db.ref("projectId").withSchema(TableName.Identity).as("identityProjectId")
);
const oidcDocs = await oidcQuery;
return oidcDocs;
diff --git a/backend/src/ee/services/identity-auth-template/identity-auth-template-service.test.ts b/backend/src/ee/services/identity-auth-template/identity-auth-template-service.test.ts
index 4f9d9dfe96..48b4e6c5bc 100644
--- a/backend/src/ee/services/identity-auth-template/identity-auth-template-service.test.ts
+++ b/backend/src/ee/services/identity-auth-template/identity-auth-template-service.test.ts
@@ -1,6 +1,12 @@
-import { createMongoAbility } from "@casl/ability";
+import { createMongoAbility, ForbiddenError, MongoAbility, RawRuleOf } from "@casl/ability";
import { beforeEach, describe, expect, it, vi } from "vitest";
+import {
+ OrgPermissionIdentityActions,
+ OrgPermissionMachineIdentityAuthTemplateActions,
+ OrgPermissionSubjects
+} from "@app/ee/services/permission/org-permission";
+import { ProjectPermissionIdentityActions, ProjectPermissionSub } from "@app/ee/services/permission/project-permission";
import { BadRequestError } from "@app/lib/errors";
import { IdentityKubernetesAuthTokenReviewMode } from "@app/services/identity-kubernetes-auth/identity-kubernetes-auth-types";
@@ -37,16 +43,24 @@ const baseBlobFields = {
const NO_GATEWAY = { gatewayV2Id: null, gatewayPoolId: null };
+const ADMIN_RULES: RawRuleOf<MongoAbility>[] = [{ action: "manage", subject: "all" }];
+
const createService = ({
authMethod = IdentityAuthTemplateMethod.KUBERNETES,
blobFields = baseBlobFields,
gatewayColumns = { gatewayV2Id: GATEWAY_V2_ID, gatewayPoolId: null },
- liveGatewayV2Ids = [GATEWAY_V2_ID]
+ liveGatewayV2Ids = [GATEWAY_V2_ID],
+ orgRules = ADMIN_RULES,
+ projectRules = ADMIN_RULES,
+ linkedIdentities = [{ identityId: "identity-id", identityName: "identity", identityProjectId: null }]
}: {
authMethod?: IdentityAuthTemplateMethod;
blobFields?: Record<string, unknown>;
gatewayColumns?: { gatewayV2Id: string | null; gatewayPoolId: string | null };
liveGatewayV2Ids?: string[];
+ orgRules?: RawRuleOf<MongoAbility>[];
+ projectRules?: RawRuleOf<MongoAbility>[];
+ linkedIdentities?: { identityId: string; identityName: string; identityProjectId: string | null }[];
} = {}) => {
const identityKubernetesAuthDAL = {
updateByTemplateId: vi.fn().mockResolvedValue([{ identityId: "identity-id" }])
@@ -67,13 +81,14 @@ const createService = ({
const identityAuthTemplateDAL = {
findByIdAndOrgId: vi.fn().mockResolvedValue(templateRow),
- findTemplateUsages: vi.fn().mockResolvedValue([{ identityId: "identity-id", identityName: "identity" }]),
+ findTemplateUsages: vi.fn().mockResolvedValue(linkedIdentities),
updateById: vi.fn().mockImplementation((id: string, data: Record<string, unknown>) => ({
...templateRow,
id,
...data
})),
delete: vi.fn().mockResolvedValue([templateRow]),
+ create: vi.fn().mockImplementation((data: Record<string, unknown>) => ({ ...templateRow, ...data })),
transaction: vi.fn().mockImplementation(async (cb: (tx: unknown) => Promise<unknown>) => cb({}))
};
@@ -82,19 +97,21 @@ const createService = ({
};
const gatewayPoolDAL = { findById: vi.fn().mockResolvedValue(null) };
const auditLogCreate = vi.fn();
+ const identityLdapAuthDAL = { updateByTemplateId: vi.fn().mockResolvedValue([{ identityId: "identity-id" }]) };
+ const getProjectPermission = vi.fn().mockResolvedValue({ permission: createMongoAbility(projectRules) });
const service = identityAuthTemplateServiceFactory({
identityAuthTemplateDAL,
- identityLdapAuthDAL: { updateByTemplateId: vi.fn().mockResolvedValue([]) },
+ identityLdapAuthDAL,
identityKubernetesAuthDAL,
identityOidcAuthDAL,
gatewayV2DAL,
gatewayPoolDAL,
- orgDAL: { findById: vi.fn().mockResolvedValue({ requireGatewayPools: false }) },
+ orgDAL: { findById: vi.fn().mockResolvedValue({ requireGatewayPools: false, shouldUseNewPrivilegeSystem: true }) },
permissionService: {
- getOrgPermission: vi
- .fn()
- .mockResolvedValue({ permission: createMongoAbility([{ action: "manage", subject: "all" }]) })
+ getOrgPermission: vi.fn().mockResolvedValue({ permission: createMongoAbility(orgRules) }),
+ getProjectPermission,
+ getActorGrantAbilities: vi.fn().mockResolvedValue([])
},
kmsService: {
createCipherPairWithDataKey: vi.fn().mockResolvedValue({
@@ -108,7 +125,15 @@ const createService = ({
auditLogService: { createAuditLog: auditLogCreate }
} as unknown as Parameters<typeof identityAuthTemplateServiceFactory>[0]);
- return { service, identityKubernetesAuthDAL, identityOidcAuthDAL, identityAuthTemplateDAL, auditLogCreate };
+ return {
+ service,
+ identityKubernetesAuthDAL,
+ identityOidcAuthDAL,
+ identityLdapAuthDAL,
+ identityAuthTemplateDAL,
+ auditLogCreate,
+ getProjectPermission
+ };
};
const patchTemplate = (service: ReturnType<typeof createService>["service"], templateFields: Record<string, unknown>) =>
@@ -417,3 +442,182 @@ describe("identityAuthTemplateServiceFactory field patch method guard", () => {
expect(identityAuthTemplateDAL.updateById).not.toHaveBeenCalled();
});
});
+
+const LDAP_BLOB_FIELDS = { url: "ldap://8.8.8.8", bindDN: "cn=admin", bindPass: "pw", searchBase: "dc=example" };
+
+const TEMPLATE_EDITOR_RULES: RawRuleOf<MongoAbility>[] = [
+ {
+ action: OrgPermissionMachineIdentityAuthTemplateActions.EditTemplates,
+ subject: OrgPermissionSubjects.MachineIdentityAuthTemplate
+ },
+ {
+ action: OrgPermissionMachineIdentityAuthTemplateActions.CreateTemplates,
+ subject: OrgPermissionSubjects.MachineIdentityAuthTemplate
+ }
+];
+
+const ORG_IDENTITY_EDIT_AUTH_RULE: RawRuleOf<MongoAbility> = {
+ action: OrgPermissionIdentityActions.EditAuth,
+ subject: OrgPermissionSubjects.Identity
+};
+
+const PROJECT_ID = "project-id";
+const PROJECT_IDENTITY = {
+ identityId: "project-identity-id",
+ identityName: "deploy-bot",
+ identityProjectId: PROJECT_ID
+};
+
+const createLdapService = (overrides: Parameters<typeof createService>[0] = {}) =>
+ createService({
+ authMethod: IdentityAuthTemplateMethod.LDAP,
+ blobFields: LDAP_BLOB_FIELDS,
+ gatewayColumns: NO_GATEWAY,
+ ...overrides
+ });
+
+describe("identityAuthTemplateServiceFactory linked identity authorization", () => {
+ beforeEach(() => vi.clearAllMocks());
+
+ it("refuses a field patch when the editor cannot edit auth on a linked org identity", async () => {
+ const { service, identityAuthTemplateDAL, identityLdapAuthDAL, auditLogCreate } = createLdapService({
+ orgRules: TEMPLATE_EDITOR_RULES
+ });
+
+ await expect(patchTemplate(service, { url: "ldap://8.8.4.4", bindPass: "attacker" })).rejects.toBeInstanceOf(
+ ForbiddenError
+ );
+ expect(identityAuthTemplateDAL.updateById).not.toHaveBeenCalled();
+ expect(identityLdapAuthDAL.updateByTemplateId).not.toHaveBeenCalled();
+ expect(auditLogCreate).not.toHaveBeenCalled();
+ });
+
+ it("propagates when the editor also holds edit-auth on linked org identities", async () => {
+ const { service, identityLdapAuthDAL } = createLdapService({
+ orgRules: [...TEMPLATE_EDITOR_RULES, ORG_IDENTITY_EDIT_AUTH_RULE]
+ });
+
+ await patchTemplate(service, { searchBase: "dc=other" });
+
+ expect(identityLdapAuthDAL.updateByTemplateId).toHaveBeenCalledTimes(1);
+ });
+
+ it("checks a project identity against the project's edit-auth, not the org's", async () => {
+ const { service, identityLdapAuthDAL, getProjectPermission } = createLdapService({
+ orgRules: [...TEMPLATE_EDITOR_RULES, ORG_IDENTITY_EDIT_AUTH_RULE],
+ projectRules: [],
+ linkedIdentities: [PROJECT_IDENTITY]
+ });
+
+ await expect(patchTemplate(service, { searchBase: "dc=other" })).rejects.toBeInstanceOf(ForbiddenError);
+ expect(getProjectPermission).toHaveBeenCalledWith(expect.objectContaining({ projectId: PROJECT_ID }));
+ expect(identityLdapAuthDAL.updateByTemplateId).not.toHaveBeenCalled();
+ });
+
+ it("honors a project edit-auth grant scoped to the linked identity", async () => {
+ const { service, identityLdapAuthDAL } = createLdapService({
+ orgRules: TEMPLATE_EDITOR_RULES,
+ projectRules: [
+ {
+ action: ProjectPermissionIdentityActions.EditAuth,
+ subject: ProjectPermissionSub.Identity,
+ conditions: { identityId: PROJECT_IDENTITY.identityId }
+ }
+ ],
+ linkedIdentities: [PROJECT_IDENTITY]
+ });
+
+ await patchTemplate(service, { searchBase: "dc=other" });
+
+ expect(identityLdapAuthDAL.updateByTemplateId).toHaveBeenCalledTimes(1);
+ });
+
+ it("lets a rename through without edit-auth, since nothing propagates", async () => {
+ const { service, identityAuthTemplateDAL, identityLdapAuthDAL } = createLdapService({
+ orgRules: TEMPLATE_EDITOR_RULES
+ });
+
+ await service.updateTemplate({
+ templateId: TEMPLATE_ID,
+ name: "renamed",
+ actorId: "actor-id",
+ actor: "user",
+ actorAuthMethod: undefined,
+ actorOrgId: ORG_ID
+ } as unknown as Parameters<typeof service.updateTemplate>[0]);
+
+ expect(identityAuthTemplateDAL.updateById).toHaveBeenCalledTimes(1);
+ expect(identityLdapAuthDAL.updateByTemplateId).not.toHaveBeenCalled();
+ });
+
+ it("records the editor, not the platform, on the per-identity audit entries", async () => {
+ const { service, auditLogCreate } = createLdapService();
+ const auditLogInfo = {
+ ipAddress: "203.0.113.7",
+ userAgent: "test-agent",
+ actor: { type: "user", metadata: { userId: "actor-id", email: "[email protected]" } }
+ };
+
+ await service.updateTemplate({
+ templateId: TEMPLATE_ID,
+ templateFields: { searchBase: "dc=other" },
+ actorId: "actor-id",
+ actor: "user",
+ actorAuthMethod: undefined,
+ actorOrgId: ORG_ID,
+ auditLogInfo
+ } as unknown as Parameters<typeof service.updateTemplate>[0]);
+
+ expect(auditLogCreate).toHaveBeenCalledWith(expect.objectContaining({ actor: auditLogInfo.actor }));
+ });
+});
+
+describe("identityAuthTemplateServiceFactory ldap url validation", () => {
+ beforeEach(() => vi.clearAllMocks());
+
+ it("blocks a private LDAP URL on update before anything propagates", async () => {
+ const { service, identityLdapAuthDAL } = createLdapService();
+
+ await expect(patchTemplate(service, { url: "ldap://10.0.0.1", bindPass: "pw" })).rejects.toThrow(
+ "Local IPs not allowed as URL"
+ );
+ expect(identityLdapAuthDAL.updateByTemplateId).not.toHaveBeenCalled();
+ });
+
+ it("does not re-vet a stored URL the patch leaves alone, since LDAP propagates only patched keys", async () => {
+ const { service, identityLdapAuthDAL } = createLdapService({
+ blobFields: { ...LDAP_BLOB_FIELDS, url: "ldap://10.0.0.1" }
+ });
+
+ await patchTemplate(service, { searchBase: "dc=other" });
+
+ expect(identityLdapAuthDAL.updateByTemplateId).toHaveBeenCalledWith(
+ { templateId: TEMPLATE_ID },
+ { searchBase: "dc=other" },
+ expect.anything()
+ );
+ });
+
+ it("reports an unparseable LDAP URL as a client error rather than a 500", async () => {
+ const { service } = createLdapService();
+
+ await expect(patchTemplate(service, { url: "not a url", bindPass: "pw" })).rejects.toBeInstanceOf(BadRequestError);
+ });
+
+ it("blocks a private LDAP URL on create", async () => {
+ const { service, identityAuthTemplateDAL } = createLdapService();
+
+ await expect(
+ service.createTemplate({
+ name: "ldap-template",
+ authMethod: IdentityAuthTemplateMethod.LDAP,
+ templateFields: { ...LDAP_BLOB_FIELDS, url: "ldap://10.0.0.1" },
+ actorId: "actor-id",
+ actor: "user",
+ actorAuthMethod: undefined,
+ actorOrgId: ORG_ID
+ } as unknown as Parameters<typeof service.createTemplate>[0])
+ ).rejects.toThrow("Local IPs not allowed as URL");
+ expect(identityAuthTemplateDAL.create).not.toHaveBeenCalled();
+ });
+});
diff --git a/backend/src/ee/services/identity-auth-template/identity-auth-template-service.ts b/backend/src/ee/services/identity-auth-template/identity-auth-template-service.ts
index 7b2158ffdc..ece4d2769e 100644
--- a/backend/src/ee/services/identity-auth-template/identity-auth-template-service.ts
+++ b/backend/src/ee/services/identity-auth-template/identity-auth-template-service.ts
@@ -2,7 +2,7 @@ import { ForbiddenError } from "@casl/ability";
import { OrganizationActionScope, TIdentityKubernetesAuthsUpdate, TIdentityOidcAuthsUpdate } from "@app/db/schemas";
import { TIdentityAuthTemplates } from "@app/db/schemas/identity-auth-templates";
-import { EventType, TAuditLogServiceFactory } from "@app/ee/services/audit-log/audit-log-types";
+import { AuditLogInfo, EventType, TAuditLogServiceFactory } from "@app/ee/services/audit-log/audit-log-types";
import { TGatewayPoolDALFactory } from "@app/ee/services/gateway-pool/gateway-pool-dal";
import { assertIndividualGatewayAllowed } from "@app/ee/services/gateway-pool/gateway-pool-policy-fns";
import { TGatewayV2DALFactory } from "@app/ee/services/gateway-v2/gateway-v2-dal";
@@ -10,6 +10,7 @@ import { TLicenseServiceFactory } from "@app/ee/services/license/license-service
import {
OrgPermissionGatewayActions,
OrgPermissionGatewayPoolActions,
+ OrgPermissionIdentityActions,
OrgPermissionMachineIdentityAuthTemplateActions,
OrgPermissionSubjects
} from "@app/ee/services/permission/org-permission";
@@ -20,6 +21,7 @@ import { getMissingGatewayMessage } from "@app/lib/gateway-v2/gateway-errors";
import { TOrgPermission } from "@app/lib/types";
import { blockLocalAndPrivateIpAddresses } from "@app/lib/validator";
import { ActorType } from "@app/services/auth/auth-type";
+import { assertIdentityAuthAccessAllowed } from "@app/services/identity/identity-auth-permission-fns";
import { TIdentityKubernetesAuthDALFactory } from "@app/services/identity-kubernetes-auth/identity-kubernetes-auth-dal";
import { withKubernetesHostScheme } from "@app/services/identity-kubernetes-auth/identity-kubernetes-auth-fns";
import { IdentityKubernetesAuthTokenReviewMode } from "@app/services/identity-kubernetes-auth/identity-kubernetes-auth-types";
@@ -54,7 +56,10 @@ type TIdentityAuthTemplateServiceFactoryDep = {
gatewayV2DAL: Pick<TGatewayV2DALFactory, "find">;
gatewayPoolDAL: Pick<TGatewayPoolDALFactory, "findById">;
orgDAL: Pick<TOrgDALFactory, "findById">;
- permissionService: Pick<TPermissionServiceFactory, "getOrgPermission">;
+ permissionService: Pick<
+ TPermissionServiceFactory,
+ "getOrgPermission" | "getProjectPermission" | "getActorGrantAbilities"
+ >;
kmsService: Pick<TKmsServiceFactory, "createCipherPairWithDataKey" | "encryptWithInputKey" | "decryptWithInputKey">;
licenseService: Pick<TLicenseServiceFactory, "getPlan">;
auditLogService: Pick<TAuditLogServiceFactory, "createAuditLog">;
@@ -108,21 +113,19 @@ export const identityAuthTemplateServiceFactory = ({
return { ...template, templateFields: redacted } as TSanitizedIdentityAuthTemplate;
};
- // blockLocalAndPrivateIpAddresses lets a DNS failure escape as-is, so a typo'd or
- // not-yet-published discovery host would 500 instead of telling the author what to fix
- const $validateOidcDiscoveryHost = async (oidcDiscoveryUrl: string) => {
+ // a DNS failure or bad URL would otherwise escape as a 500, turn it into a 400 the author can fix
+ const $validateTemplateHost = async (url: string, fieldLabel: string) => {
try {
- await blockLocalAndPrivateIpAddresses(oidcDiscoveryUrl);
+ await blockLocalAndPrivateIpAddresses(url);
} catch (error) {
if (error instanceof BadRequestError) throw error;
throw new BadRequestError({
- message: `Could not resolve the host of the OIDC discovery URL '${oidcDiscoveryUrl}'. Check the URL and that the host resolves from Infisical.`
+ message: `Could not resolve the host of the ${fieldLabel} '${url}'. Check the URL and that the host resolves from Infisical.`
});
}
};
- // audit the platform-driven rewrite of linked identities; runs after the propagation
- // transaction commits so the tx never waits on Redis, chunked to bound concurrency
+ // runs after the propagation tx commits so it never waits on Redis, chunked to bound concurrency
const $templatePropagationEvent = (
authMethod: string,
metadata: { identityId: string; identityName?: string; templateId: string; templateName: string }
@@ -142,23 +145,22 @@ export const identityAuthTemplateServiceFactory = ({
authMethod,
templateId,
templateName,
- orgId
+ orgId,
+ auditLogInfo
}: {
identities: { identityId: string; identityName?: string }[];
authMethod: string;
templateId: string;
templateName: string;
orgId: string;
+ auditLogInfo?: AuditLogInfo;
}) => {
for (const batch of chunkArray(identities, AUDIT_FANOUT_CHUNK_SIZE)) {
// eslint-disable-next-line no-await-in-loop
await Promise.all(
batch.map(({ identityId, identityName }) =>
auditLogService.createAuditLog({
- actor: {
- type: ActorType.PLATFORM,
- metadata: {}
- },
+ ...(auditLogInfo ?? { actor: { type: ActorType.PLATFORM, metadata: {} } }),
orgId,
event: $templatePropagationEvent(authMethod, { identityId, identityName, templateId, templateName })
})
@@ -354,7 +356,12 @@ export const identityAuthTemplateServiceFactory = ({
if (authMethod === IdentityAuthTemplateMethod.OIDC) {
// parity with the identity attach flow: a template-authored discovery URL must not
// let the backend dial local or private addresses
- await $validateOidcDiscoveryHost((templateFields as TOidcTemplateFields).oidcDiscoveryUrl);
+ await $validateTemplateHost((templateFields as TOidcTemplateFields).oidcDiscoveryUrl, "OIDC discovery URL");
+ }
+
+ if (authMethod === IdentityAuthTemplateMethod.LDAP) {
+ // attach blocks private LDAP URLs but trusts a template's, so vet it here
+ await $validateTemplateHost((templateFields as TLdapTemplateFields).url, "LDAP URL");
}
const { encryptor } = await kmsService.createCipherPairWithDataKey({
@@ -380,11 +387,13 @@ export const identityAuthTemplateServiceFactory = ({
actorId,
actorAuthMethod,
actor,
- actorOrgId
+ actorOrgId,
+ auditLogInfo
}: {
templateId: string;
name?: string;
templateFields?: Record<string, unknown>;
+ auditLogInfo?: AuditLogInfo;
} & Omit<TOrgPermission, "orgId">) => {
const plan = await $checkPlan(actorOrgId);
const template = await identityAuthTemplateDAL.findByIdAndOrgId(templateId, actorOrgId);
@@ -429,9 +438,31 @@ export const identityAuthTemplateServiceFactory = ({
? ((await identityAuthTemplateDAL.findTemplateUsages(templateId, template.authMethod)) as {
identityId: string;
identityName: string;
+ identityProjectId: string | null;
}[])
: [];
+ // a field patch rewrites every linked identity's auth, so the editor needs edit-auth on each.
+ // otherwise EditTemplates alone lets you point them at an LDAP server or OIDC issuer you control
+ // and log in as them
+ for (const { identityId, identityProjectId } of linkedIdentities) {
+ // eslint-disable-next-line no-await-in-loop
+ await assertIdentityAuthAccessAllowed(
+ { permissionService, orgDAL },
+ {
+ identityId,
+ orgId: template.orgId,
+ projectId: identityProjectId,
+ action: OrgPermissionIdentityActions.EditAuth,
+ baseMessage: "Failed to update auth template linked to identity with more privileged role",
+ actor,
+ actorId,
+ actorAuthMethod,
+ actorOrgId
+ }
+ );
+ }
+
const currentTemplateFields = $withGatewayFields(
template,
JSON.parse(decryptor({ cipherTextBlob: template.templateFields }).toString()) as Record<string, unknown>
@@ -532,6 +563,11 @@ export const identityAuthTemplateServiceFactory = ({
"Changing an LDAP auth template's URL requires supplying bindPass. The stored bind password cannot be read back, and the new URL is applied to every identity linked to this template."
});
}
+
+ // LDAP only propagates patched keys, so an untouched URL never reaches the identities
+ if ("url" in fieldPatch) {
+ await $validateTemplateHost(merged.url, "LDAP URL");
+ }
}
let oidcPropagationData: TIdentityOidcAuthsUpdate | undefined;
@@ -541,7 +577,7 @@ export const identityAuthTemplateServiceFactory = ({
// every propagation rather than only when the patch touches it (login re-validates
// before dialing, but the template must never store a URL its author could not
// have set directly)
- await $validateOidcDiscoveryHost(merged.oidcDiscoveryUrl);
+ await $validateTemplateHost(merged.oidcDiscoveryUrl, "OIDC discovery URL");
oidcPropagationData = {
oidcDiscoveryUrl: merged.oidcDiscoveryUrl,
boundIssuer: merged.boundIssuer,
@@ -634,7 +670,8 @@ export const identityAuthTemplateServiceFactory = ({
authMethod: template.authMethod,
templateId: template.id,
templateName: template.name,
- orgId: template.orgId
+ orgId: template.orgId,
+ auditLogInfo
});
return $sanitizeTemplate(updatedTemplate, mergedTemplateFields);
@@ -645,7 +682,8 @@ export const identityAuthTemplateServiceFactory = ({
actorId,
actorAuthMethod,
actor,
- actorOrgId
+ actorOrgId,
+ auditLogInfo
}: TDeleteIdentityAuthTemplateDTO) => {
await $checkPlan(actorOrgId);
const template = await identityAuthTemplateDAL.findByIdAndOrgId(templateId, actorOrgId);
@@ -708,7 +746,8 @@ export const identityAuthTemplateServiceFactory = ({
authMethod: template.authMethod,
templateId: template.id,
templateName: template.name,
- orgId: template.orgId
+ orgId: template.orgId,
+ auditLogInfo
});
return { ...deletedTemplate, templateFields: {} };
@@ -863,7 +902,8 @@ export const identityAuthTemplateServiceFactory = ({
actorId,
actorAuthMethod,
actor,
- actorOrgId
+ actorOrgId,
+ auditLogInfo
}: TUnlinkTemplateUsageDTO) => {
await $checkPlan(actorOrgId);
const { permission } = await permissionService.getOrgPermission({
@@ -923,7 +963,8 @@ export const identityAuthTemplateServiceFactory = ({
authMethod: template.authMethod,
templateId: template.id,
templateName: template.name,
- orgId: template.orgId
+ orgId: template.orgId,
+ auditLogInfo
});
};
diff --git a/backend/src/ee/services/identity-auth-template/identity-auth-template-types.ts b/backend/src/ee/services/identity-auth-template/identity-auth-template-types.ts
index c330a5c266..6a4f4c805a 100644
--- a/backend/src/ee/services/identity-auth-template/identity-auth-template-types.ts
+++ b/backend/src/ee/services/identity-auth-template/identity-auth-template-types.ts
@@ -1,6 +1,7 @@
import { z } from "zod";
import { TIdentityAuthTemplates } from "@app/db/schemas/identity-auth-templates";
+import { AuditLogInfo } from "@app/ee/services/audit-log/audit-log-types";
import { TProjectPermission } from "@app/lib/types";
import { IdentityKubernetesAuthTokenReviewMode } from "@app/services/identity-kubernetes-auth/identity-kubernetes-auth-types";
@@ -61,6 +62,7 @@ export type TOidcTemplateFields = {
export type TDeleteIdentityAuthTemplateDTO = {
templateId: string;
+ auditLogInfo?: AuditLogInfo;
} & Omit<TProjectPermission, "projectId">;
export type TGetIdentityAuthTemplateDTO = {
@@ -84,4 +86,5 @@ export type TFindTemplateUsagesDTO = {
export type TUnlinkTemplateUsageDTO = {
templateId: string;
identityIds: string[];
+ auditLogInfo?: AuditLogInfo;
} & Omit<TProjectPermission, "projectId">;
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 40cccbb6a5..54c9806032 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
@@ -288,35 +288,6 @@ export const identityAliCloudAuthServiceFactory = ({
throw new BadRequestError({ message: "Access token TTL cannot be greater than max TTL" });
}
- if (identityMembershipOrg.identity.projectId) {
- const { permission } = await permissionService.getProjectPermission({
- actionProjectType: ActionProjectType.Any,
- actor,
- actorId,
- projectId: identityMembershipOrg.identity.projectId,
- actorAuthMethod,
- actorOrgId
- });
-
- ForbiddenError.from(permission).throwUnlessCan(
- ProjectPermissionIdentityActions.EditAuth,
- subject(ProjectPermissionSub.Identity, { identityId })
- );
- } else {
- const { permission } = await permissionService.getOrgPermission({
- scope: OrganizationActionScope.Any,
- actor,
- actorId,
- orgId: identityMembershipOrg.scopeOrgId,
- actorAuthMethod,
- actorOrgId
- });
- ForbiddenError.from(permission).throwUnlessCan(
- OrgPermissionIdentityActions.EditAuth,
- OrgPermissionSubjects.Identity
- );
- }
-
await assertIdentityAuthAccessAllowed(
{ permissionService, orgDAL },
{
@@ -422,35 +393,6 @@ export const identityAliCloudAuthServiceFactory = ({
throw new BadRequestError({ message: "Access token TTL cannot be greater than max TTL" });
}
- if (identityMembershipOrg.identity.projectId) {
- const { permission } = await permissionService.getProjectPermission({
- actionProjectType: ActionProjectType.Any,
- actor,
- actorId,
- projectId: identityMembershipOrg.identity.projectId,
- actorAuthMethod,
- actorOrgId
- });
-
- ForbiddenError.from(permission).throwUnlessCan(
- ProjectPermissionIdentityActions.EditAuth,
- subject(ProjectPermissionSub.Identity, { identityId })
- );
- } else {
- const { permission } = await permissionService.getOrgPermission({
- scope: OrganizationActionScope.Any,
- actor,
- actorId,
- orgId: identityMembershipOrg.scopeOrgId,
- actorAuthMethod,
- actorOrgId
- });
- ForbiddenError.from(permission).throwUnlessCan(
- OrgPermissionIdentityActions.EditAuth,
- OrgPermissionSubjects.Identity
- );
- }
-
await assertIdentityAuthAccessAllowed(
{ permissionService, orgDAL },
{
@@ -591,32 +533,6 @@ export const identityAliCloudAuthServiceFactory = ({
message: "The identity does not have Alibaba Cloud auth"
});
}
- if (identityMembershipOrg.identity.projectId) {
- const { permission } = await permissionService.getProjectPermission({
- actionProjectType: ActionProjectType.Any,
- actor,
- actorId,
- projectId: identityMembershipOrg.identity.projectId,
- actorAuthMethod,
- actorOrgId
- });
-
- ForbiddenError.from(permission).throwUnlessCan(
- ProjectPermissionIdentityActions.RevokeAuth,
- subject(ProjectPermissionSub.Identity, { identityId })
- );
- } else {
- const { permission } = await permissionService.getOrgPermission({
- scope: OrganizationActionScope.Any,
- actor,
- actorId,
- orgId: identityMembershipOrg.scopeOrgId,
- actorAuthMethod,
- actorOrgId
- });
- ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Edit, OrgPermissionSubjects.Identity);
- }
-
await assertIdentityAuthAccessAllowed(
{ permissionService, orgDAL },
{
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 d61120993a..e22529eba2 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
@@ -382,35 +382,6 @@ export const identityAwsAuthServiceFactory = ({
throw new BadRequestError({ message: "Access token TTL cannot be greater than max TTL" });
}
- if (identityMembershipOrg.identity.projectId) {
- const { permission } = await permissionService.getProjectPermission({
- actionProjectType: ActionProjectType.Any,
- actor,
- actorId,
- projectId: identityMembershipOrg.identity.projectId,
- actorAuthMethod,
- actorOrgId
- });
-
- ForbiddenError.from(permission).throwUnlessCan(
- ProjectPermissionIdentityActions.EditAuth,
- subject(ProjectPermissionSub.Identity, { identityId })
- );
- } else {
- const { permission } = await permissionService.getOrgPermission({
- actor,
- actorId,
- orgId: identityMembershipOrg.scopeOrgId,
- actorAuthMethod,
- actorOrgId,
- scope: OrganizationActionScope.Any
- });
- ForbiddenError.from(permission).throwUnlessCan(
- OrgPermissionIdentityActions.EditAuth,
- OrgPermissionSubjects.Identity
- );
- }
-
await assertIdentityAuthAccessAllowed(
{ permissionService, orgDAL },
{
@@ -519,35 +490,6 @@ export const identityAwsAuthServiceFactory = ({
throw new BadRequestError({ message: "Access token TTL cannot be greater than max TTL" });
}
- if (identityMembershipOrg.identity.projectId) {
- const { permission } = await permissionService.getProjectPermission({
- actionProjectType: ActionProjectType.Any,
- actor,
- actorId,
- projectId: identityMembershipOrg.identity.projectId,
- actorAuthMethod,
- actorOrgId
- });
-
- ForbiddenError.from(permission).throwUnlessCan(
- ProjectPermissionIdentityActions.EditAuth,
- subject(ProjectPermissionSub.Identity, { identityId })
- );
- } else {
- const { permission } = await permissionService.getOrgPermission({
- scope: OrganizationActionScope.Any,
- actor,
- actorId,
- orgId: identityMembershipOrg.scopeOrgId,
- actorAuthMethod,
- actorOrgId
- });
- ForbiddenError.from(permission).throwUnlessCan(
- OrgPermissionIdentityActions.EditAuth,
- OrgPermissionSubjects.Identity
- );
- }
-
await assertIdentityAuthAccessAllowed(
{ permissionService, orgDAL },
{
@@ -690,32 +632,6 @@ export const identityAwsAuthServiceFactory = ({
message: "The identity does not have aws auth"
});
}
- if (identityMembershipOrg.identity.projectId) {
- const { permission } = await permissionService.getProjectPermission({
- actionProjectType: ActionProjectType.Any,
- actor,
- actorId,
- projectId: identityMembershipOrg.identity.projectId,
- actorAuthMethod,
- actorOrgId
- });
-
- ForbiddenError.from(permission).throwUnlessCan(
- ProjectPermissionIdentityActions.RevokeAuth,
- subject(ProjectPermissionSub.Identity, { identityId })
- );
- } else {
- const { permission } = await permissionService.getOrgPermission({
- scope: OrganizationActionScope.Any,
- actor,
- actorId,
- orgId: identityMembershipOrg.scopeOrgId,
- actorAuthMethod,
- actorOrgId
- });
- ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Edit, OrgPermissionSubjects.Identity);
- }
-
await assertIdentityAuthAccessAllowed(
{ permissionService, orgDAL },
{
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 7380c58393..ce8648e469 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
@@ -283,35 +283,6 @@ export const identityAzureAuthServiceFactory = ({
throw new BadRequestError({ message: "Access token TTL cannot be greater than max TTL" });
}
- if (identityMembershipOrg.identity.projectId) {
- const { permission } = await permissionService.getProjectPermission({
- actionProjectType: ActionProjectType.Any,
- actor,
- actorId,
- projectId: identityMembershipOrg.identity.projectId,
- actorAuthMethod,
- actorOrgId
- });
-
- ForbiddenError.from(permission).throwUnlessCan(
- ProjectPermissionIdentityActions.EditAuth,
- subject(ProjectPermissionSub.Identity, { identityId })
- );
- } else {
- const { permission } = await permissionService.getOrgPermission({
- scope: OrganizationActionScope.Any,
- actor,
- actorId,
- orgId: identityMembershipOrg.scopeOrgId,
- actorAuthMethod,
- actorOrgId
- });
- ForbiddenError.from(permission).throwUnlessCan(
- OrgPermissionIdentityActions.EditAuth,
- OrgPermissionSubjects.Identity
- );
- }
-
await assertIdentityAuthAccessAllowed(
{ permissionService, orgDAL },
{
@@ -420,35 +391,6 @@ export const identityAzureAuthServiceFactory = ({
throw new BadRequestError({ message: "Access token TTL cannot be greater than max TTL" });
}
- if (identityMembershipOrg.identity.projectId) {
- const { permission } = await permissionService.getProjectPermission({
- actionProjectType: ActionProjectType.Any,
- actor,
- actorId,
- projectId: identityMembershipOrg.identity.projectId,
- actorAuthMethod,
- actorOrgId
- });
-
- ForbiddenError.from(permission).throwUnlessCan(
- ProjectPermissionIdentityActions.EditAuth,
- subject(ProjectPermissionSub.Identity, { identityId })
- );
- } else {
- const { permission } = await permissionService.getOrgPermission({
- scope: OrganizationActionScope.Any,
- actor,
- actorId,
- orgId: identityMembershipOrg.scopeOrgId,
- actorAuthMethod,
- actorOrgId
- });
- ForbiddenError.from(permission).throwUnlessCan(
- OrgPermissionIdentityActions.EditAuth,
- OrgPermissionSubjects.Identity
- );
- }
-
await assertIdentityAuthAccessAllowed(
{ permissionService, orgDAL },
{
@@ -593,32 +535,6 @@ export const identityAzureAuthServiceFactory = ({
message: "The identity does not have azure auth"
});
}
- if (identityMembershipOrg.identity.projectId) {
- const { permission } = await permissionService.getProjectPermission({
- actionProjectType: ActionProjectType.Any,
- actor,
- actorId,
- projectId: identityMembershipOrg.identity.projectId,
- actorAuthMethod,
- actorOrgId
- });
-
- ForbiddenError.from(permission).throwUnlessCan(
- ProjectPermissionIdentityActions.RevokeAuth,
- subject(ProjectPermissionSub.Identity, { identityId })
- );
- } else {
- const { permission } = await permissionService.getOrgPermission({
- scope: OrganizationActionScope.Any,
- actor,
- actorId,
- orgId: identityMembershipOrg.scopeOrgId,
- actorAuthMethod,
- actorOrgId
- });
- ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Edit, OrgPermissionSubjects.Identity);
- }
-
await assertIdentityAuthAccessAllowed(
{ permissionService, orgDAL },
{
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 7a2b07d23c..54979b2d17 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
@@ -340,35 +340,6 @@ export const identityGcpAuthServiceFactory = ({
throw new BadRequestError({ message: "Access token TTL cannot be greater than max TTL" });
}
- if (identityMembershipOrg.identity.projectId) {
- const { permission } = await permissionService.getProjectPermission({
- actionProjectType: ActionProjectType.Any,
- actor,
- actorId,
- projectId: identityMembershipOrg.identity.projectId,
- actorAuthMethod,
- actorOrgId
- });
-
- ForbiddenError.from(permission).throwUnlessCan(
- ProjectPermissionIdentityActions.EditAuth,
- subject(ProjectPermissionSub.Identity, { identityId })
- );
- } else {
- const { permission } = await permissionService.getOrgPermission({
- scope: OrganizationActionScope.Any,
- actor,
- actorId,
- orgId: identityMembershipOrg.scopeOrgId,
- actorAuthMethod,
- actorOrgId
- });
- ForbiddenError.from(permission).throwUnlessCan(
- OrgPermissionIdentityActions.EditAuth,
- OrgPermissionSubjects.Identity
- );
- }
-
await assertIdentityAuthAccessAllowed(
{ permissionService, orgDAL },
{
@@ -478,35 +449,6 @@ export const identityGcpAuthServiceFactory = ({
throw new BadRequestError({ message: "Access token TTL cannot be greater than max TTL" });
}
- if (identityMembershipOrg.identity.projectId) {
- const { permission } = await permissionService.getProjectPermission({
- actionProjectType: ActionProjectType.Any,
- actor,
- actorId,
- projectId: identityMembershipOrg.identity.projectId,
- actorAuthMethod,
- actorOrgId
- });
-
- ForbiddenError.from(permission).throwUnlessCan(
- ProjectPermissionIdentityActions.EditAuth,
- subject(ProjectPermissionSub.Identity, { identityId })
- );
- } else {
- const { permission } = await permissionService.getOrgPermission({
- scope: OrganizationActionScope.Any,
- actor,
- actorId,
- orgId: identityMembershipOrg.scopeOrgId,
- actorAuthMethod,
- actorOrgId
- });
- ForbiddenError.from(permission).throwUnlessCan(
- OrgPermissionIdentityActions.EditAuth,
- OrgPermissionSubjects.Identity
- );
- }
-
await assertIdentityAuthAccessAllowed(
{ permissionService, orgDAL },
{
@@ -653,32 +595,6 @@ export const identityGcpAuthServiceFactory = ({
message: "The identity does not have gcp auth"
});
}
- if (identityMembershipOrg.identity.projectId) {
- const { permission } = await permissionService.getProjectPermission({
- actionProjectType: ActionProjectType.Any,
- actor,
- actorId,
- projectId: identityMembershipOrg.identity.projectId,
- actorAuthMethod,
- actorOrgId
- });
-
- ForbiddenError.from(permission).throwUnlessCan(
- ProjectPermissionIdentityActions.RevokeAuth,
- subject(ProjectPermissionSub.Identity, { identityId })
- );
- } else {
- const { permission } = await permissionService.getOrgPermission({
- scope: OrganizationActionScope.Any,
- actor,
- actorId,
- orgId: identityMembershipOrg.scopeOrgId,
- actorAuthMethod,
- actorOrgId
- });
- ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Edit, OrgPermissionSubjects.Identity);
- }
-
await assertIdentityAuthAccessAllowed(
{ permissionService, orgDAL },
{
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 7c5d3f2722..d72dae2311 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
@@ -453,36 +453,6 @@ export const identityJwtAuthServiceFactory = ({
throw new BadRequestError({ message: "Access token TTL cannot be greater than max TTL" });
}
- if (identityMembershipOrg.identity.projectId) {
- const { permission } = await permissionService.getProjectPermission({
- actionProjectType: ActionProjectType.Any,
- actor,
- actorId,
- projectId: identityMembershipOrg.identity.projectId,
- actorAuthMethod,
- actorOrgId
- });
-
- ForbiddenError.from(permission).throwUnlessCan(
- ProjectPermissionIdentityActions.EditAuth,
- subject(ProjectPermissionSub.Identity, { identityId })
- );
- } else {
- const { permission } = await permissionService.getOrgPermission({
- scope: OrganizationActionScope.Any,
- actor,
- actorId,
- orgId: identityMembershipOrg.scopeOrgId,
- actorAuthMethod,
- actorOrgId
- });
-
- ForbiddenError.from(permission).throwUnlessCan(
- OrgPermissionIdentityActions.EditAuth,
- OrgPermissionSubjects.Identity
- );
- }
-
await assertIdentityAuthAccessAllowed(
{ permissionService, orgDAL },
{
@@ -619,36 +589,6 @@ export const identityJwtAuthServiceFactory = ({
throw new BadRequestError({ message: "Access token TTL cannot be greater than max TTL" });
}
- if (identityMembershipOrg.identity.projectId) {
- const { permission } = await permissionService.getProjectPermission({
- actionProjectType: ActionProjectType.Any,
- actor,
- actorId,
- projectId: identityMembershipOrg.identity.projectId,
- actorAuthMethod,
- actorOrgId
- });
-
- ForbiddenError.from(permission).throwUnlessCan(
- ProjectPermissionIdentityActions.EditAuth,
- subject(ProjectPermissionSub.Identity, { identityId })
- );
- } else {
- const { permission } = await permissionService.getOrgPermission({
- scope: OrganizationActionScope.Any,
- actor,
- actorId,
- orgId: identityMembershipOrg.scopeOrgId,
- actorAuthMethod,
- actorOrgId
- });
-
- ForbiddenError.from(permission).throwUnlessCan(
- OrgPermissionIdentityActions.EditAuth,
- OrgPermissionSubjects.Identity
- );
- }
-
await assertIdentityAuthAccessAllowed(
{ permissionService, orgDAL },
{
@@ -846,33 +786,6 @@ export const identityJwtAuthServiceFactory = ({
});
}
- if (identityMembershipOrg.identity.projectId) {
- const { permission } = await permissionService.getProjectPermission({
- actionProjectType: ActionProjectType.Any,
- actor,
- actorId,
- projectId: identityMembershipOrg.identity.projectId,
- actorAuthMethod,
- actorOrgId
- });
-
- ForbiddenError.from(permission).throwUnlessCan(
- ProjectPermissionIdentityActions.RevokeAuth,
- subject(ProjectPermissionSub.Identity, { identityId })
- );
- } else {
- const { permission } = await permissionService.getOrgPermission({
- scope: OrganizationActionScope.Any,
- actor,
- actorId,
- orgId: identityMembershipOrg.scopeOrgId,
- actorAuthMethod,
- actorOrgId
- });
-
- ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Edit, OrgPermissionSubjects.Identity);
- }
-
await assertIdentityAuthAccessAllowed(
{ permissionService, orgDAL },
{
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 d4ac428eba..ba900129c4 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
@@ -850,35 +850,6 @@ export const identityKubernetesAuthServiceFactory = ({
throw new BadRequestError({ message: "Access token TTL cannot be greater than max TTL" });
}
- if (identityMembershipOrg.identity.projectId) {
- const { permission } = await permissionService.getProjectPermission({
- actionProjectType: ActionProjectType.Any,
- actor,
- actorId,
- projectId: identityMembershipOrg.identity.projectId,
- actorAuthMethod,
- actorOrgId
- });
-
- ForbiddenError.from(permission).throwUnlessCan(
- ProjectPermissionIdentityActions.EditAuth,
- subject(ProjectPermissionSub.Identity, { identityId })
- );
- } else {
- const { permission } = await permissionService.getOrgPermission({
- scope: OrganizationActionScope.Any,
- actor,
- actorId,
- orgId: identityMembershipOrg.scopeOrgId,
- actorAuthMethod,
- actorOrgId
- });
- ForbiddenError.from(permission).throwUnlessCan(
- OrgPermissionIdentityActions.EditAuth,
- OrgPermissionSubjects.Identity
- );
- }
-
await assertIdentityAuthAccessAllowed(
{ permissionService, orgDAL },
{
@@ -1218,35 +1189,6 @@ export const identityKubernetesAuthServiceFactory = ({
throw new BadRequestError({ message: "Access token TTL cannot be greater than max TTL" });
}
- if (identityMembershipOrg.identity.projectId) {
- const { permission } = await permissionService.getProjectPermission({
- actionProjectType: ActionProjectType.Any,
- actor,
- actorId,
- projectId: identityMembershipOrg.identity.projectId,
- actorAuthMethod,
- actorOrgId
- });
-
- ForbiddenError.from(permission).throwUnlessCan(
- ProjectPermissionIdentityActions.EditAuth,
- subject(ProjectPermissionSub.Identity, { identityId })
- );
- } else {
- const { permission } = await permissionService.getOrgPermission({
- scope: OrganizationActionScope.Any,
- actor,
- actorId,
- orgId: identityMembershipOrg.scopeOrgId,
- actorAuthMethod,
- actorOrgId
- });
- ForbiddenError.from(permission).throwUnlessCan(
- OrgPermissionIdentityActions.EditAuth,
- OrgPermissionSubjects.Identity
- );
- }
-
await assertIdentityAuthAccessAllowed(
{ permissionService, orgDAL },
{
@@ -1793,32 +1735,6 @@ export const identityKubernetesAuthServiceFactory = ({
message: "The identity does not have kubernetes auth"
});
}
- if (identityMembershipOrg.identity.projectId) {
- const { permission } = await permissionService.getProjectPermission({
- actionProjectType: ActionProjectType.Any,
- actor,
- actorId,
- projectId: identityMembershipOrg.identity.projectId,
- actorAuthMethod,
- actorOrgId
- });
-
- ForbiddenError.from(permission).throwUnlessCan(
- ProjectPermissionIdentityActions.RevokeAuth,
- subject(ProjectPermissionSub.Identity, { identityId })
- );
- } else {
- const { permission } = await permissionService.getOrgPermission({
- scope: OrganizationActionScope.Any,
- actor,
- actorId,
- orgId: identityMembershipOrg.scopeOrgId,
- actorAuthMethod,
- actorOrgId
- });
- ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Edit, OrgPermissionSubjects.Identity);
- }
-
await assertIdentityAuthAccessAllowed(
{ permissionService, orgDAL },
{
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 e99db681e4..44a7473dbf 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
@@ -378,27 +378,6 @@ export const identityLdapAuthServiceFactory = ({
actorOrgId
});
- if (identityMembershipOrg.identity.projectId) {
- const { permission: projectPermission } = await permissionService.getProjectPermission({
- actionProjectType: ActionProjectType.Any,
- actor,
- actorId,
- projectId: identityMembershipOrg.identity.projectId,
- actorAuthMethod,
- actorOrgId
- });
-
- ForbiddenError.from(projectPermission).throwUnlessCan(
- ProjectPermissionIdentityActions.EditAuth,
- subject(ProjectPermissionSub.Identity, { identityId })
- );
- } else {
- ForbiddenError.from(orgPermission).throwUnlessCan(
- OrgPermissionIdentityActions.EditAuth,
- OrgPermissionSubjects.Identity
- );
- }
-
await assertIdentityAuthAccessAllowed(
{ permissionService, orgDAL },
{
@@ -627,27 +606,6 @@ export const identityLdapAuthServiceFactory = ({
actorOrgId
});
- if (identityMembershipOrg.identity.projectId) {
- const { permission: projectPermission } = await permissionService.getProjectPermission({
- actionProjectType: ActionProjectType.Any,
- actor,
- actorId,
- projectId: identityMembershipOrg.identity.projectId,
- actorAuthMethod,
- actorOrgId
- });
-
- ForbiddenError.from(projectPermission).throwUnlessCan(
- ProjectPermissionIdentityActions.EditAuth,
- subject(ProjectPermissionSub.Identity, { identityId })
- );
- } else {
- ForbiddenError.from(orgPermission).throwUnlessCan(
- OrgPermissionIdentityActions.EditAuth,
- OrgPermissionSubjects.Identity
- );
- }
-
await assertIdentityAuthAccessAllowed(
{ permissionService, orgDAL },
{
@@ -920,32 +878,6 @@ export const identityLdapAuthServiceFactory = ({
});
}
- if (identityMembershipOrg.identity.projectId) {
- const { permission } = await permissionService.getProjectPermission({
- actionProjectType: ActionProjectType.Any,
- actor,
- actorId,
- projectId: identityMembershipOrg.identity.projectId,
- actorAuthMethod,
- actorOrgId
- });
-
- ForbiddenError.from(permission).throwUnlessCan(
- ProjectPermissionIdentityActions.RevokeAuth,
- subject(ProjectPermissionSub.Identity, { identityId })
- );
- } else {
- const { permission } = await permissionService.getOrgPermission({
- scope: OrganizationActionScope.Any,
- actor,
- actorId,
- orgId: identityMembershipOrg.scopeOrgId,
- actorAuthMethod,
- actorOrgId
- });
- ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Edit, OrgPermissionSubjects.Identity);
- }
-
await assertIdentityAuthAccessAllowed(
{ permissionService, orgDAL },
{
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 8f0d2cbd2b..75cc7b11cc 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
@@ -320,35 +320,6 @@ export const identityOciAuthServiceFactory = ({
throw new BadRequestError({ message: "Access token TTL cannot be greater than max TTL" });
}
- if (identityMembershipOrg.identity.projectId) {
- const { permission } = await permissionService.getProjectPermission({
- actionProjectType: ActionProjectType.Any,
- actor,
- actorId,
- projectId: identityMembershipOrg.identity.projectId,
- actorAuthMethod,
- actorOrgId
- });
-
- ForbiddenError.from(permission).throwUnlessCan(
- ProjectPermissionIdentityActions.EditAuth,
- subject(ProjectPermissionSub.Identity, { identityId })
- );
- } else {
- const { permission } = await permissionService.getOrgPermission({
- scope: OrganizationActionScope.Any,
- actor,
- actorId,
- orgId: identityMembershipOrg.scopeOrgId,
- actorAuthMethod,
- actorOrgId
- });
- ForbiddenError.from(permission).throwUnlessCan(
- OrgPermissionIdentityActions.EditAuth,
- OrgPermissionSubjects.Identity
- );
- }
-
await assertIdentityAuthAccessAllowed(
{ permissionService, orgDAL },
{
@@ -456,35 +427,6 @@ export const identityOciAuthServiceFactory = ({
throw new BadRequestError({ message: "Access token TTL cannot be greater than max TTL" });
}
- if (identityMembershipOrg.identity.projectId) {
- const { permission } = await permissionService.getProjectPermission({
- actionProjectType: ActionProjectType.Any,
- actor,
- actorId,
- projectId: identityMembershipOrg.identity.projectId,
- actorAuthMethod,
- actorOrgId
- });
-
- ForbiddenError.from(permission).throwUnlessCan(
- ProjectPermissionIdentityActions.EditAuth,
- subject(ProjectPermissionSub.Identity, { identityId })
- );
- } else {
- const { permission } = await permissionService.getOrgPermission({
- scope: OrganizationActionScope.Any,
- actor,
- actorId,
- orgId: identityMembershipOrg.scopeOrgId,
- actorAuthMethod,
- actorOrgId
- });
- ForbiddenError.from(permission).throwUnlessCan(
- OrgPermissionIdentityActions.EditAuth,
- OrgPermissionSubjects.Identity
- );
- }
-
await assertIdentityAuthAccessAllowed(
{ permissionService, orgDAL },
{
@@ -628,32 +570,6 @@ export const identityOciAuthServiceFactory = ({
});
}
- if (identityMembershipOrg.identity.projectId) {
- const { permission } = await permissionService.getProjectPermission({
- actionProjectType: ActionProjectType.Any,
- actor,
- actorId,
- projectId: identityMembershipOrg.identity.projectId,
- actorAuthMethod,
- actorOrgId
- });
-
- ForbiddenError.from(permission).throwUnlessCan(
- ProjectPermissionIdentityActions.RevokeAuth,
- subject(ProjectPermissionSub.Identity, { identityId })
- );
- } else {
- const { permission } = await permissionService.getOrgPermission({
- scope: OrganizationActionScope.Any,
- actor,
- actorId,
- orgId: identityMembershipOrg.scopeOrgId,
- actorAuthMethod,
- actorOrgId
- });
- ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Edit, OrgPermissionSubjects.Identity);
- }
-
await assertIdentityAuthAccessAllowed(
{ permissionService, orgDAL },
{
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 ffd4b822d7..6f6d5c3892 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
@@ -639,36 +639,6 @@ export const identityOidcAuthServiceFactory = ({
throw new BadRequestError({ message: "Access token TTL cannot be greater than max TTL" });
}
- if (identityMembershipOrg.identity.projectId) {
- const { permission } = await permissionService.getProjectPermission({
- actionProjectType: ActionProjectType.Any,
- actor,
- actorId,
- projectId: identityMembershipOrg.identity.projectId,
- actorAuthMethod,
- actorOrgId
- });
-
- ForbiddenError.from(permission).throwUnlessCan(
- ProjectPermissionIdentityActions.EditAuth,
- subject(ProjectPermissionSub.Identity, { identityId })
- );
- } else {
- const { permission } = await permissionService.getOrgPermission({
- scope: OrganizationActionScope.Any,
- actor,
- actorId,
- orgId: identityMembershipOrg.scopeOrgId,
- actorAuthMethod,
- actorOrgId
- });
-
- ForbiddenError.from(permission).throwUnlessCan(
- OrgPermissionIdentityActions.EditAuth,
- OrgPermissionSubjects.Identity
- );
- }
-
await assertIdentityAuthAccessAllowed(
{ permissionService, orgDAL },
{
@@ -855,36 +825,6 @@ export const identityOidcAuthServiceFactory = ({
throw new BadRequestError({ message: "Access token TTL cannot be greater than max TTL" });
}
- if (identityMembershipOrg.identity.projectId) {
- const { permission } = await permissionService.getProjectPermission({
- actionProjectType: ActionProjectType.Any,
- actor,
- actorId,
- projectId: identityMembershipOrg.identity.projectId,
- actorAuthMethod,
- actorOrgId
- });
-
- ForbiddenError.from(permission).throwUnlessCan(
- ProjectPermissionIdentityActions.EditAuth,
- subject(ProjectPermissionSub.Identity, { identityId })
- );
- } else {
- const { permission } = await permissionService.getOrgPermission({
- scope: OrganizationActionScope.Any,
- actor,
- actorId,
- orgId: identityMembershipOrg.scopeOrgId,
- actorAuthMethod,
- actorOrgId
- });
-
- ForbiddenError.from(permission).throwUnlessCan(
- OrgPermissionIdentityActions.EditAuth,
- OrgPermissionSubjects.Identity
- );
- }
-
await assertIdentityAuthAccessAllowed(
{ permissionService, orgDAL },
{
@@ -1141,33 +1081,6 @@ export const identityOidcAuthServiceFactory = ({
});
}
- if (identityMembershipOrg.identity.projectId) {
- const { permission } = await permissionService.getProjectPermission({
- actionProjectType: ActionProjectType.Any,
- actor,
- actorId,
- projectId: identityMembershipOrg.identity.projectId,
- actorAuthMethod,
- actorOrgId
- });
-
- ForbiddenError.from(permission).throwUnlessCan(
- ProjectPermissionIdentityActions.RevokeAuth,
- subject(ProjectPermissionSub.Identity, { identityId })
- );
- } else {
- const { permission } = await permissionService.getOrgPermission({
- scope: OrganizationActionScope.Any,
- actor,
- actorId,
- orgId: identityMembershipOrg.scopeOrgId,
- actorAuthMethod,
- actorOrgId
- });
-
- ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Edit, OrgPermissionSubjects.Identity);
- }
-
await assertIdentityAuthAccessAllowed(
{ permissionService, orgDAL },
{
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 23ebabd066..8a3004309d 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
@@ -531,36 +531,6 @@ export const identitySpiffeAuthServiceFactory = ({
throw new BadRequestError({ message: "Access token TTL cannot be greater than max TTL" });
}
- if (identityMembershipOrg.identity.projectId) {
- const { permission } = await permissionService.getProjectPermission({
- actionProjectType: ActionProjectType.Any,
- actor,
- actorId,
- projectId: identityMembershipOrg.identity.projectId,
- actorAuthMethod,
- actorOrgId
- });
-
- ForbiddenError.from(permission).throwUnlessCan(
- ProjectPermissionIdentityActions.EditAuth,
- subject(ProjectPermissionSub.Identity, { identityId })
- );
- } else {
- const { permission } = await permissionService.getOrgPermission({
- scope: OrganizationActionScope.Any,
- actor,
- actorId,
- orgId: identityMembershipOrg.scopeOrgId,
- actorAuthMethod,
- actorOrgId
- });
-
- ForbiddenError.from(permission).throwUnlessCan(
- OrgPermissionIdentityActions.EditAuth,
- OrgPermissionSubjects.Identity
- );
- }
-
await assertIdentityAuthAccessAllowed(
{ permissionService, orgDAL },
{
@@ -705,36 +675,6 @@ export const identitySpiffeAuthServiceFactory = ({
throw new BadRequestError({ message: "Access token TTL cannot be greater than max TTL" });
}
- if (identityMembershipOrg.identity.projectId) {
- const { permission } = await permissionService.getProjectPermission({
- actionProjectType: ActionProjectType.Any,
- actor,
- actorId,
- projectId: identityMembershipOrg.identity.projectId,
- actorAuthMethod,
- actorOrgId
- });
-
- ForbiddenError.from(permission).throwUnlessCan(
- ProjectPermissionIdentityActions.EditAuth,
- subject(ProjectPermissionSub.Identity, { identityId })
- );
- } else {
- const { permission } = await permissionService.getOrgPermission({
- scope: OrganizationActionScope.Any,
- actor,
- actorId,
- orgId: identityMembershipOrg.scopeOrgId,
- actorAuthMethod,
- actorOrgId
- });
-
- ForbiddenError.from(permission).throwUnlessCan(
- OrgPermissionIdentityActions.EditAuth,
- OrgPermissionSubjects.Identity
- );
- }
-
await assertIdentityAuthAccessAllowed(
{ permissionService, orgDAL },
{
@@ -938,33 +878,6 @@ export const identitySpiffeAuthServiceFactory = ({
throw new BadRequestError({ message: "The identity does not have SPIFFE auth" });
}
- if (identityMembershipOrg.identity.projectId) {
- const { permission } = await permissionService.getProjectPermission({
- actionProjectType: ActionProjectType.Any,
- actor,
- actorId,
- projectId: identityMembershipOrg.identity.projectId,
- actorAuthMethod,
- actorOrgId
- });
-
- ForbiddenError.from(permission).throwUnlessCan(
- ProjectPermissionIdentityActions.RevokeAuth,
- subject(ProjectPermissionSub.Identity, { identityId })
- );
- } else {
- const { permission } = await permissionService.getOrgPermission({
- scope: OrganizationActionScope.Any,
- actor,
- actorId,
- orgId: identityMembershipOrg.scopeOrgId,
- actorAuthMethod,
- actorOrgId
- });
-
- ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Edit, OrgPermissionSubjects.Identity);
- }
-
await assertIdentityAuthAccessAllowed(
{ permissionService, orgDAL },
{
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 8110c3eaf9..c6e886d74e 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
@@ -513,35 +513,6 @@ export const identityTlsCertAuthServiceFactory = ({
throw new BadRequestError({ message: "Access token TTL cannot be greater than max TTL" });
}
- if (identityMembershipOrg.identity.projectId) {
- const { permission } = await permissionService.getProjectPermission({
- actionProjectType: ActionProjectType.Any,
- actor,
- actorId,
- projectId: identityMembershipOrg.identity.projectId,
- actorAuthMethod,
- actorOrgId
- });
-
- ForbiddenError.from(permission).throwUnlessCan(
- ProjectPermissionIdentityActions.EditAuth,
- subject(ProjectPermissionSub.Identity, { identityId })
- );
- } else {
- const { permission } = await permissionService.getOrgPermission({
- scope: OrganizationActionScope.Any,
- actor,
- actorId,
- orgId: identityMembershipOrg.scopeOrgId,
- actorAuthMethod,
- actorOrgId
- });
- ForbiddenError.from(permission).throwUnlessCan(
- OrgPermissionIdentityActions.EditAuth,
- OrgPermissionSubjects.Identity
- );
- }
-
await assertIdentityAuthAccessAllowed(
{ permissionService, orgDAL },
{
@@ -660,35 +631,6 @@ export const identityTlsCertAuthServiceFactory = ({
throw new BadRequestError({ message: "Access token TTL cannot be greater than max TTL" });
}
- if (identityMembershipOrg.identity.projectId) {
- const { permission } = await permissionService.getProjectPermission({
- actionProjectType: ActionProjectType.Any,
- actor,
- actorId,
- projectId: identityMembershipOrg.identity.projectId,
- actorAuthMethod,
- actorOrgId
- });
-
- ForbiddenError.from(permission).throwUnlessCan(
- ProjectPermissionIdentityActions.EditAuth,
- subject(ProjectPermissionSub.Identity, { identityId })
- );
- } else {
- const { permission } = await permissionService.getOrgPermission({
- scope: OrganizationActionScope.Any,
- actor,
- actorId,
- orgId: identityMembershipOrg.scopeOrgId,
- actorAuthMethod,
- actorOrgId
- });
- ForbiddenError.from(permission).throwUnlessCan(
- OrgPermissionIdentityActions.EditAuth,
- OrgPermissionSubjects.Identity
- );
- }
-
await assertIdentityAuthAccessAllowed(
{ permissionService, orgDAL },
{
@@ -863,32 +805,6 @@ export const identityTlsCertAuthServiceFactory = ({
});
}
- if (identityMembershipOrg.identity.projectId) {
- const { permission } = await permissionService.getProjectPermission({
- actionProjectType: ActionProjectType.Any,
- actor,
- actorId,
- projectId: identityMembershipOrg.identity.projectId,
- actorAuthMethod,
- actorOrgId
- });
-
- ForbiddenError.from(permission).throwUnlessCan(
- ProjectPermissionIdentityActions.RevokeAuth,
- subject(ProjectPermissionSub.Identity, { identityId })
- );
- } else {
- const { permission } = await permissionService.getOrgPermission({
- scope: OrganizationActionScope.Any,
- actor,
- actorId,
- orgId: identityMembershipOrg.scopeOrgId,
- actorAuthMethod,
- actorOrgId
- });
- ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Edit, OrgPermissionSubjects.Identity);
- }
-
await assertIdentityAuthAccessAllowed(
{ permissionService, orgDAL },
{
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 381b7ffe47..bbed07b6b7 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
@@ -118,35 +118,6 @@ export const identityTokenAuthServiceFactory = ({
throw new BadRequestError({ message: "Access token TTL cannot be greater than max TTL" });
}
- if (identityMembershipOrg.identity.projectId) {
- const { permission } = await permissionService.getProjectPermission({
- actionProjectType: ActionProjectType.Any,
- actor,
- actorId,
- projectId: identityMembershipOrg.identity.projectId,
- actorAuthMethod,
- actorOrgId
- });
-
- ForbiddenError.from(permission).throwUnlessCan(
- ProjectPermissionIdentityActions.EditAuth,
- subject(ProjectPermissionSub.Identity, { identityId })
- );
- } else {
- const { permission } = await permissionService.getOrgPermission({
- scope: OrganizationActionScope.Any,
- actor,
- actorId,
- orgId: identityMembershipOrg.scopeOrgId,
- actorAuthMethod,
- actorOrgId
- });
- ForbiddenError.from(permission).throwUnlessCan(
- OrgPermissionIdentityActions.EditAuth,
- OrgPermissionSubjects.Identity
- );
- }
-
await assertIdentityAuthAccessAllowed(
{ permissionService, orgDAL },
{
@@ -250,35 +221,6 @@ export const identityTokenAuthServiceFactory = ({
throw new BadRequestError({ message: "Access token TTL cannot be greater than max TTL" });
}
- if (identityMembershipOrg.identity.projectId) {
- const { permission } = await permissionService.getProjectPermission({
- actionProjectType: ActionProjectType.Any,
- actor,
- actorId,
- projectId: identityMembershipOrg.identity.projectId,
- actorAuthMethod,
- actorOrgId
- });
-
- ForbiddenError.from(permission).throwUnlessCan(
- ProjectPermissionIdentityActions.EditAuth,
- subject(ProjectPermissionSub.Identity, { identityId })
- );
- } else {
- const { permission } = await permissionService.getOrgPermission({
- scope: OrganizationActionScope.Any,
- actor,
- actorId,
- orgId: identityMembershipOrg.scopeOrgId,
- actorAuthMethod,
- actorOrgId
- });
- ForbiddenError.from(permission).throwUnlessCan(
- OrgPermissionIdentityActions.EditAuth,
- OrgPermissionSubjects.Identity
- );
- }
-
await assertIdentityAuthAccessAllowed(
{ permissionService, orgDAL },
{
@@ -424,32 +366,6 @@ export const identityTokenAuthServiceFactory = ({
});
}
- if (identityMembershipOrg.identity.projectId) {
- const { permission } = await permissionService.getProjectPermission({
- actionProjectType: ActionProjectType.Any,
- actor,
- actorId,
- projectId: identityMembershipOrg.identity.projectId,
- actorAuthMethod,
- actorOrgId
- });
-
- ForbiddenError.from(permission).throwUnlessCan(
- ProjectPermissionIdentityActions.RevokeAuth,
- subject(ProjectPermissionSub.Identity, { identityId })
- );
- } else {
- const { permission } = await permissionService.getOrgPermission({
- scope: OrganizationActionScope.Any,
- actor,
- actorId,
- orgId: identityMembershipOrg.scopeOrgId,
- actorAuthMethod,
- actorOrgId
- });
- ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Edit, OrgPermissionSubjects.Identity);
- }
-
await assertIdentityAuthAccessAllowed(
{ permissionService, orgDAL },
{
@@ -525,33 +441,6 @@ export const identityTokenAuthServiceFactory = ({
});
}
- if (identityMembershipOrg.identity.projectId) {
- const { permission } = await permissionService.getProjectPermission({
- actionProjectType: ActionProjectType.Any,
- actor,
- actorId,
- projectId: identityMembershipOrg.identity.projectId,
- actorAuthMethod,
- actorOrgId
- });
-
- ForbiddenError.from(permission).throwUnlessCan(
- ProjectPermissionIdentityActions.CreateToken,
- subject(ProjectPermissionSub.Identity, { identityId })
- );
- } else {
- const { permission } = await permissionService.getOrgPermission({
- scope: OrganizationActionScope.Any,
- actor,
- actorId,
- orgId: identityMembershipOrg.scopeOrgId,
- actorAuthMethod,
- actorOrgId
- });
-
- ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Edit, OrgPermissionSubjects.Identity);
- }
-
await assertIdentityAuthAccessAllowed(
{ permissionService, orgDAL },
{
@@ -824,32 +713,6 @@ export const identityTokenAuthServiceFactory = ({
});
}
- if (identityMembershipOrg.identity.projectId) {
- const { permission } = await permissionService.getProjectPermission({
- actionProjectType: ActionProjectType.Any,
- actor,
- actorId,
- projectId: identityMembershipOrg.identity.projectId,
- actorAuthMethod,
- actorOrgId
- });
-
- ForbiddenError.from(permission).throwUnlessCan(
- ProjectPermissionIdentityActions.CreateToken,
- subject(ProjectPermissionSub.Identity, { identityId: identityMembershipOrg.identity.id })
- );
- } else {
- const { permission } = await permissionService.getOrgPermission({
- scope: OrganizationActionScope.Any,
- actor,
- actorId,
- orgId: identityMembershipOrg.scopeOrgId,
- actorAuthMethod,
- actorOrgId
- });
- ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Edit, OrgPermissionSubjects.Identity);
- }
-
await assertIdentityAuthAccessAllowed(
{ permissionService, orgDAL },
{
diff --git a/backend/src/services/identity-ua/identity-ua-service.ts b/backend/src/services/identity-ua/identity-ua-service.ts
index 5a150e6da2..8cd6620d70 100644
--- a/backend/src/services/identity-ua/identity-ua-service.ts
+++ b/backend/src/services/identity-ua/identity-ua-service.ts
@@ -467,36 +467,6 @@ export const identityUaServiceFactory = ({
throw new BadRequestError({ message: "Access token TTL cannot be greater than max TTL" });
}
- if (identityMembershipOrg.identity.projectId) {
- const { permission } = await permissionService.getProjectPermission({
- actionProjectType: ActionProjectType.Any,
- actor,
- actorId,
- projectId: identityMembershipOrg.identity.projectId,
- actorAuthMethod,
- actorOrgId
- });
-
- ForbiddenError.from(permission).throwUnlessCan(
- ProjectPermissionIdentityActions.EditAuth,
- subject(ProjectPermissionSub.Identity, { identityId })
- );
- } else {
- const { permission } = await permissionService.getOrgPermission({
- scope: OrganizationActionScope.Any,
- actor,
- actorId,
- orgId: identityMembershipOrg.scopeOrgId,
- actorAuthMethod,
- actorOrgId
- });
-
- ForbiddenError.from(permission).throwUnlessCan(
- OrgPermissionIdentityActions.EditAuth,
- OrgPermissionSubjects.Identity
- );
- }
-
await assertIdentityAuthAccessAllowed(
{ permissionService, orgDAL },
{
@@ -635,35 +605,6 @@ export const identityUaServiceFactory = ({
throw new BadRequestError({ message: "Access token TTL cannot be greater than max TTL" });
}
- if (identityMembershipOrg.identity.projectId) {
- const { permission } = await permissionService.getProjectPermission({
- actionProjectType: ActionProjectType.Any,
- actor,
- actorId,
- projectId: identityMembershipOrg.identity.projectId,
- actorAuthMethod,
- actorOrgId
- });
-
- ForbiddenError.from(permission).throwUnlessCan(
- ProjectPermissionIdentityActions.EditAuth,
- subject(ProjectPermissionSub.Identity, { identityId })
- );
- } else {
- const { permission } = await permissionService.getOrgPermission({
- scope: OrganizationActionScope.Any,
- actor,
- actorId,
- orgId: identityMembershipOrg.scopeOrgId,
- actorAuthMethod,
- actorOrgId
- });
- ForbiddenError.from(permission).throwUnlessCan(
- OrgPermissionIdentityActions.EditAuth,
- OrgPermissionSubjects.Identity
- );
- }
-
await assertIdentityAuthAccessAllowed(
{ permissionService, orgDAL },
{
@@ -831,32 +772,6 @@ export const identityUaServiceFactory = ({
throw new ForbiddenRequestError({ message: "Sub organization not authorized to access this identity" });
}
- if (identityMembershipOrg.identity.projectId) {
- const { permission } = await permissionService.getProjectPermission({
- actionProjectType: ActionProjectType.Any,
- actor,
- actorId,
- projectId: identityMembershipOrg.identity.projectId,
- actorAuthMethod,
- actorOrgId
- });
-
- ForbiddenError.from(permission).throwUnlessCan(
- ProjectPermissionIdentityActions.RevokeAuth,
- subject(ProjectPermissionSub.Identity, { identityId })
- );
- } else {
- const { permission } = await permissionService.getOrgPermission({
- scope: OrganizationActionScope.Any,
- actor,
- actorId,
- orgId: identityMembershipOrg.scopeOrgId,
- actorAuthMethod,
- actorOrgId
- });
- ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Edit, OrgPermissionSubjects.Identity);
- }
-
await assertIdentityAuthAccessAllowed(
{ permissionService, orgDAL },
{
@@ -930,35 +845,6 @@ export const identityUaServiceFactory = ({
throw new ForbiddenRequestError({ message: "Sub organization not authorized to access this identity" });
}
- if (identityMembershipOrg.identity.projectId) {
- const { permission } = await permissionService.getProjectPermission({
- actionProjectType: ActionProjectType.Any,
- actor,
- actorId,
- projectId: identityMembershipOrg.identity.projectId,
- actorAuthMethod,
- actorOrgId
- });
-
- ForbiddenError.from(permission).throwUnlessCan(
- ProjectPermissionIdentityActions.CreateToken,
- subject(ProjectPermissionSub.Identity, { identityId })
- );
- } else {
- const { permission } = await permissionService.getOrgPermission({
- scope: OrganizationActionScope.Any,
- actor,
- actorId,
- orgId: identityMembershipOrg.scopeOrgId,
- actorAuthMethod,
- actorOrgId
- });
- ForbiddenError.from(permission).throwUnlessCan(
- OrgPermissionIdentityActions.Create,
- OrgPermissionSubjects.Identity
- );
- }
-
await assertIdentityAuthAccessAllowed(
{ permissionService, orgDAL },
{
@@ -1043,32 +929,6 @@ export const identityUaServiceFactory = ({
throw new ForbiddenRequestError({ message: "Sub organization not authorized to access this identity" });
}
- if (identityMembershipOrg.identity.projectId) {
- const { permission } = await permissionService.getProjectPermission({
- actionProjectType: ActionProjectType.Any,
- actor,
- actorId,
- projectId: identityMembershipOrg.identity.projectId,
- actorAuthMethod,
- actorOrgId
- });
-
- ForbiddenError.from(permission).throwUnlessCan(
- ProjectPermissionIdentityActions.GetToken,
- subject(ProjectPermissionSub.Identity, { identityId })
- );
- } else {
- const { permission } = await permissionService.getOrgPermission({
- scope: OrganizationActionScope.Any,
- actor,
- actorId,
- orgId: identityMembershipOrg.scopeOrgId,
- actorAuthMethod,
- actorOrgId
- });
- ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Read, OrgPermissionSubjects.Identity);
- }
-
await assertIdentityAuthAccessAllowed(
{ permissionService, orgDAL },
{
@@ -1127,32 +987,6 @@ export const identityUaServiceFactory = ({
const clientSecret = await identityUaClientSecretDAL.findOne({ id: clientSecretId, identityUAId: identityUa.id });
if (!clientSecret) throw new NotFoundError({ message: `Failed to find identity with ID ${identityId}` });
- if (identityMembershipOrg.identity.projectId) {
- const { permission } = await permissionService.getProjectPermission({
- actionProjectType: ActionProjectType.Any,
- actor,
- actorId,
- projectId: identityMembershipOrg.identity.projectId,
- actorAuthMethod,
- actorOrgId
- });
-
- ForbiddenError.from(permission).throwUnlessCan(
- ProjectPermissionIdentityActions.GetToken,
- subject(ProjectPermissionSub.Identity, { identityId })
- );
- } else {
- const { permission } = await permissionService.getOrgPermission({
- scope: OrganizationActionScope.Any,
- actor,
- actorId,
- orgId: identityMembershipOrg.scopeOrgId,
- actorAuthMethod,
- actorOrgId
- });
- ForbiddenError.from(permission).throwUnlessCan(OrgPermissionIdentityActions.Read, OrgPermissionSubjects.Identity);
- }
-
await assertIdentityAuthAccessAllowed(
{ permissionService, orgDAL },
{
@@ -1204,35 +1038,6 @@ export const identityUaServiceFactory = ({
const clientSecret = await identityUaClientSecretDAL.findOne({ id: clientSecretId, identityUAId: identityUa.id });
if (!clientSecret) throw new NotFoundError({ message: `Failed to find identity with ID ${identityId}` });
- if (identityMembershipOrg.identity.projectId) {
- const { permission } = await permissionService.getProjectPermission({
- actionProjectType: ActionProjectType.Any,
- actor,
- actorId,
- projectId: identityMembershipOrg.identity.projectId,
- actorAuthMethod,
- actorOrgId
- });
-
- ForbiddenError.from(permission).throwUnlessCan(
- ProjectPermissionIdentityActions.DeleteToken,
- subject(ProjectPermissionSub.Identity, { identityId })
- );
- } else {
- const { permission } = await permissionService.getOrgPermission({
- scope: OrganizationActionScope.Any,
- actor,
- actorId,
- orgId: identityMembershipOrg.scopeOrgId,
- actorAuthMethod,
- actorOrgId
- });
- ForbiddenError.from(permission).throwUnlessCan(
- OrgPermissionIdentityActions.Delete,
- OrgPermissionSubjects.Identity
- );
- }
-
await assertIdentityAuthAccessAllowed(
{ permissionService, orgDAL },
{
diff --git a/backend/src/services/identity/identity-auth-permission-fns.test.ts b/backend/src/services/identity/identity-auth-permission-fns.test.ts
index d61e57cce8..63a488e580 100644
--- a/backend/src/services/identity/identity-auth-permission-fns.test.ts
+++ b/backend/src/services/identity/identity-auth-permission-fns.test.ts
@@ -1,4 +1,4 @@
-import { createMongoAbility, MongoAbility } from "@casl/ability";
+import { createMongoAbility, ForbiddenError, MongoAbility } from "@casl/ability";
import { AccessScope } from "@app/db/schemas";
import { projectAdminPermissions, projectMemberPermissions } from "@app/ee/services/permission/default-roles";
@@ -33,6 +33,10 @@ const orgEditAuthOnly = createMongoAbility<MongoAbility<OrgPermissionSet>>([
{ action: OrgPermissionIdentityActions.EditAuth, subject: OrgPermissionSubjects.Identity },
{ action: OrgPermissionIdentityActions.RevokeAuth, subject: OrgPermissionSubjects.Identity }
]);
+const orgCreateTokenOnly = createMongoAbility<MongoAbility<OrgPermissionSet>>([
+ { action: OrgPermissionIdentityActions.CreateToken, subject: OrgPermissionSubjects.Identity }
+]);
+const noAccess = createMongoAbility<MongoAbility>([]);
const projectAdmin = createMongoAbility<MongoAbility<ProjectPermissionSet>>(projectAdminPermissions);
const projectMember = createMongoAbility<MongoAbility<ProjectPermissionSet>>(projectMemberPermissions);
@@ -42,6 +46,13 @@ const projectEditAuthOnly = createMongoAbility<MongoAbility<ProjectPermissionSet
const projectCreateTokenOnly = createMongoAbility<MongoAbility<ProjectPermissionSet>>([
{ action: ProjectPermissionIdentityActions.CreateToken, subject: ProjectPermissionSub.Identity }
]);
+const projectEditAuthOnOtherIdentity = createMongoAbility<MongoAbility<ProjectPermissionSet>>([
+ {
+ action: ProjectPermissionIdentityActions.EditAuth,
+ subject: ProjectPermissionSub.Identity,
+ conditions: { identityId: "identity-2" }
+ }
+]);
type TScopeCall = { scope: AccessScope; orgId: string; projectId?: string };
type TPrincipal = { actorId: string; actorType: ActorType };
@@ -140,7 +151,7 @@ describe("assertIdentityAuthAccessAllowed", () => {
).resolves.toBeUndefined();
await expect(
runBoundary({ shouldUseNewPrivilegeSystem: true, actorPermission: orgMember, targetPermissions: [orgMember] })
- ).rejects.toThrow(PermissionBoundaryError);
+ ).rejects.toThrow(ForbiddenError);
});
test("the target is not looked up at all under the new privilege system", async () => {
@@ -209,7 +220,7 @@ describe("assertIdentityAuthAccessAllowed", () => {
targetPermissions: [projectMember],
projectId: "project-1"
})
- ).rejects.toThrow(PermissionBoundaryError);
+ ).rejects.toThrow(ForbiddenError);
});
test("the target is not looked up at all under the new privilege system", async () => {
@@ -228,6 +239,39 @@ describe("assertIdentityAuthAccessAllowed", () => {
});
});
+ // the legacy boundary only compares grants, so covering the target isn't enough. the scary case is a
+ // no-access org identity that's admin in projects: no org grants, so anyone could mint it a credential
+ describe("the action is required on the legacy privilege system too", () => {
+ test("covering an org identity's grants does not stand in for the action", async () => {
+ await expect(
+ runBoundary({
+ actorPermission: orgMember,
+ targetPermissions: [noAccess],
+ action: OrgPermissionIdentityActions.CreateToken
+ })
+ ).rejects.toThrow(ForbiddenError);
+ await expect(runBoundary({ actorPermission: orgMember, targetPermissions: [orgMember] })).rejects.toThrow(
+ ForbiddenError
+ );
+ });
+
+ test("covering a project identity's grants does not stand in for the action", async () => {
+ await expect(
+ runBoundary({ actorPermission: projectMember, targetPermissions: [noAccess], projectId: "project-1" })
+ ).rejects.toThrow(ForbiddenError);
+ });
+
+ test("a project grant scoped to another identity does not cover this one", async () => {
+ await expect(
+ runBoundary({
+ actorPermission: projectEditAuthOnOtherIdentity,
+ targetPermissions: [noAccess],
+ projectId: "project-1"
+ })
+ ).rejects.toThrow(ForbiddenError);
+ });
+ });
+
describe("credential issuance", () => {
test("a create-token-only actor may not mint a credential for an admin identity", async () => {
await expect(
@@ -240,7 +284,7 @@ describe("assertIdentityAuthAccessAllowed", () => {
).rejects.toThrow(PermissionBoundaryError);
await expect(
runBoundary({
- actorPermission: orgMember,
+ actorPermission: orgCreateTokenOnly,
targetPermissions: [orgAdmin],
action: OrgPermissionIdentityActions.CreateToken
})
diff --git a/backend/src/services/identity/identity-auth-permission-fns.ts b/backend/src/services/identity/identity-auth-permission-fns.ts
index 6116cdef92..2fc741e803 100644
--- a/backend/src/services/identity/identity-auth-permission-fns.ts
+++ b/backend/src/services/identity/identity-auth-permission-fns.ts
@@ -1,3 +1,5 @@
+import { ForbiddenError, subject } from "@casl/ability";
+
import { AccessScope, ActionProjectType, OrganizationActionScope } from "@app/db/schemas";
import { OrgPermissionIdentityActions, OrgPermissionSubjects } from "@app/ee/services/permission/org-permission";
import { assertRoleSetBoundary } from "@app/ee/services/permission/permission-fns";
@@ -36,10 +38,10 @@ type TAssertIdentityAuthAccessAllowedDTO = {
actorOrgId: string;
};
-// Repointing an identity's auth trust or minting a credential for it lets you authenticate as that
-// identity, and enumerating its credential records tells you what to attack, so the actor has to
-// out-rank every role the target holds. Only bites on the legacy privilege system: on the new one
-// `assertRoleSetBoundary` reduces to the action check the caller already ran.
+// repointing an identity's auth or minting it a credential lets you log in as it, and listing its
+// credentials shows what to attack. so you need the action, and on the legacy system you also have to
+// out-rank every grant the target holds. the action check lives here because the legacy boundary alone
+// passes for any target you cover, no-access identities included
export const assertIdentityAuthAccessAllowed = async (
{ permissionService, orgDAL }: TIdentityAuthPermissionDeps,
{
@@ -58,18 +60,6 @@ export const assertIdentityAuthAccessAllowed = async (
orgDAL.findById(orgId)
);
- const resolveTargetPermissions = async () => {
- if (shouldUseNewPrivilegeSystem) return [];
-
- return permissionService.getActorGrantAbilities({
- scopeData: projectId
- ? { scope: AccessScope.Project, orgId, projectId }
- : { scope: AccessScope.Organization, orgId },
- actorId: identityId,
- actorType: ActorType.IDENTITY
- });
- };
-
if (projectId) {
const { permission } = await permissionService.getProjectPermission({
actionProjectType: ActionProjectType.Any,
@@ -80,12 +70,22 @@ export const assertIdentityAuthAccessAllowed = async (
actorOrgId
});
+ ForbiddenError.from(permission).throwUnlessCan(
+ PROJECT_ACTION_BY_ORG_ACTION[action],
+ subject(ProjectPermissionSub.Identity, { identityId })
+ );
+ if (shouldUseNewPrivilegeSystem) return;
+
assertRoleSetBoundary({
shouldUseNewPrivilegeSystem,
opActions: PROJECT_ACTION_BY_ORG_ACTION[action],
opSubject: ProjectPermissionSub.Identity,
actorPermission: permission,
- targetPermissions: await resolveTargetPermissions(),
+ targetPermissions: await permissionService.getActorGrantAbilities({
+ scopeData: { scope: AccessScope.Project, orgId, projectId },
+ actorId: identityId,
+ actorType: ActorType.IDENTITY
+ }),
baseMessage,
subjectFields: { identityId }
});
@@ -101,12 +101,19 @@ export const assertIdentityAuthAccessAllowed = async (
actorOrgId
});
+ ForbiddenError.from(permission).throwUnlessCan(action, OrgPermissionSubjects.Identity);
+ if (shouldUseNewPrivilegeSystem) return;
+
assertRoleSetBoundary({
shouldUseNewPrivilegeSystem,
opActions: action,
opSubject: OrgPermissionSubjects.Identity,
actorPermission: permission,
- targetPermissions: await resolveTargetPermissions(),
+ targetPermissions: await permissionService.getActorGrantAbilities({
+ scopeData: { scope: AccessScope.Organization, orgId },
+ actorId: identityId,
+ actorType: ActorType.IDENTITY
+ }),
baseMessage
});
};