Skip to content

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

feat: custom roles as enterprise-only feature

Daniel Hougaarde4880e71edd3
diff --git a/backend/src/server/routes/index.ts b/backend/src/server/routes/index.ts
index 62c1f40bc5..23af2d7e27 100644
--- a/backend/src/server/routes/index.ts
+++ b/backend/src/server/routes/index.ts
@@ -759,7 +759,8 @@ export const registerRoutes = async (
identityDAL,
userDAL,
externalGroupOrgRoleMappingDAL,
- membershipRoleDAL
+ membershipRoleDAL,
+ licenseService
});
const additionalPrivilegeService = additionalPrivilegeServiceFactory({
additionalPrivilegeDAL,
diff --git a/backend/src/services/role/role-service.ts b/backend/src/services/role/role-service.ts
index 7453585970..46796126fa 100644
--- a/backend/src/services/role/role-service.ts
+++ b/backend/src/services/role/role-service.ts
@@ -2,6 +2,7 @@ import { packRules } from "@casl/ability/extra";
import { requestContext } from "@fastify/request-context";
import { AccessScope, ActionProjectType, OrganizationActionScope, TableName } from "@app/db/schemas";
+import { TLicenseServiceFactory } from "@app/ee/services/license/license-service";
import { TPermissionServiceFactory } from "@app/ee/services/permission/permission-service-types";
import { BadRequestError, NotFoundError } from "@app/lib/errors";
import { validateHandlebarTemplate } from "@app/lib/template/validate-handlebars";
@@ -34,6 +35,7 @@ type TRoleServiceFactoryDep = {
projectDAL: Pick<TProjectDALFactory, "findById">;
externalGroupOrgRoleMappingDAL: Pick<TExternalGroupOrgRoleMappingDALFactory, "findOne">;
membershipRoleDAL: Pick<TMembershipRoleDALFactory, "find">;
+ licenseService: Pick<TLicenseServiceFactory, "getPlan">;
};
export type TRoleServiceFactory = ReturnType<typeof roleServiceFactory>;
@@ -45,7 +47,8 @@ export const roleServiceFactory = ({
identityDAL,
userDAL,
externalGroupOrgRoleMappingDAL,
- membershipRoleDAL
+ membershipRoleDAL,
+ licenseService
}: TRoleServiceFactoryDep) => {
const orgRoleFactory = newOrgRoleFactory({
permissionService,
@@ -65,6 +68,14 @@ export const roleServiceFactory = ({
const factory = scopeFactory[scopeData.scope];
await factory.onCreateRoleGuard(dto);
+ const plan = await licenseService.getPlan(dto.permission.orgId);
+ if (!plan?.rbac) {
+ throw new BadRequestError({
+ message:
+ "Failed to create custom role due to plan RBAC restriction. Upgrade to Infisical Enterprise plan to create custom roles."
+ });
+ }
+
const scope = factory.getScopeField(scopeData);
const existingRole = await roleDAL.findOne({
slug: data.slug,
@@ -94,6 +105,14 @@ export const roleServiceFactory = ({
await factory.onUpdateRoleGuard(dto);
+ const plan = await licenseService.getPlan(dto.permission.orgId);
+ if (!plan?.rbac) {
+ throw new BadRequestError({
+ message:
+ "Failed to update custom role due to plan RBAC restriction. Upgrade to Infisical Enterprise plan to update custom roles."
+ });
+ }
+
const existingRole = await roleDAL.findOne({
id: dto.selector.id,
[scope.key]: scope.value
diff --git a/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityTable.tsx b/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityTable.tsx
index 939ef3515b..6b134e20e8 100644
--- a/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityTable.tsx
+++ b/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityTable.tsx
@@ -49,7 +49,13 @@ import {
UnstableTableHeader,
UnstableTableRow
} from "@app/components/v3";
-import { OrgPermissionIdentityActions, OrgPermissionSubjects, useOrganization } from "@app/context";
+import {
+ OrgPermissionIdentityActions,
+ OrgPermissionSubjects,
+ useOrganization,
+ useSubscription
+} from "@app/context";
+import { isCustomOrgRole } from "@app/helpers/roles";
import {
getUserTablePreference,
PreferenceKey,
@@ -68,10 +74,12 @@ import { UsePopUpState } from "@app/hooks/usePopUp";
type Props = {
handlePopUpOpen: (
- popUpName: keyof UsePopUpState<["deleteIdentity"]>,
+ popUpName: keyof UsePopUpState<["deleteIdentity", "upgradePlan"]>,
data?: {
- identityId: string;
- name: string;
+ identityId?: string;
+ name?: string;
+ text?: string;
+ isEnterpriseFeature?: boolean;
}
) => void;
};
@@ -83,6 +91,7 @@ type Filter = {
export const IdentityTable = ({ handlePopUpOpen }: Props) => {
const navigate = useNavigate();
const { currentOrg, isSubOrganization } = useOrganization();
+ const { subscription } = useSubscription();
const {
offset,
@@ -148,6 +157,14 @@ export const IdentityTable = ({ handlePopUpOpen }: Props) => {
};
const handleChangeRole = async ({ identityId, role }: { identityId: string; role: string }) => {
+ if (isCustomOrgRole(role) && subscription && !subscription?.rbac) {
+ handlePopUpOpen("upgradePlan", {
+ text: "Assigning custom roles to machine identities can be unlocked if you upgrade to Infisical Enterprise plan.",
+ isEnterpriseFeature: true
+ });
+ return;
+ }
+
await updateMutateAsync({
identityId,
role,
diff --git a/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/OrgIdentityModal.tsx b/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/OrgIdentityModal.tsx
index 732a22cce7..f5a057caa0 100644
--- a/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/OrgIdentityModal.tsx
+++ b/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/OrgIdentityModal.tsx
@@ -6,6 +6,7 @@ import { zodResolver } from "@hookform/resolvers/zod";
import { useNavigate } from "@tanstack/react-router";
import { z } from "zod";
+import { UpgradePlanModal } from "@app/components/license/UpgradePlanModal";
import { createNotification } from "@app/components/notifications";
import {
Button,
@@ -16,11 +17,11 @@ import {
Input,
Switch
} from "@app/components/v2";
-import { useOrganization } from "@app/context";
-import { findOrgMembershipRole } from "@app/helpers/roles";
+import { useOrganization, useSubscription } from "@app/context";
+import { findOrgMembershipRole, isCustomOrgRole } from "@app/helpers/roles";
import { useCreateOrgIdentity, useGetOrgRoles, useUpdateOrgIdentity } from "@app/hooks/api";
import { useAddIdentityUniversalAuth } from "@app/hooks/api/identities";
-import { UsePopUpState } from "@app/hooks/usePopUp";
+import { usePopUp, UsePopUpState } from "@app/hooks/usePopUp";
const schema = z
.object({
@@ -49,6 +50,12 @@ export const OrgIdentityModal = ({ popUp, handlePopUpToggle }: Props) => {
const navigate = useNavigate();
const { currentOrg } = useOrganization();
const orgId = currentOrg?.id || "";
+ const { subscription } = useSubscription();
+ const {
+ popUp: upgradePlanPopUp,
+ handlePopUpOpen: handleUpgradePlanPopUpOpen,
+ handlePopUpToggle: handleUpgradePlanPopUpToggle
+ } = usePopUp(["upgradePlan"] as const);
const { data: roles } = useGetOrgRoles(orgId);
const isOrgIdentity = popUp?.identity?.data ? orgId === popUp?.identity?.data?.orgId : true;
@@ -106,6 +113,11 @@ export const OrgIdentityModal = ({ popUp, handlePopUpToggle }: Props) => {
}, [popUp?.identity?.data, roles]);
const onFormSubmit = async ({ name, role, metadata, hasDeleteProtection }: FormData) => {
+ if (role?.slug && isCustomOrgRole(role.slug) && subscription && !subscription?.rbac) {
+ handleUpgradePlanPopUpOpen("upgradePlan");
+ return;
+ }
+
const identity = popUp?.identity?.data as {
identityId: string;
name: string;
@@ -311,6 +323,12 @@ export const OrgIdentityModal = ({ popUp, handlePopUpToggle }: Props) => {
Cancel
</Button>
</div>
+ <UpgradePlanModal
+ isOpen={upgradePlanPopUp.upgradePlan.isOpen}
+ onOpenChange={(isOpen) => handleUpgradePlanPopUpToggle("upgradePlan", isOpen)}
+ text="Assigning custom roles to machine identities can be unlocked if you upgrade to Infisical Enterprise plan."
+ isEnterpriseFeature
+ />
</form>
);
};
diff --git a/frontend/src/pages/organization/AccessManagementPage/components/OrgMembersTab/components/OrgMembersSection/OrgMembersSection.tsx b/frontend/src/pages/organization/AccessManagementPage/components/OrgMembersTab/components/OrgMembersSection/OrgMembersSection.tsx
index b938ab863e..2e0d984e91 100644
--- a/frontend/src/pages/organization/AccessManagementPage/components/OrgMembersTab/components/OrgMembersSection/OrgMembersSection.tsx
+++ b/frontend/src/pages/organization/AccessManagementPage/components/OrgMembersTab/components/OrgMembersSection/OrgMembersSection.tsx
@@ -333,6 +333,7 @@ export const OrgMembersSection = () => {
isOpen={popUp.upgradePlan.isOpen}
onOpenChange={(isOpen) => handlePopUpToggle("upgradePlan", isOpen)}
text={popUp.upgradePlan?.data?.text}
+ isEnterpriseFeature={popUp.upgradePlan?.data?.isEnterpriseFeature}
/>
<EmailServiceSetupModal
isOpen={popUp.setUpEmail?.isOpen}
diff --git a/frontend/src/pages/organization/AccessManagementPage/components/OrgMembersTab/components/OrgMembersSection/OrgMembersTable.tsx b/frontend/src/pages/organization/AccessManagementPage/components/OrgMembersTab/components/OrgMembersSection/OrgMembersTable.tsx
index c25c45055c..4ed9a7275a 100644
--- a/frontend/src/pages/organization/AccessManagementPage/components/OrgMembersTab/components/OrgMembersSection/OrgMembersTable.tsx
+++ b/frontend/src/pages/organization/AccessManagementPage/components/OrgMembersTab/components/OrgMembersSection/OrgMembersTable.tsx
@@ -86,6 +86,7 @@ type Props = {
username?: string;
text?: string;
selectedOrgMemberships?: OrgUser[];
+ isEnterpriseFeature?: boolean;
}
) => void;
setCompleteInviteLinks: (links: Array<{ email: string; link: string }> | null) => void;
@@ -134,7 +135,8 @@ export const OrgMembersTable = ({
if (isCustomRole && subscription && !subscription?.rbac) {
handlePopUpOpen("upgradePlan", {
- text: "Your current plan does not include access to assigning custom roles to members. To unlock this feature, please upgrade to Infisical Pro plan."
+ text: "Your current plan does not include access to assigning custom roles to members. To unlock this feature, please upgrade to Infisical Enterprise plan.",
+ isEnterpriseFeature: true
});
return;
}
diff --git a/frontend/src/pages/organization/AccessManagementPage/components/OrgRoleTabSection/OrgRoleTable.tsx b/frontend/src/pages/organization/AccessManagementPage/components/OrgRoleTabSection/OrgRoleTable.tsx
index 203aa285fc..530b150a3a 100644
--- a/frontend/src/pages/organization/AccessManagementPage/components/OrgRoleTabSection/OrgRoleTable.tsx
+++ b/frontend/src/pages/organization/AccessManagementPage/components/OrgRoleTabSection/OrgRoleTable.tsx
@@ -110,7 +110,8 @@ export const OrgRoleTable = () => {
if (isCustomRole && subscription && !subscription?.rbac) {
handlePopUpOpen("upgradePlan", {
- text: "Your current plan does not include access to set a custom default organization role. To unlock this feature, please upgrade to Infisical Pro plan."
+ text: "Your current plan does not include access to set a custom default organization role. To unlock this feature, please upgrade to Infisical Enterprise plan.",
+ isEnterpriseFeature: true
});
return;
}
@@ -527,6 +528,7 @@ export const OrgRoleTable = () => {
isOpen={popUp.upgradePlan.isOpen}
onOpenChange={(isOpen) => handlePopUpToggle("upgradePlan", isOpen)}
text={popUp.upgradePlan?.data?.text}
+ isEnterpriseFeature={popUp.upgradePlan?.data?.isEnterpriseFeature}
/>
<DuplicateOrgRoleModal
isOpen={popUp.duplicateRole.isOpen}
diff --git a/frontend/src/pages/organization/RoleByIDPage/components/DuplicateOrgRoleModal.tsx b/frontend/src/pages/organization/RoleByIDPage/components/DuplicateOrgRoleModal.tsx
index 973d80c1b4..a22f15bad0 100644
--- a/frontend/src/pages/organization/RoleByIDPage/components/DuplicateOrgRoleModal.tsx
+++ b/frontend/src/pages/organization/RoleByIDPage/components/DuplicateOrgRoleModal.tsx
@@ -3,11 +3,13 @@ import { zodResolver } from "@hookform/resolvers/zod";
import { useNavigate } from "@tanstack/react-router";
import { z } from "zod";
+import { UpgradePlanModal } from "@app/components/license/UpgradePlanModal";
import { createNotification } from "@app/components/notifications";
import { Button, FormControl, Input, Modal, ModalContent, Spinner } from "@app/components/v2";
-import { useOrganization } from "@app/context";
+import { useOrganization, useSubscription } from "@app/context";
import { useCreateOrgRole, useGetOrgRole } from "@app/hooks/api";
import { TOrgRole } from "@app/hooks/api/roles/types";
+import { usePopUp } from "@app/hooks/usePopUp";
import { slugSchema } from "@app/lib/schemas";
type Props = {
@@ -43,10 +45,22 @@ const Content = ({ role, onClose }: ContentProps) => {
resolver: zodResolver(schema)
});
+ const { subscription } = useSubscription();
+ const {
+ popUp: upgradePlanPopUp,
+ handlePopUpOpen: handleUpgradePlanPopUpOpen,
+ handlePopUpToggle: handleUpgradePlanPopUpToggle
+ } = usePopUp(["upgradePlan"] as const);
+
const createRole = useCreateOrgRole();
const navigate = useNavigate();
const handleDuplicateRole = async (form: FormData) => {
+ if (subscription && !subscription?.rbac) {
+ handleUpgradePlanPopUpOpen("upgradePlan");
+ return;
+ }
+
const newRole = await createRole.mutateAsync({
orgId: role.orgId,
permissions: role.permissions,
@@ -70,52 +84,70 @@ const Content = ({ role, onClose }: ContentProps) => {
};
return (
- <form onSubmit={handleSubmit(handleDuplicateRole)}>
- <Controller
- control={control}
- defaultValue=""
- name="name"
- render={({ field, fieldState: { error } }) => (
- <FormControl label="Name" isError={Boolean(error)} errorText={error?.message} isRequired>
- <Input {...field} placeholder="Billing Team" />
- </FormControl>
- )}
- />
- <Controller
- control={control}
- defaultValue=""
- name="slug"
- render={({ field, fieldState: { error } }) => (
- <FormControl label="Slug" isError={Boolean(error)} errorText={error?.message} isRequired>
- <Input {...field} placeholder="billing" />
- </FormControl>
- )}
- />
- <Controller
- control={control}
- defaultValue=""
- name="description"
- render={({ field, fieldState: { error } }) => (
- <FormControl label="Description" isError={Boolean(error)} errorText={error?.message}>
- <Input {...field} placeholder="To manage billing" />
- </FormControl>
- )}
+ <>
+ <form onSubmit={handleSubmit(handleDuplicateRole)}>
+ <Controller
+ control={control}
+ defaultValue=""
+ name="name"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Name"
+ isError={Boolean(error)}
+ errorText={error?.message}
+ isRequired
+ >
+ <Input {...field} placeholder="Billing Team" />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ defaultValue=""
+ name="slug"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Slug"
+ isError={Boolean(error)}
+ errorText={error?.message}
+ isRequired
+ >
+ <Input {...field} placeholder="billing" />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ defaultValue=""
+ name="description"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl label="Description" isError={Boolean(error)} errorText={error?.message}>
+ <Input {...field} placeholder="To manage billing" />
+ </FormControl>
+ )}
+ />
+ <div className="flex items-center">
+ <Button
+ className="mr-4"
+ size="sm"
+ type="submit"
+ isLoading={isSubmitting}
+ isDisabled={isSubmitting}
+ >
+ Duplicate Role
+ </Button>
+ <Button colorSchema="secondary" variant="plain" onClick={onClose}>
+ Cancel
+ </Button>
+ </div>
+ </form>
+ <UpgradePlanModal
+ isOpen={upgradePlanPopUp.upgradePlan.isOpen}
+ onOpenChange={(isOpen) => handleUpgradePlanPopUpToggle("upgradePlan", isOpen)}
+ text="Your current plan does not include custom roles. To unlock this feature, please upgrade to Infisical Enterprise plan."
+ isEnterpriseFeature
/>
- <div className="flex items-center">
- <Button
- className="mr-4"
- size="sm"
- type="submit"
- isLoading={isSubmitting}
- isDisabled={isSubmitting}
- >
- Duplicate Role
- </Button>
- <Button colorSchema="secondary" variant="plain" onClick={onClose}>
- Cancel
- </Button>
- </div>
- </form>
+ </>
);
};
diff --git a/frontend/src/pages/organization/RoleByIDPage/components/RoleModal.tsx b/frontend/src/pages/organization/RoleByIDPage/components/RoleModal.tsx
index f47d5ed2ca..72ea8340d4 100644
--- a/frontend/src/pages/organization/RoleByIDPage/components/RoleModal.tsx
+++ b/frontend/src/pages/organization/RoleByIDPage/components/RoleModal.tsx
@@ -4,11 +4,12 @@ import { zodResolver } from "@hookform/resolvers/zod";
import { useNavigate } from "@tanstack/react-router";
import { z } from "zod";
+import { UpgradePlanModal } from "@app/components/license/UpgradePlanModal";
import { createNotification } from "@app/components/notifications";
import { Button, FormControl, Input, Modal, ModalContent } from "@app/components/v2";
-import { useOrganization } from "@app/context";
+import { useOrganization, useSubscription } from "@app/context";
import { useCreateOrgRole, useGetOrgRole, useUpdateOrgRole } from "@app/hooks/api";
-import { UsePopUpState } from "@app/hooks/usePopUp";
+import { usePopUp, UsePopUpState } from "@app/hooks/usePopUp";
import { slugSchema } from "@app/lib/schemas";
const schema = z
@@ -30,6 +31,12 @@ export const RoleModal = ({ popUp, handlePopUpToggle }: Props) => {
const navigate = useNavigate();
const { currentOrg } = useOrganization();
const orgId = currentOrg?.id || "";
+ const { subscription } = useSubscription();
+ const {
+ popUp: upgradePlanPopUp,
+ handlePopUpOpen: handleUpgradePlanPopUpOpen,
+ handlePopUpToggle: handleUpgradePlanPopUpToggle
+ } = usePopUp(["upgradePlan"] as const);
const popupData = popUp?.role?.data as {
roleId: string;
@@ -72,6 +79,11 @@ export const RoleModal = ({ popUp, handlePopUpToggle }: Props) => {
const onFormSubmit = async ({ name, description, slug }: FormData) => {
if (!orgId) return;
+ if (subscription && !subscription?.rbac) {
+ handleUpgradePlanPopUpOpen("upgradePlan");
+ return;
+ }
+
if (role) {
// update
@@ -114,75 +126,87 @@ export const RoleModal = ({ popUp, handlePopUpToggle }: Props) => {
};
return (
- <Modal
- isOpen={popUp?.role?.isOpen}
- onOpenChange={(isOpen) => {
- handlePopUpToggle("role", isOpen);
- reset();
- }}
- >
- <ModalContent title={`${popUp?.role?.data ? "Update" : "Create"} Role`}>
- <form onSubmit={handleSubmit(onFormSubmit)}>
- <Controller
- control={control}
- defaultValue=""
- name="name"
- render={({ field, fieldState: { error } }) => (
- <FormControl
- label="Name"
- isError={Boolean(error)}
- errorText={error?.message}
- isRequired
+ <>
+ <Modal
+ isOpen={popUp?.role?.isOpen}
+ onOpenChange={(isOpen) => {
+ handlePopUpToggle("role", isOpen);
+ reset();
+ }}
+ >
+ <ModalContent title={`${popUp?.role?.data ? "Update" : "Create"} Role`}>
+ <form onSubmit={handleSubmit(onFormSubmit)}>
+ <Controller
+ control={control}
+ defaultValue=""
+ name="name"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Name"
+ isError={Boolean(error)}
+ errorText={error?.message}
+ isRequired
+ >
+ <Input {...field} placeholder="Billing Team" />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ defaultValue=""
+ name="slug"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Slug"
+ isError={Boolean(error)}
+ errorText={error?.message}
+ isRequired
+ >
+ <Input {...field} placeholder="billing" />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ defaultValue=""
+ name="description"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Description"
+ isError={Boolean(error)}
+ errorText={error?.message}
+ >
+ <Input {...field} placeholder="To manage billing" />
+ </FormControl>
+ )}
+ />
+ <div className="flex items-center">
+ <Button
+ className="mr-4"
+ size="sm"
+ type="submit"
+ isLoading={isSubmitting}
+ isDisabled={isSubmitting}
>
- <Input {...field} placeholder="Billing Team" />
- </FormControl>
- )}
- />
- <Controller
- control={control}
- defaultValue=""
- name="slug"
- render={({ field, fieldState: { error } }) => (
- <FormControl
- label="Slug"
- isError={Boolean(error)}
- errorText={error?.message}
- isRequired
+ {popUp?.role?.data ? "Update" : "Create"}
+ </Button>
+ <Button
+ colorSchema="secondary"
+ variant="plain"
+ onClick={() => handlePopUpToggle("role", false)}
>
- <Input {...field} placeholder="billing" />
- </FormControl>
- )}
- />
- <Controller
- control={control}
- defaultValue=""
- name="description"
- render={({ field, fieldState: { error } }) => (
- <FormControl label="Description" isError={Boolean(error)} errorText={error?.message}>
- <Input {...field} placeholder="To manage billing" />
- </FormControl>
- )}
- />
- <div className="flex items-center">
- <Button
- className="mr-4"
- size="sm"
- type="submit"
- isLoading={isSubmitting}
- isDisabled={isSubmitting}
- >
- {popUp?.role?.data ? "Update" : "Create"}
- </Button>
- <Button
- colorSchema="secondary"
- variant="plain"
- onClick={() => handlePopUpToggle("role", false)}
- >
- Cancel
- </Button>
- </div>
- </form>
- </ModalContent>
- </Modal>
+ Cancel
+ </Button>
+ </div>
+ </form>
+ </ModalContent>
+ </Modal>
+ <UpgradePlanModal
+ isOpen={upgradePlanPopUp.upgradePlan.isOpen}
+ onOpenChange={(isOpen) => handleUpgradePlanPopUpToggle("upgradePlan", isOpen)}
+ text="Your current plan does not include custom roles. To unlock this feature, please upgrade to Infisical Enterprise plan."
+ isEnterpriseFeature
+ />
+ </>
);
};
diff --git a/frontend/src/pages/organization/UserDetailsByIDPage/UserDetailsByIDPage.tsx b/frontend/src/pages/organization/UserDetailsByIDPage/UserDetailsByIDPage.tsx
index e4618b1f03..58857dbdfc 100644
--- a/frontend/src/pages/organization/UserDetailsByIDPage/UserDetailsByIDPage.tsx
+++ b/frontend/src/pages/organization/UserDetailsByIDPage/UserDetailsByIDPage.tsx
@@ -257,6 +257,7 @@ const Page = withPermission(
isOpen={popUp.upgradePlan.isOpen}
onOpenChange={(isOpen) => handlePopUpToggle("upgradePlan", isOpen)}
text={popUp.upgradePlan?.data?.text}
+ isEnterpriseFeature={popUp.upgradePlan?.data?.isEnterpriseFeature}
/>
<UserOrgMembershipModal
popUp={popUp}
diff --git a/frontend/src/pages/organization/UserDetailsByIDPage/components/UserOrgMembershipModal.tsx b/frontend/src/pages/organization/UserDetailsByIDPage/components/UserOrgMembershipModal.tsx
index e8b9767344..39ac7a1d56 100644
--- a/frontend/src/pages/organization/UserDetailsByIDPage/components/UserOrgMembershipModal.tsx
+++ b/frontend/src/pages/organization/UserDetailsByIDPage/components/UserOrgMembershipModal.tsx
@@ -137,7 +137,8 @@ export const UserOrgMembershipModal = ({ popUp, handlePopUpOpen, handlePopUpTogg
if (isCustomRole && subscription && !subscription?.rbac) {
handlePopUpOpen("upgradePlan", {
- text: "Your current plan does not include access to assig custom roles to members. To unlock this feature, please upgrade to Infisical Pro plan."
+ text: "Your current plan does not include access to assigning custom roles to members. To unlock this feature, please upgrade to Infisical Enterprise plan.",
+ isEnterpriseFeature: true
});
return;
}
diff --git a/frontend/src/pages/project/AccessControlPage/components/GroupsTab/components/GroupsSection/GroupRoles.tsx b/frontend/src/pages/project/AccessControlPage/components/GroupsTab/components/GroupsSection/GroupRoles.tsx
index 2d42130187..c10ed6c39d 100644
--- a/frontend/src/pages/project/AccessControlPage/components/GroupsTab/components/GroupsSection/GroupRoles.tsx
+++ b/frontend/src/pages/project/AccessControlPage/components/GroupsTab/components/GroupsSection/GroupRoles.tsx
@@ -7,6 +7,7 @@ import { PopperContentProps } from "@radix-ui/react-popper";
import { twMerge } from "tailwind-merge";
import { z } from "zod";
+import { UpgradePlanModal } from "@app/components/license/UpgradePlanModal";
import { createNotification } from "@app/components/notifications";
import {
Button,
@@ -24,8 +25,13 @@ import {
Tag,
Tooltip
} from "@app/components/v2";
-import { ProjectPermissionSub, useProject, useProjectPermission } from "@app/context";
-import { formatProjectRoleName } from "@app/helpers/roles";
+import {
+ ProjectPermissionSub,
+ useProject,
+ useProjectPermission,
+ useSubscription
+} from "@app/context";
+import { formatProjectRoleName, isCustomProjectRole } from "@app/helpers/roles";
import { usePopUp } from "@app/hooks";
import { useGetProjectRoles, useUpdateGroupWorkspaceRole } from "@app/hooks/api";
import { TGroupMembership } from "@app/hooks/api/groups/types";
@@ -220,6 +226,12 @@ type FormProps = {
const GroupRolesForm = ({ projectRoles, roles, groupId, onClose }: FormProps) => {
const { currentProject } = useProject();
+ const { subscription } = useSubscription();
+ const {
+ popUp: upgradePlanPopUp,
+ handlePopUpOpen: handleUpgradePlanPopUpOpen,
+ handlePopUpToggle: handleUpgradePlanPopUpToggle
+ } = usePopUp(["upgradePlan"] as const);
const [searchRoles, setSearchRoles] = useState("");
@@ -237,6 +249,15 @@ const GroupRolesForm = ({ projectRoles, roles, groupId, onClose }: FormProps) =>
});
const handleRoleUpdate = async (data: TForm) => {
+ const hasCustomRole = Object.keys(data)
+ .filter((el) => Boolean(data[el].isChecked))
+ .some((slug) => isCustomProjectRole(slug));
+
+ if (hasCustomRole && subscription && !subscription?.rbac) {
+ handleUpgradePlanPopUpOpen("upgradePlan");
+ return;
+ }
+
const selectedRoles = Object.keys(data)
.filter((el) => Boolean(data[el].isChecked))
.map((el) => {
@@ -369,6 +390,12 @@ const GroupRolesForm = ({ projectRoles, roles, groupId, onClose }: FormProps) =>
</Button>
</div>
</div>
+ <UpgradePlanModal
+ isOpen={upgradePlanPopUp.upgradePlan.isOpen}
+ onOpenChange={(isOpen) => handleUpgradePlanPopUpToggle("upgradePlan", isOpen)}
+ text="Assigning custom roles to groups can be unlocked if you upgrade to Infisical Enterprise plan."
+ isEnterpriseFeature
+ />
</form>
);
};
diff --git a/frontend/src/pages/project/AccessControlPage/components/MembersTab/components/MemberRoleForm/MemberRbacSection.tsx b/frontend/src/pages/project/AccessControlPage/components/MembersTab/components/MemberRoleForm/MemberRbacSection.tsx
index 5be2390429..ff87e9d05e 100644
--- a/frontend/src/pages/project/AccessControlPage/components/MembersTab/components/MemberRoleForm/MemberRbacSection.tsx
+++ b/frontend/src/pages/project/AccessControlPage/components/MembersTab/components/MemberRoleForm/MemberRbacSection.tsx
@@ -122,7 +122,7 @@ export const MemberRbacSection = ({ projectMember, onOpenUpgradeModal }: Props)
if (hasCustomRoleSelected && subscription && !subscription?.rbac) {
onOpenUpgradeModal(
- "You can assign custom roles to members if you upgrade your Infisical plan."
+ "You can assign custom roles to members if you upgrade to Infisical Enterprise plan."
);
return;
}
diff --git a/frontend/src/pages/project/IdentityDetailsByIDPage/components/IdentityRoleDetailsSection/IdentityRoleModify.tsx b/frontend/src/pages/project/IdentityDetailsByIDPage/components/IdentityRoleDetailsSection/IdentityRoleModify.tsx
index dd34b25065..9ced327138 100644
--- a/frontend/src/pages/project/IdentityDetailsByIDPage/components/IdentityRoleDetailsSection/IdentityRoleModify.tsx
+++ b/frontend/src/pages/project/IdentityDetailsByIDPage/components/IdentityRoleDetailsSection/IdentityRoleModify.tsx
@@ -10,6 +10,7 @@ import { twMerge } from "tailwind-merge";
import { z } from "zod";
import { TtlFormLabel } from "@app/components/features";
+import { UpgradePlanModal } from "@app/components/license/UpgradePlanModal";
import { createNotification } from "@app/components/notifications";
import { ProjectPermissionCan } from "@app/components/permissions";
import {
@@ -31,9 +32,11 @@ import {
ProjectPermissionIdentityActions,
ProjectPermissionSub,
useProject,
- useProjectPermission
+ useProjectPermission,
+ useSubscription
} from "@app/context";
-import { formatProjectRoleName } from "@app/helpers/roles";
+import { formatProjectRoleName, isCustomProjectRole } from "@app/helpers/roles";
+import { usePopUp } from "@app/hooks";
import { useGetProjectRoles, useUpdateProjectIdentityMembership } from "@app/hooks/api";
import { IdentityProjectMembershipV1 } from "@app/hooks/api/identities/types";
import { TemporaryPermissionMode } from "@app/hooks/api/shared";
@@ -69,8 +72,14 @@ type Props = {
export const IdentityRoleModify = ({ identityProjectMembership }: Props) => {
const { projectId } = useProject();
+ const { subscription } = useSubscription();
const { data: projectRoles, isPending: isRolesLoading } = useGetProjectRoles(projectId);
const { permission } = useProjectPermission();
+ const {
+ popUp: upgradePlanPopUp,
+ handlePopUpOpen: handleUpgradePlanPopUpOpen,
+ handlePopUpToggle: handleUpgradePlanPopUpToggle
+ } = usePopUp(["upgradePlan"] as const);
const isIdentityEditDisabled = permission.cannot(
ProjectPermissionIdentityActions.Edit,
ProjectPermissionSub.Identity
@@ -150,6 +159,12 @@ export const IdentityRoleModify = ({ identityProjectMembership }: Props) => {
const handleRoleUpdate = async (data: TRoleForm) => {
if (updateProjectIdentityMembership.isPending) return;
+ const hasCustomRole = data.roles.some((el) => isCustomProjectRole(el.slug));
+ if (hasCustomRole && subscription && !subscription?.rbac) {
+ handleUpgradePlanPopUpOpen("upgradePlan");
+ return;
+ }
+
const sanitizedRoles = data.roles.map((el) => {
const { isTemporary } = el.temporaryAccess;
if (!isTemporary) {
@@ -405,6 +420,12 @@ export const IdentityRoleModify = ({ identityProjectMembership }: Props) => {
Save Roles
</Button>
</div>
+ <UpgradePlanModal
+ isOpen={upgradePlanPopUp.upgradePlan.isOpen}
+ onOpenChange={(isOpen) => handleUpgradePlanPopUpToggle("upgradePlan", isOpen)}
+ text="Assigning custom roles to machine identities can be unlocked if you upgrade to Infisical Enterprise plan."
+ isEnterpriseFeature
+ />
</form>
);
};
diff --git a/frontend/src/pages/project/MemberDetailsByIDPage/MemberDetailsByIDPage.tsx b/frontend/src/pages/project/MemberDetailsByIDPage/MemberDetailsByIDPage.tsx
index 2c433bb97e..c934ce6754 100644
--- a/frontend/src/pages/project/MemberDetailsByIDPage/MemberDetailsByIDPage.tsx
+++ b/frontend/src/pages/project/MemberDetailsByIDPage/MemberDetailsByIDPage.tsx
@@ -236,7 +236,8 @@ export const Page = () => {
isMembershipDetailsLoading={isMembershipDetailsLoading}
onOpenUpgradeModal={() =>
handlePopUpOpen("upgradePlan", {
- text: "Assigning custom roles to members can be unlocked if you upgrade to Infisical Pro plan."
+ text: "Assigning custom roles to members can be unlocked if you upgrade to Infisical Enterprise plan.",
+ isEnterpriseFeature: true
})
}
/>
@@ -263,6 +264,7 @@ export const Page = () => {
isOpen={popUp.upgradePlan.isOpen}
onOpenChange={(isOpen) => handlePopUpToggle("upgradePlan", isOpen)}
text={popUp.upgradePlan?.data?.text}
+ isEnterpriseFeature={popUp.upgradePlan?.data?.isEnterpriseFeature}
/>
</>
) : (
diff --git a/frontend/src/pages/project/RoleDetailsBySlugPage/components/DuplicateProjectRoleModal.tsx b/frontend/src/pages/project/RoleDetailsBySlugPage/components/DuplicateProjectRoleModal.tsx
index e315d50b31..79d3d2e04a 100644
--- a/frontend/src/pages/project/RoleDetailsBySlugPage/components/DuplicateProjectRoleModal.tsx
+++ b/frontend/src/pages/project/RoleDetailsBySlugPage/components/DuplicateProjectRoleModal.tsx
@@ -3,13 +3,15 @@ import { zodResolver } from "@hookform/resolvers/zod";
import { useNavigate } from "@tanstack/react-router";
import { z } from "zod";
+import { UpgradePlanModal } from "@app/components/license/UpgradePlanModal";
import { createNotification } from "@app/components/notifications";
import { Button, FormControl, Input, Modal, ModalContent, Spinner } from "@app/components/v2";
-import { ProjectPermissionSub, useOrganization, useProject } from "@app/context";
+import { ProjectPermissionSub, useOrganization, useProject, useSubscription } from "@app/context";
import { ProjectPermissionSecretActions } from "@app/context/ProjectPermissionContext/types";
import { getProjectBaseURL } from "@app/helpers/project";
import { useCreateProjectRole, useGetProjectRoleBySlug } from "@app/hooks/api";
import { TProjectRole } from "@app/hooks/api/roles/types";
+import { usePopUp } from "@app/hooks/usePopUp";
import { slugSchema } from "@app/lib/schemas";
type Props = {
@@ -47,11 +49,22 @@ const Content = ({ role, onClose }: ContentProps) => {
const { currentOrg } = useOrganization();
const { currentProject } = useProject();
+ const { subscription } = useSubscription();
+ const {
+ popUp: upgradePlanPopUp,
+ handlePopUpOpen: handleUpgradePlanPopUpOpen,
+ handlePopUpToggle: handleUpgradePlanPopUpToggle
+ } = usePopUp(["upgradePlan"] as const);
const createRole = useCreateProjectRole();
const navigate = useNavigate();
const handleDuplicateRole = async (form: FormData) => {
+ if (subscription && !subscription?.rbac) {
+ handleUpgradePlanPopUpOpen("upgradePlan");
+ return;
+ }
+
const sanitizedPermission = role.permissions.map((permission) => {
if (
// if contains new secret action the legacy one can be stripped off
@@ -94,52 +107,70 @@ const Content = ({ role, onClose }: ContentProps) => {
};
return (
- <form onSubmit={handleSubmit(handleDuplicateRole)}>
- <Controller
- control={control}
- defaultValue=""
- name="name"
- render={({ field, fieldState: { error } }) => (
- <FormControl label="Name" isError={Boolean(error)} errorText={error?.message} isRequired>
- <Input {...field} placeholder="Billing Team" />
- </FormControl>
- )}
- />
- <Controller
- control={control}
- defaultValue=""
- name="slug"
- render={({ field, fieldState: { error } }) => (
- <FormControl label="Slug" isError={Boolean(error)} errorText={error?.message} isRequired>
- <Input {...field} placeholder="billing" />
- </FormControl>
- )}
- />
- <Controller
- control={control}
- defaultValue=""
- name="description"
- render={({ field, fieldState: { error } }) => (
- <FormControl label="Description" isError={Boolean(error)} errorText={error?.message}>
- <Input {...field} placeholder="To manage billing" />
- </FormControl>
- )}
+ <>
+ <form onSubmit={handleSubmit(handleDuplicateRole)}>
+ <Controller
+ control={control}
+ defaultValue=""
+ name="name"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Name"
+ isError={Boolean(error)}
+ errorText={error?.message}
+ isRequired
+ >
+ <Input {...field} placeholder="Billing Team" />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ defaultValue=""
+ name="slug"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Slug"
+ isError={Boolean(error)}
+ errorText={error?.message}
+ isRequired
+ >
+ <Input {...field} placeholder="billing" />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ defaultValue=""
+ name="description"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl label="Description" isError={Boolean(error)} errorText={error?.message}>
+ <Input {...field} placeholder="To manage billing" />
+ </FormControl>
+ )}
+ />
+ <div className="flex items-center">
+ <Button
+ className="mr-4"
+ size="sm"
+ type="submit"
+ isLoading={isSubmitting}
+ isDisabled={isSubmitting}
+ >
+ Duplicate Role
+ </Button>
+ <Button colorSchema="secondary" variant="plain" onClick={onClose}>
+ Cancel
+ </Button>
+ </div>
+ </form>
+ <UpgradePlanModal
+ isOpen={upgradePlanPopUp.upgradePlan.isOpen}
+ onOpenChange={(isOpen) => handleUpgradePlanPopUpToggle("upgradePlan", isOpen)}
+ text="Your current plan does not include custom roles. To unlock this feature, please upgrade to Infisical Enterprise plan."
+ isEnterpriseFeature
/>
- <div className="flex items-center">
- <Button
- className="mr-4"
- size="sm"
- type="submit"
- isLoading={isSubmitting}
- isDisabled={isSubmitting}
- >
- Duplicate Role
- </Button>
- <Button colorSchema="secondary" variant="plain" onClick={onClose}>
- Cancel
- </Button>
- </div>
- </form>
+ </>
);
};
diff --git a/frontend/src/pages/project/RoleDetailsBySlugPage/components/RoleModal.tsx b/frontend/src/pages/project/RoleDetailsBySlugPage/components/RoleModal.tsx
index 4fcb246ef2..ba64bc3c3b 100644
--- a/frontend/src/pages/project/RoleDetailsBySlugPage/components/RoleModal.tsx
+++ b/frontend/src/pages/project/RoleDetailsBySlugPage/components/RoleModal.tsx
@@ -4,16 +4,17 @@ import { zodResolver } from "@hookform/resolvers/zod";
import { useNavigate } from "@tanstack/react-router";
import { z } from "zod";
+import { UpgradePlanModal } from "@app/components/license/UpgradePlanModal";
import { createNotification } from "@app/components/notifications";
import { Button, FormControl, Input, Modal, ModalContent } from "@app/components/v2";
-import { useOrganization, useProject } from "@app/context";
+import { useOrganization, useProject, useSubscription } from "@app/context";
import { getProjectBaseURL } from "@app/helpers/project";
import {
useCreateProjectRole,
useGetProjectRoleBySlug,
useUpdateProjectRole
} from "@app/hooks/api";
-import { UsePopUpState } from "@app/hooks/usePopUp";
+import { usePopUp, UsePopUpState } from "@app/hooks/usePopUp";
import { slugSchema } from "@app/lib/schemas";
const schema = z
@@ -43,6 +44,12 @@ export const RoleModal = ({ popUp, handlePopUpToggle }: Props) => {
const { currentProject } = useProject();
const projectId = currentProject?.id || "";
+ const { subscription } = useSubscription();
+ const {
+ popUp: upgradePlanPopUp,
+ handlePopUpOpen: handleUpgradePlanPopUpOpen,
+ handlePopUpToggle: handleUpgradePlanPopUpToggle
+ } = usePopUp(["upgradePlan"] as const);
const { data: role } = useGetProjectRoleBySlug(projectId, popupData?.roleSlug ?? "");
@@ -81,6 +88,11 @@ export const RoleModal = ({ popUp, handlePopUpToggle }: Props) => {
const onFormSubmit = async ({ name, description, slug }: FormData) => {
if (!projectId) return;
+ if (subscription && !subscription?.rbac) {
+ handleUpgradePlanPopUpOpen("upgradePlan");
+ return;
+ }
+
if (role) {
// update
await updateProjectRole({
@@ -132,75 +144,87 @@ export const RoleModal = ({ popUp, handlePopUpToggle }: Props) => {
};
return (
- <Modal
- isOpen={popUp?.role?.isOpen}
- onOpenChange={(isOpen) => {
- handlePopUpToggle("role", isOpen);
- reset();
- }}
- >
- <ModalContent title={`${popUp?.role?.data ? "Update" : "Create"} Role`}>
- <form onSubmit={handleSubmit(onFormSubmit)}>
- <Controller
- control={control}
- defaultValue=""
- name="name"
- render={({ field, fieldState: { error } }) => (
- <FormControl
- label="Name"
- isError={Boolean(error)}
- errorText={error?.message}
- isRequired
+ <>
+ <Modal
+ isOpen={popUp?.role?.isOpen}
+ onOpenChange={(isOpen) => {
+ handlePopUpToggle("role", isOpen);
+ reset();
+ }}
+ >
+ <ModalContent title={`${popUp?.role?.data ? "Update" : "Create"} Role`}>
+ <form onSubmit={handleSubmit(onFormSubmit)}>
+ <Controller
+ control={control}
+ defaultValue=""
+ name="name"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Name"
+ isError={Boolean(error)}
+ errorText={error?.message}
+ isRequired
+ >
+ <Input {...field} placeholder="Billing Team" />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ defaultValue=""
+ name="slug"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Slug"
+ isError={Boolean(error)}
+ errorText={error?.message}
+ isRequired
+ >
+ <Input {...field} placeholder="billing" />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ defaultValue=""
+ name="description"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Description"
+ isError={Boolean(error)}
+ errorText={error?.message}
+ >
+ <Input {...field} placeholder="To manage billing" />
+ </FormControl>
+ )}
+ />
+ <div className="flex items-center">
+ <Button
+ className="mr-4"
+ size="sm"
+ type="submit"
+ isLoading={isSubmitting}
+ isDisabled={isSubmitting}
>
- <Input {...field} placeholder="Billing Team" />
- </FormControl>
- )}
- />
- <Controller
- control={control}
- defaultValue=""
- name="slug"
- render={({ field, fieldState: { error } }) => (
- <FormControl
- label="Slug"
- isError={Boolean(error)}
- errorText={error?.message}
- isRequired
+ {popUp?.role?.data ? "Update" : "Create"}
+ </Button>
+ <Button
+ colorSchema="secondary"
+ variant="plain"
+ onClick={() => handlePopUpToggle("role", false)}
>
- <Input {...field} placeholder="billing" />
- </FormControl>
- )}
- />
- <Controller
- control={control}
- defaultValue=""
- name="description"
- render={({ field, fieldState: { error } }) => (
- <FormControl label="Description" isError={Boolean(error)} errorText={error?.message}>
- <Input {...field} placeholder="To manage billing" />
- </FormControl>
- )}
- />
- <div className="flex items-center">
- <Button
- className="mr-4"
- size="sm"
- type="submit"
- isLoading={isSubmitting}
- isDisabled={isSubmitting}
- >
- {popUp?.role?.data ? "Update" : "Create"}
- </Button>
- <Button
- colorSchema="secondary"
- variant="plain"
- onClick={() => handlePopUpToggle("role", false)}
- >
- Cancel
- </Button>
- </div>
- </form>
- </ModalContent>
- </Modal>
+ Cancel
+ </Button>
+ </div>
+ </form>
+ </ModalContent>
+ </Modal>
+ <UpgradePlanModal
+ isOpen={upgradePlanPopUp.upgradePlan.isOpen}
+ onOpenChange={(isOpen) => handleUpgradePlanPopUpToggle("upgradePlan", isOpen)}
+ text="Your current plan does not include custom roles. To unlock this feature, please upgrade to Infisical Enterprise plan."
+ isEnterpriseFeature
+ />
+ </>
);
};