Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
add shared role listing badge
Thiago Araujo da Silvab88eee082d32
diff --git a/backend/src/ee/services/license/license-fns.ts b/backend/src/ee/services/license/license-fns.tsindex 3ac5621b0c..c962a48804 100644--- a/backend/src/ee/services/license/license-fns.ts+++ b/backend/src/ee/services/license/license-fns.ts@@ -68,7 +68,7 @@ export const getDefaultOnPremFeatures = (): TFeatureSet => ({secretVersioning: true,pitRecovery: false,ipAllowlisting: false,- rbac: false,+ rbac: true,githubOrgSync: false,customRateLimits: false,subOrganization: false,diff --git a/backend/src/ee/services/license/license-types.ts b/backend/src/ee/services/license/license-types.tsindex 69b5e18c7f..525c3b2c1a 100644--- a/backend/src/ee/services/license/license-types.ts+++ b/backend/src/ee/services/license/license-types.ts@@ -48,7 +48,7 @@ export type TFeatureSet = {secretVersioning: true;pitRecovery: false;ipAllowlisting: false;- rbac: false;+ rbac: true;customRateLimits: false;customAlerts: false;auditLogs: false;diff --git a/backend/src/services/membership-identity/membership-identity-dal.ts b/backend/src/services/membership-identity/membership-identity-dal.tsindex e01f10b973..58f8215775 100644--- a/backend/src/services/membership-identity/membership-identity-dal.ts+++ b/backend/src/services/membership-identity/membership-identity-dal.ts@@ -297,6 +297,7 @@ export const membershipIdentityDALFactory = (db: TDbClient) => {db.ref("hasDeleteProtection").withSchema(TableName.Identity).as("identityHasDeleteProtection"),db.ref("slug").withSchema(TableName.Role).as("roleSlug"),+ db.ref("name").withSchema(TableName.Role).as("roleName"),db.ref("id").withSchema(TableName.MembershipRole).as("membershipRoleId"),db.ref("role").withSchema(TableName.MembershipRole).as("membershipRole"),db.ref("temporaryMode").withSchema(TableName.MembershipRole).as("membershipRoleTemporaryMode"),@@ -343,6 +344,7 @@ export const membershipIdentityDALFactory = (db: TDbClient) => {label: "roles" as const,mapper: ({roleSlug,+ roleName,membershipRoleId,membershipRole,membershipRoleIsTemporary,@@ -355,6 +357,7 @@ export const membershipIdentityDALFactory = (db: TDbClient) => {}) => ({id: membershipRoleId,role: membershipRole,+ customRoleName: roleName,customRoleSlug: roleSlug,temporaryRange: membershipRoleTemporaryRange,temporaryMode: membershipRoleTemporaryMode,diff --git a/frontend/src/components/v3/platform/IdentityRoleBadges/IdentityRoleBadges.tsx b/frontend/src/components/v3/platform/IdentityRoleBadges/IdentityRoleBadges.tsxnew file mode 100644index 0000000000..b2de34ffcb--- /dev/null+++ b/frontend/src/components/v3/platform/IdentityRoleBadges/IdentityRoleBadges.tsx@@ -0,0 +1,116 @@+import { ClockAlertIcon, ClockIcon } from "lucide-react";++import { formatProjectRoleName } from "@app/helpers/roles";+import { ProjectMembershipRole } from "@app/hooks/api/roles/types";++import { Badge } from "../../generic/Badge";+import { Popover, PopoverContent, PopoverTrigger } from "../../generic/Popover";+import { Tooltip, TooltipContent, TooltipTrigger } from "../../generic/Tooltip";+import { cn } from "../../utils";++// Minimal shape shared by the org search and project membership role payloads. Both tables feed+// their respective role objects in here, so keep this structural (don't reach for a domain type).+export type TIdentityRoleBadge = {+ id: string;+ role: string;+ customRoleName?: string | null;+ isTemporary?: boolean | null;+ temporaryAccessEndTime?: string | null;+};++type TIdentityRoleBadgesProps = {+ roles: TIdentityRoleBadge[];+ // Pills rendered inline before collapsing the rest into a "+N" popover.+ maxVisible?: number;+};++const DEFAULT_MAX_VISIBLE = 2;++const getRoleLabel = (role: TIdentityRoleBadge) =>+ formatProjectRoleName(role.role, role.customRoleName ?? undefined);++const isRoleExpired = (role: TIdentityRoleBadge) =>+ Boolean(role.isTemporary && role.temporaryAccessEndTime) &&+ new Date() > new Date(role.temporaryAccessEndTime as string);++const RoleBadge = ({ role, className }: { role: TIdentityRoleBadge; className?: string }) => {+ const expired = isRoleExpired(role);+ const label = getRoleLabel(role);+ const isCustom = role.role === ProjectMembershipRole.Custom;++ // Custom names can be arbitrarily long, so cap the width and truncate. A short built-in role+ // never needs the extra chrome, but a custom name (which the cap may clip) or a temporary role+ // (whose icon needs explaining) gets a tooltip revealing the full label + access status.+ const badge = (+ <Badge+ variant={expired ? "danger" : "neutral"}+ isTruncatable+ className={cn("max-w-[10rem]", className)}+ >+ <span className="capitalize">{label}</span>+ {role.isTemporary && (expired ? <ClockAlertIcon /> : <ClockIcon />)}+ </Badge>+ );++ if (!isCustom && !role.isTemporary) {+ return badge;+ }++ return (+ <Tooltip>+ <TooltipTrigger asChild>{badge}</TooltipTrigger>+ <TooltipContent className="flex flex-col gap-0.5">+ <span className="capitalize">{label}</span>+ {role.isTemporary && (+ <span className="opacity-70">{expired ? "Access expired" : "Temporary access"}</span>+ )}+ </TooltipContent>+ </Tooltip>+ );+};++export const IdentityRoleBadges = ({+ roles,+ maxVisible = DEFAULT_MAX_VISIBLE+}: TIdentityRoleBadgesProps) => {+ // Sort by displayed label so both tables show the same order regardless of how each endpoint+ // happens to return its (unordered) role rows.+ const sortedRoles = [...roles].sort((a, b) =>+ getRoleLabel(a).localeCompare(getRoleLabel(b), undefined, { sensitivity: "base" })+ );+ const visible = sortedRoles.slice(0, maxVisible);+ const overflow = sortedRoles.slice(maxVisible);++ return (+ <div className="flex items-center gap-1.5">+ {visible.map((role) => (+ <RoleBadge key={role.id} role={role} />+ ))}+ {overflow.length > 0 && (+ <Popover>+ <Tooltip>+ <TooltipTrigger className="flex h-4 items-center">+ <PopoverTrigger asChild>+ <Badge variant="neutral" asChild>+ <button type="button" onClick={(e) => e.stopPropagation()}>+ +{overflow.length}+ </button>+ </Badge>+ </PopoverTrigger>+ </TooltipTrigger>+ <TooltipContent>Click to view additional roles</TooltipContent>+ </Tooltip>+ <PopoverContent+ side="right"+ className="flex w-auto max-w-sm flex-wrap gap-1.5"+ onClick={(e) => e.stopPropagation()}+ >+ {overflow.map((role) => (+ <RoleBadge key={role.id} role={role} className="z-10" />+ ))}+ </PopoverContent>+ </Popover>+ )}+ </div>+ );+};diff --git a/frontend/src/components/v3/platform/IdentityRoleBadges/index.ts b/frontend/src/components/v3/platform/IdentityRoleBadges/index.tsnew file mode 100644index 0000000000..2f1a69aa21--- /dev/null+++ b/frontend/src/components/v3/platform/IdentityRoleBadges/index.ts@@ -0,0 +1 @@+export * from "./IdentityRoleBadges";diff --git a/frontend/src/components/v3/platform/index.ts b/frontend/src/components/v3/platform/index.tsindex bdb3389b35..2e57a96c34 100644--- a/frontend/src/components/v3/platform/index.ts+++ b/frontend/src/components/v3/platform/index.ts@@ -1,6 +1,7 @@export * from "./DateRangeFilter";export * from "./DocumentationLinkBadge";export * from "./GatewayPicker";+export * from "./IdentityRoleBadges";export * from "./PageLoader";export * from "./PasswordGenerator";export * from "./ScopeIcons";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.tsxindex 5d10afeae5..b34c522f40 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@@ -3,8 +3,6 @@ import { useNavigate } from "@tanstack/react-router";import { formatDistanceToNow } from "date-fns";import {ChevronDownIcon,- ClockAlertIcon,- ClockIcon,EditIcon,FilterIcon,MoreHorizontalIcon,@@ -28,14 +26,12 @@ import {EmptyHeader,EmptyTitle,IconButton,+ IdentityRoleBadges,InputGroup,InputGroupAddon,InputGroupInput,OrgIcon,Pagination,- Popover,- PopoverContent,- PopoverTrigger,ProjectIcon,Skeleton,SubOrgIcon,@@ -54,7 +50,6 @@ import {} from "@app/components/v3";import { OrgPermissionIdentityActions, OrgPermissionSubjects, useOrganization } from "@app/context";import { getProjectBaseURL } from "@app/helpers/project";-import { formatProjectRoleName } from "@app/helpers/roles";import {getUserTablePreference,PreferenceKey,@@ -68,11 +63,7 @@ import {useSearchOrgIdentityMemberships} from "@app/hooks/api";import { OrderByDirection } from "@app/hooks/api/generic/types";-import {- IdentityMembershipSearchResult,- IdentityMembershipSearchRole,- SearchIdentitiesScope-} from "@app/hooks/api/identities";+import { IdentityMembershipSearchResult, SearchIdentitiesScope } from "@app/hooks/api/identities";import { OrgIdentityOrderBy } from "@app/hooks/api/organization/types";import { UsePopUpState } from "@app/hooks/usePopUp";@@ -94,8 +85,6 @@ type Filter = {type ScopeTab = "all" | "organization" | "project";-const MAX_ROLES_TO_BE_SHOWN_IN_TABLE = 2;-const TAB_TO_SCOPE: Record<ScopeTab, SearchIdentitiesScope[]> = {all: [SearchIdentitiesScope.OrganizationScope, SearchIdentitiesScope.ProjectScope],organization: [SearchIdentitiesScope.OrganizationScope],@@ -110,11 +99,6 @@ const formatLastUsed = (lastLoginTime?: string | null) => {return `${formatDistanceToNow(date)} ago`;};-const isRoleExpired = (role: IdentityMembershipSearchRole) =>- role.isTemporary &&- !!role.temporaryAccessEndTime &&- new Date() > new Date(role.temporaryAccessEndTime);-type SortableHeadProps = {column: OrgIdentityOrderBy;label: string;@@ -139,69 +123,6 @@ const SortableHead = ({ column, label, activeColumn, direction, onSort }: Sortab);};-const RoleBadge = ({- role,- className-}: {- role: IdentityMembershipSearchRole;- className?: string;-}) => {- const expired = isRoleExpired(role);- return (- <Badge variant={expired ? "danger" : "neutral"} className={className}>- <span className="capitalize">- {formatProjectRoleName(role.role, role.customRoleName ?? undefined)}- </span>- {role.isTemporary && (- <Tooltip>- <TooltipTrigger tabIndex={-1}>- {expired ? <ClockAlertIcon /> : <ClockIcon />}- </TooltipTrigger>- <TooltipContent>{expired ? "Access expired" : "Temporary access"}</TooltipContent>- </Tooltip>- )}- </Badge>- );-};--const RolesCell = ({ roles }: { roles: IdentityMembershipSearchRole[] }) => {- const visible = roles.slice(0, MAX_ROLES_TO_BE_SHOWN_IN_TABLE);- const overflow = roles.slice(MAX_ROLES_TO_BE_SHOWN_IN_TABLE);-- return (- <div className="flex items-center gap-1.5">- {visible.map((role) => (- <RoleBadge key={role.id} role={role} />- ))}- {overflow.length > 0 && (- <Popover>- <Tooltip>- <TooltipTrigger className="flex h-4 items-center">- <PopoverTrigger asChild>- <Badge variant="neutral" asChild>- <button type="button" onClick={(e) => e.stopPropagation()}>- +{overflow.length}- </button>- </Badge>- </PopoverTrigger>- </TooltipTrigger>- <TooltipContent>Click to view additional roles</TooltipContent>- </Tooltip>- <PopoverContent- side="right"- className="flex w-auto max-w-sm flex-wrap gap-1.5"- onClick={(e) => e.stopPropagation()}- >- {overflow.map((role) => (- <RoleBadge key={role.id} role={role} className="z-10" />- ))}- </PopoverContent>- </Popover>- )}- </div>- );-};-type ManagedByCellProps = {scope: SearchIdentitiesScope;project?: IdentityMembershipSearchResult["project"];@@ -419,7 +340,7 @@ const IdentityRow = ({ membership, onDelete }: IdentityRowProps) => {<TableRow className="cursor-pointer" onClick={navigateToIdentity}><TableCell isTruncatable>{name}</TableCell><TableCell>- <RolesCell roles={membershipRoles ?? []} />+ <IdentityRoleBadges roles={membershipRoles ?? []} /></TableCell><TableCell><ManagedByCelldiff --git a/frontend/src/pages/project/AccessControlPage/components/IdentityTab/IdentityTab.tsx b/frontend/src/pages/project/AccessControlPage/components/IdentityTab/IdentityTab.tsxindex 80dbdc3bb2..4c2391ef17 100644--- a/frontend/src/pages/project/AccessControlPage/components/IdentityTab/IdentityTab.tsx+++ b/frontend/src/pages/project/AccessControlPage/components/IdentityTab/IdentityTab.tsx@@ -3,8 +3,6 @@ import { subject } from "@casl/ability";import { useNavigate } from "@tanstack/react-router";import {ChevronDownIcon,- ClockAlertIcon,- ClockIcon,FilterIcon,InfoIcon,MoreHorizontalIcon,@@ -45,14 +43,12 @@ import {EmptyHeader,EmptyTitle,IconButton,+ IdentityRoleBadges,InputGroup,InputGroupAddon,InputGroupInput,OrgIcon,Pagination,- Popover,- PopoverContent,- PopoverTrigger,ProjectIcon,Skeleton,SubOrgIcon,@@ -76,7 +72,6 @@ import {useProject} from "@app/context";import { getProjectBaseURL } from "@app/helpers/project";-import { formatProjectRoleName } from "@app/helpers/roles";import {getUserTablePreference,PreferenceKey,@@ -97,8 +92,6 @@ import { ProjectIdentityModal } from "@app/pages/project/AccessControlPage/compoimport { ProjectLinkIdentityModal } from "./components/ProjectLinkIdentityModal";-const MAX_ROLES_TO_BE_SHOWN_IN_TABLE = 2;-enum AddIdentityType {CreateNew = "create-new",AssignExisting = "assign-existing"@@ -414,114 +407,7 @@ export const IdentityTab = withProjectPermission(><TableCell isTruncatable>{name}</TableCell><TableCell>- <div className="flex items-center gap-1.5">- {roles- .slice(0, MAX_ROLES_TO_BE_SHOWN_IN_TABLE)- .map(- ({- role,- customRoleName,- id: roleId,- isTemporary,- temporaryAccessEndTime- }) => {- const isExpired =- new Date() >- new Date(temporaryAccessEndTime || ("" as string));- return (- <Badge- key={roleId}- variant={isExpired ? "danger" : "neutral"}- >- <span className="capitalize">- {formatProjectRoleName(role, customRoleName)}- </span>- {isTemporary && (- <Tooltip>- <TooltipTrigger>- <ClockIcon />- </TooltipTrigger>- <TooltipContent>- {isExpired- ? "Access expired"- : "Temporary access"}- </TooltipContent>- </Tooltip>- )}- </Badge>- );- }- )}- {roles.length > MAX_ROLES_TO_BE_SHOWN_IN_TABLE && (- <Popover>- <Tooltip>- <TooltipTrigger className="flex h-4 items-center">- <PopoverTrigger asChild>- <Badge variant="neutral" asChild>- <button- type="button"- onClick={(e) => e.stopPropagation()}- >- +{roles.length - MAX_ROLES_TO_BE_SHOWN_IN_TABLE}- </button>- </Badge>- </PopoverTrigger>- </TooltipTrigger>- <TooltipContent>- Click to view additional roles- </TooltipContent>- </Tooltip>- <PopoverContent- side="right"- className="flex w-auto max-w-sm flex-wrap gap-1.5"- onClick={(e) => e.stopPropagation()}- >- {roles- .slice(MAX_ROLES_TO_BE_SHOWN_IN_TABLE)- .map(- ({- role,- customRoleName,- id: roleId,- isTemporary,- temporaryAccessEndTime- }) => {- const isExpired =- new Date() >- new Date(temporaryAccessEndTime || ("" as string));- return (- <Badge- key={roleId}- className="z-10"- variant={isExpired ? "danger" : "neutral"}- >- <span className="capitalize">- {formatProjectRoleName(role, customRoleName)}- </span>- {isTemporary && (- <Tooltip>- <TooltipTrigger tabIndex={-1}>- {isExpired ? (- <ClockAlertIcon />- ) : (- <ClockIcon />- )}- </TooltipTrigger>- <TooltipContent>- {isExpired- ? "Access expired"- : "Temporary access"}- </TooltipContent>- </Tooltip>- )}- </Badge>- );- }- )}- </PopoverContent>- </Popover>- )}- </div>+ <IdentityRoleBadges roles={roles} /></TableCell><TableCell><Badge