Skip to content

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

PKI Signers improvements

Carlos Monastyrski1e92a81d6338
diff --git a/frontend/src/hooks/api/approvalGrants/queries.tsx b/frontend/src/hooks/api/approvalGrants/queries.tsx
index ca9334ca71..1004286b3f 100644
--- a/frontend/src/hooks/api/approvalGrants/queries.tsx
+++ b/frontend/src/hooks/api/approvalGrants/queries.tsx
@@ -28,7 +28,8 @@ export const approvalGrantQuery = {
grants: TApprovalGrant[];
}>(`/api/v1/approval-policies/${params.policyType}/grants`, {
params: {
- projectId: params.projectId
+ scope: params.scope,
+ id: params.id
}
});
return data.grants;
diff --git a/frontend/src/hooks/api/approvalGrants/types.ts b/frontend/src/hooks/api/approvalGrants/types.ts
index 970bd3cb63..d7639ec3df 100644
--- a/frontend/src/hooks/api/approvalGrants/types.ts
+++ b/frontend/src/hooks/api/approvalGrants/types.ts
@@ -1,4 +1,4 @@
-import { ApprovalPolicyType } from "../approvalPolicies";
+import { ApprovalPolicyScope, ApprovalPolicyType } from "../approvalPolicies";
export enum ApprovalGrantStatus {
Active = "active",
@@ -43,7 +43,8 @@ export type TApprovalGrant = {
// DTOs
export type TListApprovalGrantsDTO = {
policyType: ApprovalPolicyType;
- projectId: string;
+ scope: ApprovalPolicyScope;
+ id: string;
};
export type TGetApprovalGrantByIdDTO = {
diff --git a/frontend/src/layouts/OrganizationLayout/components/OrgSidebar/CertManagerNav.tsx b/frontend/src/layouts/OrganizationLayout/components/OrgSidebar/CertManagerNav.tsx
index ec31ec3413..05f96b9fef 100644
--- a/frontend/src/layouts/OrganizationLayout/components/OrgSidebar/CertManagerNav.tsx
+++ b/frontend/src/layouts/OrganizationLayout/components/OrgSidebar/CertManagerNav.tsx
@@ -58,7 +58,7 @@ export const CertManagerNav = ({
}),
enabled: isCertManagerAdmin && Boolean(projectId)
});
- const { data: pendingRequestsCount = 0 } = useQuery({
+ const { data: pendingCertRequestsCount = 0 } = useQuery({
...approvalRequestQuery.list({
scope: ApprovalPolicyScope.Project,
scopeId: projectId,
@@ -67,6 +67,16 @@ export const CertManagerNav = ({
enabled: Boolean(projectId),
select: (requests) => requests.filter((r) => r.status === ApprovalRequestStatus.Pending).length
});
+ const { data: pendingSigningRequestsCount = 0 } = useQuery({
+ ...approvalRequestQuery.list({
+ scope: ApprovalPolicyScope.Project,
+ scopeId: projectId,
+ policyType: ApprovalPolicyType.CertCodeSigning
+ }),
+ enabled: Boolean(projectId),
+ select: (requests) => requests.filter((r) => r.status === ApprovalRequestStatus.Pending).length
+ });
+ const pendingRequestsCount = pendingCertRequestsCount + pendingSigningRequestsCount;
const hasLegacyAlerts =
Boolean(v2AlertsData?.alerts?.some((a) => !a.applicationId)) ||
diff --git a/frontend/src/pages/cert-manager/ApplicationDetailsByIDPage/components/ApplicationMembersTab.tsx b/frontend/src/pages/cert-manager/ApplicationDetailsByIDPage/components/ApplicationMembersTab.tsx
index 4b8029c798..fc3581783f 100644
--- a/frontend/src/pages/cert-manager/ApplicationDetailsByIDPage/components/ApplicationMembersTab.tsx
+++ b/frontend/src/pages/cert-manager/ApplicationDetailsByIDPage/components/ApplicationMembersTab.tsx
@@ -105,11 +105,7 @@ export const ApplicationMembersTab = ({ members, applicationId }: Props) => {
Users, machine identities, and groups granted access to this Application.
</CardDescription>
<CardAction>
- <Button
- variant="outline"
- onClick={() => setIsAddOpen(true)}
- isDisabled={!canAddMember}
- >
+ <Button variant="outline" onClick={() => setIsAddOpen(true)} isDisabled={!canAddMember}>
<UserPlusIcon />
Add Member
</Button>
diff --git a/frontend/src/pages/cert-manager/ApprovalsPage/components/CodeSigningGrantsTab/CodeSigningGrantsTab.tsx b/frontend/src/pages/cert-manager/ApprovalsPage/components/CodeSigningGrantsTab/CodeSigningGrantsTab.tsx
index 643111aab6..65f712c411 100644
--- a/frontend/src/pages/cert-manager/ApprovalsPage/components/CodeSigningGrantsTab/CodeSigningGrantsTab.tsx
+++ b/frontend/src/pages/cert-manager/ApprovalsPage/components/CodeSigningGrantsTab/CodeSigningGrantsTab.tsx
@@ -1,44 +1,45 @@
import { useMemo, useState } from "react";
import { useForm } from "react-hook-form";
-import {
- faCheckCircle,
- faChevronRight,
- faFilter,
- faInfo,
- faXmark
-} from "@fortawesome/free-solid-svg-icons";
-import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { zodResolver } from "@hookform/resolvers/zod";
import { useQuery } from "@tanstack/react-query";
import { Link } from "@tanstack/react-router";
import { format } from "date-fns";
-import { MoreHorizontalIcon, SearchIcon } from "lucide-react";
+import {
+ ChevronRightIcon,
+ CircleCheckIcon,
+ FilterIcon,
+ InfoIcon,
+ MoreHorizontalIcon,
+ SearchIcon,
+ XIcon
+} from "lucide-react";
import { twMerge } from "tailwind-merge";
import { z } from "zod";
import { createNotification } from "@app/components/notifications";
-import {
- Button,
- DropdownMenu,
- DropdownMenuContent,
- DropdownMenuItem,
- DropdownMenuLabel,
- DropdownMenuTrigger,
- DropdownSubMenu,
- DropdownSubMenuContent,
- DropdownSubMenuTrigger,
- FormControl,
- Modal,
- ModalContent,
- TextArea
-} from "@app/components/v2";
+import { FormControl, TextArea } from "@app/components/v2";
import {
Badge,
+ Button,
Card,
CardContent,
CardDescription,
CardHeader,
CardTitle,
+ Dialog,
+ DialogContent,
+ DialogDescription,
+ DialogFooter,
+ DialogHeader,
+ DialogTitle,
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuLabel,
+ DropdownMenuSub,
+ DropdownMenuSubContent,
+ DropdownMenuSubTrigger,
+ DropdownMenuTrigger,
Empty,
EmptyDescription,
EmptyHeader,
@@ -66,7 +67,7 @@ import {
CodeSigningGrantAttributes,
useRevokeApprovalGrant
} from "@app/hooks/api/approvalGrants";
-import { ApprovalPolicyType } from "@app/hooks/api/approvalPolicies";
+import { ApprovalPolicyScope, ApprovalPolicyType } from "@app/hooks/api/approvalPolicies";
import { useListProjectIdentityMemberships } from "@app/hooks/api/projectIdentityMembership/queries";
const revokeGrantSchema = z.object({
@@ -105,7 +106,8 @@ export const CodeSigningGrantsTab = () => {
const { data: grants = [], isPending: isGrantsLoading } = useQuery(
approvalGrantQuery.list({
policyType: ApprovalPolicyType.CertCodeSigning,
- projectId
+ scope: ApprovalPolicyScope.Project,
+ id: projectId
})
);
@@ -210,13 +212,23 @@ export const CodeSigningGrantsTab = () => {
const isTableFiltered = filter !== ApprovalGrantStatus.Active;
return (
- <Card className="mb-6">
+ <Card>
<CardHeader>
<CardTitle>Signing Grants</CardTitle>
- <CardDescription>View and revoke signing access grants</CardDescription>
+ <CardDescription>View and revoke signing access grants.</CardDescription>
</CardHeader>
<CardContent>
<div className="mb-4 flex items-center gap-2">
+ <InputGroup className="flex-1">
+ <InputGroupAddon>
+ <SearchIcon />
+ </InputGroupAddon>
+ <InputGroupInput
+ value={search}
+ onChange={(e) => setSearch(e.target.value)}
+ placeholder="Search signing grants..."
+ />
+ </InputGroup>
<DropdownMenu>
<DropdownMenuTrigger asChild>
<IconButton
@@ -225,77 +237,57 @@ export const CodeSigningGrantsTab = () => {
size="md"
className={twMerge(isTableFiltered && "text-primary")}
>
- <FontAwesomeIcon icon={faFilter} />
+ <FilterIcon className="size-4" />
</IconButton>
</DropdownMenuTrigger>
- <DropdownMenuContent align="start" className="p-0">
+ <DropdownMenuContent align="end">
<DropdownMenuLabel>Filter By</DropdownMenuLabel>
<DropdownMenuItem
onClick={(evt) => {
evt.preventDefault();
setFilter(ApprovalGrantStatus.Active);
}}
- icon={
- filter === ApprovalGrantStatus.Active && <FontAwesomeIcon icon={faCheckCircle} />
- }
- iconPos="right"
>
Active Grants
+ {filter === ApprovalGrantStatus.Active && (
+ <CircleCheckIcon className="ml-auto size-4" />
+ )}
</DropdownMenuItem>
- <DropdownSubMenu>
- <DropdownSubMenuTrigger
- iconPos="right"
- icon={<FontAwesomeIcon icon={faChevronRight} size="sm" />}
- >
+ <DropdownMenuSub>
+ <DropdownMenuSubTrigger>
Inactive Grants
- </DropdownSubMenuTrigger>
- <DropdownSubMenuContent className="max-h-80 thin-scrollbar overflow-y-auto rounded-l-none">
- <DropdownMenuLabel className="sticky top-0 bg-mineshaft-900">
- Filter by Status
- </DropdownMenuLabel>
+ <ChevronRightIcon className="ml-auto size-4" />
+ </DropdownMenuSubTrigger>
+ <DropdownMenuSubContent>
+ <DropdownMenuLabel>Filter by Status</DropdownMenuLabel>
<DropdownMenuItem
onClick={(evt) => {
evt.preventDefault();
setFilter(ApprovalGrantStatus.Expired);
}}
- icon={
- filter === ApprovalGrantStatus.Expired && (
- <FontAwesomeIcon icon={faCheckCircle} />
- )
- }
- iconPos="right"
>
Expired
+ {filter === ApprovalGrantStatus.Expired && (
+ <CircleCheckIcon className="ml-auto size-4" />
+ )}
</DropdownMenuItem>
<DropdownMenuItem
onClick={(evt) => {
evt.preventDefault();
setFilter(ApprovalGrantStatus.Revoked);
}}
- icon={
- filter === ApprovalGrantStatus.Revoked && (
- <FontAwesomeIcon icon={faCheckCircle} />
- )
- }
- iconPos="right"
>
Revoked
+ {filter === ApprovalGrantStatus.Revoked && (
+ <CircleCheckIcon className="ml-auto size-4" />
+ )}
</DropdownMenuItem>
- </DropdownSubMenuContent>
- </DropdownSubMenu>
+ </DropdownMenuSubContent>
+ </DropdownMenuSub>
</DropdownMenuContent>
</DropdownMenu>
- <InputGroup className="flex-1">
- <InputGroupAddon>
- <SearchIcon />
- </InputGroupAddon>
- <InputGroupInput
- value={search}
- onChange={(e) => setSearch(e.target.value)}
- placeholder="Search signing grants..."
- />
- </InputGroup>
</div>
+
<Table>
<TableHeader>
<TableRow>
@@ -309,10 +301,10 @@ export const CodeSigningGrantsTab = () => {
</TableHeader>
<TableBody>
{isGrantsLoading &&
- Array.from({ length: 5 }).map((_, i) => (
- <TableRow key={`grant-skeleton-${i + 1}`}>
+ Array.from({ length: 6 }).map((_, i) => (
+ <TableRow key={`cs-grant-skeleton-${i + 1}`}>
{Array.from({ length: 6 }).map((__, j) => (
- <TableCell key={`grant-skeleton-cell-${j + 1}`}>
+ <TableCell key={`cs-grant-skeleton-cell-${j + 1}`}>
<Skeleton className="h-4 w-full" />
</TableCell>
))}
@@ -325,73 +317,52 @@ export const CodeSigningGrantsTab = () => {
return (
<TableRow key={grant.id} className="group">
- <TableCell>{getGranteeName(grant)}</TableCell>
- <TableCell>
- <span className="text-sm text-mineshaft-200">{attrs.signerName || "-"}</span>
- </TableCell>
+ <TableCell isTruncatable>{getGranteeName(grant)}</TableCell>
+ <TableCell isTruncatable>{attrs.signerName || "-"}</TableCell>
<TableCell>
- <Badge
- variant={
- isActive
- ? getStatusBadgeColor(ApprovalGrantStatus.Active)
- : getStatusBadgeColor(grant.status)
- }
- className="capitalize"
- >
+ <Badge variant={getStatusBadgeColor(grant.status)} className="capitalize">
{isActive ? "Active" : grant.status}
</Badge>
</TableCell>
- <TableCell>
- <span className="text-sm text-mineshaft-400">
- {format(new Date(grant.createdAt), "MMM d, yyyy")}
- </span>
+ <TableCell className="whitespace-nowrap text-accent">
+ {format(new Date(grant.createdAt), "MMM d, yyyy")}
</TableCell>
- <TableCell>
- {grant.expiresAt ? (
- <span className="text-sm text-mineshaft-400">
- {format(new Date(grant.expiresAt), "MMM d, yyyy")}
- </span>
- ) : (
- <span className="text-sm text-mineshaft-500">Never</span>
- )}
+ <TableCell className="whitespace-nowrap text-accent">
+ {grant.expiresAt ? format(new Date(grant.expiresAt), "MMM d, yyyy") : "Never"}
</TableCell>
- <TableCell
- onClick={(e) => {
- e.stopPropagation();
- }}
- >
+ <TableCell onClick={(e) => e.stopPropagation()}>
{isActive && (
<DropdownMenu>
<DropdownMenuTrigger asChild>
- <IconButton variant="ghost" size="xs" aria-label="More options">
+ <IconButton variant="ghost" size="xs" aria-label="Grant actions">
<MoreHorizontalIcon />
</IconButton>
</DropdownMenuTrigger>
- <DropdownMenuContent align="end" className="p-1" sideOffset={5}>
+ <DropdownMenuContent align="end" className="min-w-40" sideOffset={2}>
{grant.requestId && (
- <Link
- to="/organizations/$orgId/projects/cert-manager/$projectId/approvals/$approvalRequestId"
- params={{
- orgId: currentOrg.id,
- projectId: currentProject.id,
- approvalRequestId: grant.requestId
- }}
- search={{
- policyType: ApprovalPolicyType.CertCodeSigning
- }}
- >
- <DropdownMenuItem icon={<FontAwesomeIcon icon={faInfo} />}>
+ <DropdownMenuItem asChild>
+ <Link
+ to="/organizations/$orgId/projects/cert-manager/$projectId/approvals/$approvalRequestId"
+ params={{
+ orgId: currentOrg.id,
+ projectId: currentProject.id,
+ approvalRequestId: grant.requestId
+ }}
+ search={{ policyType: ApprovalPolicyType.CertCodeSigning }}
+ >
+ <InfoIcon />
Request Details
- </DropdownMenuItem>
- </Link>
+ </Link>
+ </DropdownMenuItem>
)}
<DropdownMenuItem
+ variant="danger"
onClick={(e) => {
e.stopPropagation();
openRevokeModal(grant.id);
}}
- icon={<FontAwesomeIcon icon={faXmark} />}
>
+ <XIcon />
Revoke Grant
</DropdownMenuItem>
</DropdownMenuContent>
@@ -401,28 +372,24 @@ export const CodeSigningGrantsTab = () => {
</TableRow>
);
})}
- {!isGrantsLoading && !filteredGrants?.length && (
- <TableRow>
- <td colSpan={6} className="p-0">
- <Empty className="border-none">
- <EmptyHeader>
- <EmptyTitle>
- {grants.length
- ? "No signing grants match search..."
- : "No signing grants found"}
- </EmptyTitle>
- <EmptyDescription>
- {grants.length
- ? "Try adjusting your search or filters"
- : "Grants will appear here when users are granted signing access"}
- </EmptyDescription>
- </EmptyHeader>
- </Empty>
- </td>
- </TableRow>
- )}
</TableBody>
</Table>
+
+ {!isGrantsLoading && !filteredGrants.length && (
+ <Empty className="border">
+ <EmptyHeader>
+ <EmptyTitle>
+ {grants.length ? "No signing grants match search" : "No signing grants yet"}
+ </EmptyTitle>
+ <EmptyDescription>
+ {grants.length
+ ? "Try clearing your filters or search."
+ : "Approved signing requests will appear here as active grants."}
+ </EmptyDescription>
+ </EmptyHeader>
+ </Empty>
+ )}
+
{Boolean(filteredGrants.length) && (
<Pagination
count={filteredGrants.length}
@@ -434,11 +401,14 @@ export const CodeSigningGrantsTab = () => {
)}
</CardContent>
- <Modal isOpen={revokeModalOpen} onOpenChange={(open) => !open && closeRevokeModal()}>
- <ModalContent
- title="Revoke Signing Grant"
- subTitle="Are you sure you want to revoke this signing grant? This action cannot be undone."
- >
+ <Dialog open={revokeModalOpen} onOpenChange={(open) => !open && closeRevokeModal()}>
+ <DialogContent className="max-w-lg">
+ <DialogHeader className="gap-3">
+ <DialogTitle>Revoke Signing Grant</DialogTitle>
+ <DialogDescription>
+ Are you sure you want to revoke this signing grant? This action cannot be undone.
+ </DialogDescription>
+ </DialogHeader>
<form onSubmit={handleSubmit(handleRevokeGrant)}>
<FormControl
label="Revocation Reason (Optional)"
@@ -451,22 +421,17 @@ export const CodeSigningGrantsTab = () => {
rows={4}
/>
</FormControl>
- <div className="mt-6 flex items-center space-x-4">
- <Button
- colorSchema="danger"
- type="submit"
- isLoading={isRevoking}
- isDisabled={isRevoking}
- >
- Revoke Grant
- </Button>
- <Button variant="outline_bg" onClick={closeRevokeModal} isDisabled={isRevoking}>
+ <DialogFooter>
+ <Button variant="outline" onClick={closeRevokeModal} isDisabled={isRevoking}>
Cancel
</Button>
- </div>
+ <Button variant="danger" type="submit" isPending={isRevoking} isDisabled={isRevoking}>
+ Revoke Grant
+ </Button>
+ </DialogFooter>
</form>
- </ModalContent>
- </Modal>
+ </DialogContent>
+ </Dialog>
</Card>
);
};
diff --git a/frontend/src/pages/cert-manager/ApprovalsPage/components/CodeSigningPolicyTab/CodeSigningPolicyTab.tsx b/frontend/src/pages/cert-manager/ApprovalsPage/components/CodeSigningPolicyTab/CodeSigningPolicyTab.tsx
index cec3cd9ada..4ca9bf4438 100644
--- a/frontend/src/pages/cert-manager/ApprovalsPage/components/CodeSigningPolicyTab/CodeSigningPolicyTab.tsx
+++ b/frontend/src/pages/cert-manager/ApprovalsPage/components/CodeSigningPolicyTab/CodeSigningPolicyTab.tsx
@@ -56,14 +56,14 @@ export const CodeSigningPolicyTab = () => {
};
return (
- <Card className="mb-6">
+ <Card>
<CardHeader>
<CardTitle>Signing Policies</CardTitle>
<CardDescription>
- Define policies that require approval before signing operations
+ Define policies that require approval before signing operations.
</CardDescription>
<CardAction>
- <Button variant="outline" onClick={() => handlePopUpOpen("policy")}>
+ <Button variant="project" onClick={() => handlePopUpOpen("policy")}>
<PlusIcon />
Create Policy
</Button>
diff --git a/frontend/src/pages/cert-manager/ApprovalsPage/components/CodeSigningPolicyTab/components/CodeSigningPoliciesTable.tsx b/frontend/src/pages/cert-manager/ApprovalsPage/components/CodeSigningPolicyTab/components/CodeSigningPoliciesTable.tsx
index 80ad7b1f9c..5636d5ca47 100644
--- a/frontend/src/pages/cert-manager/ApprovalsPage/components/CodeSigningPolicyTab/components/CodeSigningPoliciesTable.tsx
+++ b/frontend/src/pages/cert-manager/ApprovalsPage/components/CodeSigningPolicyTab/components/CodeSigningPoliciesTable.tsx
@@ -56,83 +56,77 @@ export const CodeSigningPoliciesTable = ({ handlePopUpOpen }: Props) => {
}, [policies]);
return (
- <Table>
- <TableHeader>
- <TableRow>
- <TableHead>Policy Name</TableHead>
- <TableHead>Approval Steps</TableHead>
- <TableHead>Created</TableHead>
- <TableHead className="w-5" />
- </TableRow>
- </TableHeader>
- <TableBody>
- {isPoliciesLoading &&
- Array.from({ length: 3 }).map((_, i) => (
- <TableRow key={`policy-skeleton-${i + 1}`}>
- {Array.from({ length: 4 }).map((__, j) => (
- <TableCell key={`policy-skeleton-cell-${j + 1}`}>
- <Skeleton className="h-4 w-full" />
+ <>
+ <Table>
+ <TableHeader>
+ <TableRow>
+ <TableHead>Policy Name</TableHead>
+ <TableHead>Approval Steps</TableHead>
+ <TableHead>Created</TableHead>
+ <TableHead className="w-5" />
+ </TableRow>
+ </TableHeader>
+ <TableBody>
+ {isPoliciesLoading &&
+ Array.from({ length: 3 }).map((_, i) => (
+ <TableRow key={`cs-policy-skeleton-${i + 1}`}>
+ {Array.from({ length: 4 }).map((__, j) => (
+ <TableCell key={`cs-policy-skeleton-cell-${j + 1}`}>
+ <Skeleton className="h-4 w-full" />
+ </TableCell>
+ ))}
+ </TableRow>
+ ))}
+ {!isPoliciesLoading &&
+ sortedPolicies.map((policy) => (
+ <TableRow key={policy.id} className="group">
+ <TableCell isTruncatable>
+ <span className="font-medium text-foreground">{policy.name}</span>
</TableCell>
- ))}
- </TableRow>
- ))}
- {!isPoliciesLoading &&
- sortedPolicies.map((policy) => (
- <TableRow key={policy.id} className="group">
- <TableCell>
- <div className="text-sm font-medium text-foreground">{policy.name}</div>
- </TableCell>
- <TableCell>
- <span className="text-sm text-accent">
+ <TableCell className="text-accent">
{policy.steps.length} step{policy.steps.length !== 1 ? "s" : ""}
- </span>
- </TableCell>
- <TableCell>
- <span className="text-sm text-accent">
+ </TableCell>
+ <TableCell className="whitespace-nowrap text-accent">
{format(new Date(policy.createdAt), "MMM d, yyyy")}
- </span>
- </TableCell>
- <TableCell>
- <DropdownMenu>
- <DropdownMenuTrigger asChild>
- <IconButton variant="ghost" size="xs" aria-label="More options">
- <MoreHorizontalIcon />
- </IconButton>
- </DropdownMenuTrigger>
- <DropdownMenuContent align="end" sideOffset={2}>
- <DropdownMenuItem
- onClick={() => handlePopUpOpen("policy", { policyId: policy.id, policy })}
- >
- <PencilIcon />
- Edit Policy
- </DropdownMenuItem>
- <DropdownMenuItem
- variant="danger"
- onClick={() => handlePopUpOpen("deletePolicy", { policyId: policy.id })}
- >
- <Trash2Icon />
- Delete Policy
- </DropdownMenuItem>
- </DropdownMenuContent>
- </DropdownMenu>
- </TableCell>
- </TableRow>
- ))}
- {!isPoliciesLoading && !sortedPolicies.length && (
- <TableRow>
- <td colSpan={4} className="p-0">
- <Empty className="border-none">
- <EmptyHeader>
- <EmptyTitle>No signing policies found</EmptyTitle>
- <EmptyDescription>
- Create a policy to require approval before signing operations
- </EmptyDescription>
- </EmptyHeader>
- </Empty>
- </td>
- </TableRow>
- )}
- </TableBody>
- </Table>
+ </TableCell>
+ <TableCell>
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <IconButton variant="ghost" size="xs" aria-label="Policy actions">
+ <MoreHorizontalIcon />
+ </IconButton>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent className="min-w-40" align="end" sideOffset={2}>
+ <DropdownMenuItem
+ onClick={() => handlePopUpOpen("policy", { policyId: policy.id, policy })}
+ >
+ <PencilIcon />
+ Edit Policy
+ </DropdownMenuItem>
+ <DropdownMenuItem
+ variant="danger"
+ onClick={() => handlePopUpOpen("deletePolicy", { policyId: policy.id })}
+ >
+ <Trash2Icon />
+ Delete Policy
+ </DropdownMenuItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ </TableCell>
+ </TableRow>
+ ))}
+ </TableBody>
+ </Table>
+ {!isPoliciesLoading && !sortedPolicies.length && (
+ <Empty className="border">
+ <EmptyHeader>
+ <EmptyTitle>No signing policies yet</EmptyTitle>
+ <EmptyDescription>
+ Create a policy to require approval before signing operations.
+ </EmptyDescription>
+ </EmptyHeader>
+ </Empty>
+ )}
+ </>
);
};
diff --git a/frontend/src/pages/cert-manager/ApprovalsPage/components/CodeSigningRequestsTab/RequestSigningAccessModal.tsx b/frontend/src/pages/cert-manager/ApprovalsPage/components/CodeSigningRequestsTab/RequestSigningAccessModal.tsx
index 8320977c50..1946942559 100644
--- a/frontend/src/pages/cert-manager/ApprovalsPage/components/CodeSigningRequestsTab/RequestSigningAccessModal.tsx
+++ b/frontend/src/pages/cert-manager/ApprovalsPage/components/CodeSigningRequestsTab/RequestSigningAccessModal.tsx
@@ -24,11 +24,12 @@ import {
TApprovalPolicy
} from "@app/hooks/api/approvalPolicies";
import { useCreateApprovalRequest } from "@app/hooks/api/approvalRequests/mutations";
-import { useListSigners } from "@app/hooks/api/signers";
+import { TSigner, useListSigners } from "@app/hooks/api/signers";
type Props = {
isOpen: boolean;
onOpenChange: (isOpen: boolean) => void;
+ signer?: TSigner;
};
const toDatetimeLocalValue = (date: Date): string => {
@@ -80,15 +81,12 @@ const formSchema = z
type FormData = z.infer<typeof formSchema>;
-const Content = ({ onOpenChange }: Props) => {
+const Content = ({ onOpenChange, signer: presetSigner }: Props) => {
const { projectId } = useProject();
const { mutateAsync: createApprovalRequest, isPending: isSubmitting } =
useCreateApprovalRequest();
- const { data: signersData } = useListSigners({
- projectId,
- limit: 100
- });
+ const { data: signersData } = useListSigners({ projectId, limit: 100 });
const { data: policies = [] } = useQuery(
approvalPolicyQuery.list({
@@ -115,7 +113,7 @@ const Content = ({ onOpenChange }: Props) => {
resolver: zodResolver(formSchema),
mode: "onChange",
defaultValues: {
- signerId: "",
+ signerId: presetSigner?.id ?? "",
justification: "",
windowStart: getDefaultWindowStart(),
windowEnd: getDefaultWindowEnd(),
@@ -135,8 +133,8 @@ const Content = ({ onOpenChange }: Props) => {
const selectedSignerId = watch("signerId");
const selectedSigner = useMemo(
- () => signers.find((s) => s.id === selectedSignerId),
- [signers, selectedSignerId]
+ () => presetSigner ?? signers.find((s) => s.id === selectedSignerId),
+ [presetSigner, signers, selectedSignerId]
);
const selectedPolicy = useMemo(
@@ -211,32 +209,45 @@ const Content = ({ onOpenChange }: Props) => {
return (
<form onSubmit={handleSubmit(onSubmit)}>
- <Controller
- name="signerId"
- control={control}
- render={({ field, fieldState: { error } }) => (
- <FormControl
- label="Signer"
- errorText={error?.message}
- isError={Boolean(error?.message)}
- helperText="Select the signer you want to request signing access for"
- >
- <Select
- value={field.value}
- onValueChange={field.onChange}
- placeholder="Select a signer..."
- className="w-full"
+ {presetSigner ? (
+ <FormControl label="Signer">
+ <Input
+ value={
+ presetSigner.certificateCommonName
+ ? `${presetSigner.name} (${presetSigner.certificateCommonName})`
+ : presetSigner.name
+ }
+ isReadOnly
+ />
+ </FormControl>
+ ) : (
+ <Controller
+ name="signerId"
+ control={control}
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Signer"
+ errorText={error?.message}
+ isError={Boolean(error?.message)}
+ helperText="Select the signer you want to request signing access for"
>
- {signers.map((signer) => (
- <SelectItem key={signer.id} value={signer.id}>
- {signer.name}
- {signer.certificateCommonName ? ` (${signer.certificateCommonName})` : ""}
- </SelectItem>
- ))}
- </Select>
- </FormControl>
- )}
- />
+ <Select
+ value={field.value}
+ onValueChange={field.onChange}
+ placeholder="Select a signer..."
+ className="w-full"
+ >
+ {signers.map((signer) => (
+ <SelectItem key={signer.id} value={signer.id}>
+ {signer.name}
+ {signer.certificateCommonName ? ` (${signer.certificateCommonName})` : ""}
+ </SelectItem>
+ ))}
+ </Select>
+ </FormControl>
+ )}
+ />
+ )}
{hasTimeConstraint && (
<div className="grid grid-cols-2 gap-4">
<Controller
@@ -324,7 +335,7 @@ const Content = ({ onOpenChange }: Props) => {
};
export const RequestSigningAccessModal = (props: Props) => {
- const { isOpen, onOpenChange } = props;
+ const { isOpen, onOpenChange, signer } = props;
return (
<Modal isOpen={isOpen} onOpenChange={onOpenChange}>
@@ -332,6 +343,7 @@ export const RequestSigningAccessModal = (props: Props) => {
className="max-w-2xl pb-2"
title="Request Signing Access"
subTitle="Request approval to sign with a code signing key"
+ key={signer?.id ?? "no-preset"}
>
<Content {...props} />
</ModalContent>
diff --git a/frontend/src/pages/cert-manager/CodeSigningPage/components/SignersTable.tsx b/frontend/src/pages/cert-manager/CodeSigningPage/components/SignersTable.tsx
index 032b825d62..5712fc46e9 100644
--- a/frontend/src/pages/cert-manager/CodeSigningPage/components/SignersTable.tsx
+++ b/frontend/src/pages/cert-manager/CodeSigningPage/components/SignersTable.tsx
@@ -5,6 +5,7 @@ import {
BanIcon,
CheckCircleIcon,
ClipboardCopyIcon,
+ KeyRoundIcon,
MoreHorizontalIcon,
PencilIcon,
PlusIcon,
@@ -58,6 +59,7 @@ import {
} from "@app/hooks/api/signers";
import { useDebounce } from "@app/hooks/useDebounce";
+import { RequestSigningAccessModal } from "../../ApprovalsPage/components/CodeSigningRequestsTab/RequestSigningAccessModal";
import { EditSignerModal } from "../../SignerDetailPage/components/EditSignerModal";
type Props = {
@@ -76,6 +78,7 @@ export const SignersTable = ({ projectId, onCreateSigner }: Props) => {
const [debouncedSearch] = useDebounce(search, 300);
const [deleteSignerId, setDeleteSignerId] = useState<string | null>(null);
const [editSigner, setEditSigner] = useState<TSigner | null>(null);
+ const [requestAccessSigner, setRequestAccessSigner] = useState<TSigner | null>(null);
const { data, isLoading } = useListSigners({
projectId,
@@ -199,6 +202,17 @@ export const SignersTable = ({ projectId, onCreateSigner }: Props) => {
<ClipboardCopyIcon />
Copy ID
</DropdownMenuItem>
+ {signer.approvalPolicyId ? (
+ <DropdownMenuItem
+ onClick={(e) => {
+ e.stopPropagation();
+ setRequestAccessSigner(signer);
+ }}
+ >
+ <KeyRoundIcon />
+ Request Signing Access
+ </DropdownMenuItem>
+ ) : null}
<ProjectPermissionCan
I={ProjectPermissionCodeSigningActions.Edit}
a={ProjectPermissionSub.CodeSigners}
@@ -302,6 +316,13 @@ export const SignersTable = ({ projectId, onCreateSigner }: Props) => {
projectId={projectId}
/>
)}
+ <RequestSigningAccessModal
+ isOpen={Boolean(requestAccessSigner)}
+ onOpenChange={(open) => {
+ if (!open) setRequestAccessSigner(null);
+ }}
+ signer={requestAccessSigner ?? undefined}
+ />
</>
);
};
diff --git a/frontend/src/pages/pam/ApprovalsPage/components/RequestGrantTab/RequestGrantTab.tsx b/frontend/src/pages/pam/ApprovalsPage/components/RequestGrantTab/RequestGrantTab.tsx
index 8abd7f6efc..58e4347e2b 100644
--- a/frontend/src/pages/pam/ApprovalsPage/components/RequestGrantTab/RequestGrantTab.tsx
+++ b/frontend/src/pages/pam/ApprovalsPage/components/RequestGrantTab/RequestGrantTab.tsx
@@ -60,7 +60,7 @@ import {
PamAccessGrantAttributes,
useRevokeApprovalGrant
} from "@app/hooks/api/approvalGrants";
-import { ApprovalPolicyType } from "@app/hooks/api/approvalPolicies";
+import { ApprovalPolicyScope, ApprovalPolicyType } from "@app/hooks/api/approvalPolicies";
const revokeGrantSchema = z.object({
revocationReason: z.string().max(256).optional()
@@ -94,7 +94,8 @@ export const RequestGrantTab = () => {
const { data: grants = [], isPending: isGrantsLoading } = useQuery(
approvalGrantQuery.list({
policyType: ApprovalPolicyType.PamAccess,
- projectId
+ scope: ApprovalPolicyScope.Project,
+ id: projectId
})
);