mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-14 18:41:21 +00:00
Merge remote-tracking branch 'origin/main' into feat/moved-mfa-to-org-level
This commit is contained in:
@@ -5,7 +5,7 @@ import { TOrgRoleDALFactory } from "@app/services/org/org-role-dal";
|
||||
|
||||
const RESERVED_ORG_ROLE_SLUGS = Object.values(OrgMembershipRole).filter((role) => role !== "custom");
|
||||
|
||||
export const isCustomOrgRole = (roleSlug: string) => !RESERVED_ORG_ROLE_SLUGS.includes(roleSlug as OrgMembershipRole);
|
||||
export const isCustomOrgRole = (roleSlug: string) => !RESERVED_ORG_ROLE_SLUGS.find((r) => r === roleSlug);
|
||||
|
||||
// this is only for updating an org
|
||||
export const getDefaultOrgMembershipRoleForUpdateOrg = async ({
|
||||
@@ -27,7 +27,12 @@ export const getDefaultOrgMembershipRoleForUpdateOrg = async ({
|
||||
});
|
||||
|
||||
const customRole = await orgRoleDAL.findOne({ slug: membershipRoleSlug, orgId });
|
||||
if (!customRole) throw new NotFoundError({ name: "UpdateOrg", message: "Organization role not found" });
|
||||
if (!customRole) {
|
||||
throw new NotFoundError({
|
||||
name: "UpdateOrg",
|
||||
message: `Organization role with slug '${membershipRoleSlug}' not found`
|
||||
});
|
||||
}
|
||||
|
||||
// use ID for default role
|
||||
return customRole.id;
|
||||
|
||||
@@ -100,7 +100,7 @@ export const orgRoleServiceFactory = ({
|
||||
}
|
||||
default: {
|
||||
const role = await orgRoleDAL.findOne({ id: roleId, orgId });
|
||||
if (!role) throw new NotFoundError({ message: "Organization role not found" });
|
||||
if (!role) throw new NotFoundError({ message: `Organization role with ID '${roleId}' not found` });
|
||||
return role;
|
||||
}
|
||||
}
|
||||
@@ -125,7 +125,7 @@ export const orgRoleServiceFactory = ({
|
||||
{ id: roleId, orgId },
|
||||
{ ...data, permissions: data.permissions ? JSON.stringify(data.permissions) : undefined }
|
||||
);
|
||||
if (!updatedRole) throw new NotFoundError({ message: "Organization role not found" });
|
||||
if (!updatedRole) throw new NotFoundError({ message: `Organization role with ID '${roleId}' not found` });
|
||||
return updatedRole;
|
||||
};
|
||||
|
||||
@@ -143,7 +143,7 @@ export const orgRoleServiceFactory = ({
|
||||
|
||||
if (!org)
|
||||
throw new NotFoundError({
|
||||
message: "Failed to find organization"
|
||||
message: `Organization with ID '${orgId}' not found`
|
||||
});
|
||||
|
||||
if (org.defaultMembershipRole === roleId)
|
||||
@@ -163,7 +163,8 @@ export const orgRoleServiceFactory = ({
|
||||
});
|
||||
|
||||
const [deletedRole] = await orgRoleDAL.delete({ id: roleId, orgId });
|
||||
if (!deletedRole) throw new NotFoundError({ message: "Organization role not found", name: "Update role" });
|
||||
if (!deletedRole)
|
||||
throw new NotFoundError({ message: `Organization role with ID '${roleId}' not found`, name: "UpdateRole" });
|
||||
|
||||
return deletedRole;
|
||||
};
|
||||
|
||||
@@ -138,7 +138,7 @@ export const orgServiceFactory = ({
|
||||
) => {
|
||||
await permissionService.getUserOrgPermission(userId, orgId, actorAuthMethod, actorOrgId);
|
||||
const org = await orgDAL.findOrgById(orgId);
|
||||
if (!org) throw new NotFoundError({ message: "Organization not found" });
|
||||
if (!org) throw new NotFoundError({ message: `Organization with ID '${orgId}' not found` });
|
||||
return org;
|
||||
};
|
||||
/*
|
||||
@@ -313,7 +313,7 @@ export const orgServiceFactory = ({
|
||||
|
||||
if (!samlCfg && !oidcCfg)
|
||||
throw new NotFoundError({
|
||||
message: "No enforceable SSO config found"
|
||||
message: `SAML or OIDC configuration for organization with ID '${orgId}' not found`
|
||||
});
|
||||
}
|
||||
|
||||
@@ -335,7 +335,7 @@ export const orgServiceFactory = ({
|
||||
defaultMembershipRole,
|
||||
enforceMfa
|
||||
});
|
||||
if (!org) throw new NotFoundError({ message: "Organization not found" });
|
||||
if (!org) throw new NotFoundError({ message: `Organization with ID '${orgId}' not found` });
|
||||
return org;
|
||||
};
|
||||
/*
|
||||
@@ -449,7 +449,8 @@ export const orgServiceFactory = ({
|
||||
ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Edit, OrgPermissionSubjects.Member);
|
||||
|
||||
const foundMembership = await orgMembershipDAL.findById(membershipId);
|
||||
if (!foundMembership) throw new NotFoundError({ message: "Failed to find organization membership" });
|
||||
if (!foundMembership)
|
||||
throw new NotFoundError({ message: `Organization membership with ID ${membershipId} not found` });
|
||||
if (foundMembership.orgId !== orgId)
|
||||
throw new UnauthorizedError({ message: "Updated org member doesn't belong to the organization" });
|
||||
if (foundMembership.userId === userId)
|
||||
@@ -645,8 +646,12 @@ export const orgServiceFactory = ({
|
||||
const orgRole = isCustomOrgRole ? OrgMembershipRole.Custom : organizationRoleSlug;
|
||||
if (isCustomOrgRole) {
|
||||
const customRole = await orgRoleDAL.findOne({ slug: organizationRoleSlug, orgId });
|
||||
if (!customRole)
|
||||
throw new NotFoundError({ name: "InviteUser", message: "Custom organization role not found" });
|
||||
if (!customRole) {
|
||||
throw new NotFoundError({
|
||||
name: "InviteUser",
|
||||
message: `Custom organization role with slug '${orgRole}' not found`
|
||||
});
|
||||
}
|
||||
roleId = customRole.id;
|
||||
}
|
||||
|
||||
@@ -804,7 +809,7 @@ export const orgServiceFactory = ({
|
||||
if (!bot) {
|
||||
throw new NotFoundError({
|
||||
name: "InviteUser",
|
||||
message: "Failed to find project bot"
|
||||
message: `Failed to find project bot for project with ID '${projectId}'`
|
||||
});
|
||||
}
|
||||
|
||||
@@ -812,7 +817,7 @@ export const orgServiceFactory = ({
|
||||
if (!ghostUserLatestKey) {
|
||||
throw new NotFoundError({
|
||||
name: "InviteUser",
|
||||
message: "Failed to find project owner's latest key"
|
||||
message: `Failed to find project owner's latest key for project with ID '${projectId}'`
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1001,7 +1006,7 @@ export const orgServiceFactory = ({
|
||||
|
||||
const membership = await orgMembershipDAL.findOrgMembershipById(membershipId);
|
||||
if (!membership) {
|
||||
throw new NotFoundError({ message: "Organization membership not found" });
|
||||
throw new NotFoundError({ message: `Organization membership with ID '${membershipId}' not found` });
|
||||
}
|
||||
if (membership.orgId !== orgId) {
|
||||
throw new ForbiddenRequestError({ message: "Membership does not belong to organization" });
|
||||
@@ -1047,7 +1052,7 @@ export const orgServiceFactory = ({
|
||||
|
||||
const membership = await orgMembershipDAL.findOrgMembershipById(orgMembershipId);
|
||||
if (!membership) {
|
||||
throw new NotFoundError({ message: "Organization membership not found" });
|
||||
throw new NotFoundError({ message: `Organization membership with ID '${orgMembershipId}' not found` });
|
||||
}
|
||||
if (membership.orgId !== orgId) throw new NotFoundError({ message: "Failed to find organization membership" });
|
||||
|
||||
|
||||
Reference in New Issue
Block a user