Skip to content

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

fix: pki ux patches

Sheen Capadngan3e947c3d96d1
diff --git a/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/CertificateAuthoritiesPage.tsx b/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/CertificateAuthoritiesPage.tsx
index 129d562e51..e10e3e31fc 100644
--- a/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/CertificateAuthoritiesPage.tsx
+++ b/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/CertificateAuthoritiesPage.tsx
@@ -1,16 +1,48 @@
import { Helmet } from "react-helmet";
import { useTranslation } from "react-i18next";
+import { useNavigate, useSearch } from "@tanstack/react-router";
import { ProjectPermissionCan } from "@app/components/permissions";
import { PageHeader } from "@app/components/v2";
-import { ProjectPermissionActions, ProjectPermissionSub } from "@app/context";
+import { Tabs, TabsContent, TabsList, TabsTrigger } from "@app/components/v3";
+import {
+ ProjectPermissionActions,
+ ProjectPermissionSub,
+ useOrganization,
+ useProject
+} from "@app/context";
import { ProjectType } from "@app/hooks/api/projects/types";
import { ExternalCaSection } from "./components/ExternalCaSection";
import { CaSection } from "./components";
+export enum CertificateAuthorityTab {
+ Internal = "internal",
+ External = "external"
+}
+
export const CertificateAuthoritiesPage = () => {
const { t } = useTranslation();
+ const navigate = useNavigate();
+ const { currentOrg } = useOrganization();
+ const { currentProject } = useProject();
+
+ const selectedTab = useSearch({
+ strict: false,
+ select: (search) => search.selectedTab
+ });
+
+ const updateSelectedTab = (tab: CertificateAuthorityTab) => {
+ navigate({
+ to: "/organizations/$orgId/projects/cert-manager/$projectId/certificate-authorities",
+ params: {
+ orgId: currentOrg.id,
+ projectId: currentProject.id
+ },
+ search: (prev) => ({ ...prev, selectedTab: tab })
+ });
+ };
+
return (
<div className="mx-auto flex h-full flex-col justify-between text-white">
<Helmet>
@@ -18,17 +50,31 @@ export const CertificateAuthoritiesPage = () => {
</Helmet>
<div className="mx-auto mb-6 w-full max-w-8xl">
<PageHeader
+ className="mb-6"
scope={ProjectType.CertificateManager}
title="Certificate Authorities"
- description="Define the trust anchors that sign certificates in this project — internal CAs you operate, plus external CAs you connect to."
+ description="Define the trust anchors that sign your certificates: internal CAs you operate, plus external CAs you connect to."
/>
<ProjectPermissionCan
renderGuardBanner
I={ProjectPermissionActions.Read}
a={ProjectPermissionSub.CertificateAuthorities}
>
- <CaSection />
- <ExternalCaSection />
+ <Tabs
+ value={selectedTab ?? CertificateAuthorityTab.Internal}
+ onValueChange={(tab) => updateSelectedTab(tab as CertificateAuthorityTab)}
+ >
+ <TabsList variant="project" aria-label="Certificate authority sections">
+ <TabsTrigger value={CertificateAuthorityTab.Internal}>Internal</TabsTrigger>
+ <TabsTrigger value={CertificateAuthorityTab.External}>External</TabsTrigger>
+ </TabsList>
+ <TabsContent value={CertificateAuthorityTab.Internal}>
+ <CaSection />
+ </TabsContent>
+ <TabsContent value={CertificateAuthorityTab.External}>
+ <ExternalCaSection />
+ </TabsContent>
+ </Tabs>
</ProjectPermissionCan>
</div>
</div>
diff --git a/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/CaSection.tsx b/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/CaSection.tsx
index c42b5d1f15..08d673abc9 100644
--- a/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/CaSection.tsx
+++ b/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/CaSection.tsx
@@ -82,7 +82,7 @@ export const CaSection = () => {
};
return (
- <Card className="mb-6">
+ <Card>
<CardHeader>
<CardTitle>
Internal Certificate Authorities
diff --git a/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/ExternalCaSection.tsx b/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/ExternalCaSection.tsx
index f3f5a166a6..e987d511c7 100644
--- a/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/ExternalCaSection.tsx
+++ b/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/components/ExternalCaSection.tsx
@@ -71,7 +71,7 @@ export const ExternalCaSection = () => {
};
return (
- <Card className="mb-6">
+ <Card>
<CardHeader>
<CardTitle>
External Certificate Authorities
diff --git a/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/route.tsx b/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/route.tsx
index 1e17db0b09..d7526131f4 100644
--- a/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/route.tsx
+++ b/frontend/src/pages/cert-manager/CertificateAuthoritiesPage/route.tsx
@@ -1,11 +1,21 @@
-import { createFileRoute } from "@tanstack/react-router";
+import { createFileRoute, stripSearchParams } from "@tanstack/react-router";
+import { zodValidator } from "@tanstack/zod-adapter";
+import { z } from "zod";
-import { CertificateAuthoritiesPage } from "./CertificateAuthoritiesPage";
+import { CertificateAuthoritiesPage, CertificateAuthorityTab } from "./CertificateAuthoritiesPage";
+
+const CertificateAuthoritiesSearchSchema = z.object({
+ selectedTab: z.nativeEnum(CertificateAuthorityTab).catch(CertificateAuthorityTab.Internal)
+});
export const Route = createFileRoute(
"/_authenticate/_inject-org-details/_org-layout/organizations/$orgId/projects/cert-manager/$projectId/_cert-manager-layout/certificate-authorities"
)({
component: CertificateAuthoritiesPage,
+ validateSearch: zodValidator(CertificateAuthoritiesSearchSchema),
+ search: {
+ middlewares: [stripSearchParams({ selectedTab: CertificateAuthorityTab.Internal })]
+ },
beforeLoad: ({ context }) => {
return {
breadcrumbs: [
diff --git a/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateIssuanceModal.tsx b/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateIssuanceModal.tsx
index cd1db176a8..8314b2d7e7 100644
--- a/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateIssuanceModal.tsx
+++ b/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateIssuanceModal.tsx
@@ -45,6 +45,7 @@ import {
import { AlgorithmSelectors } from "./AlgorithmSelectors";
import { BasicConstraintsField } from "./BasicConstraintsField";
import { buildManagedRequest } from "./buildManagedRequest";
+import { mergeRowErrors } from "./certificatePolicyGuidance";
import {
detectSanTypeFromValue,
EXTERNAL_CA_TEMPLATE_HINT,
@@ -53,9 +54,11 @@ import {
} from "./certificateUtils";
import { CertificateWizardSheet, useWizardSteps, WizardStep } from "./CertificateWizardSheet";
import { KeyUsageSection } from "./KeyUsageSection";
+import { PolicyRequirementsAlert } from "./PolicyRequirementsAlert";
import { SubjectAltNamesField } from "./SubjectAltNamesField";
import { SubjectAttributesField } from "./SubjectAttributesField";
import { useCertificatePolicy } from "./useCertificatePolicy";
+import { useSubjectPolicyGuidance } from "./useSubjectPolicyGuidance";
enum RequestMethod {
MANAGED = "managed",
@@ -382,6 +385,18 @@ export const CertificateIssuanceModal = ({
watch
);
+ const policyGuidance = useSubjectPolicyGuidance({
+ policy: policyData,
+ watch,
+ setValue,
+ isSubjectSectionShown: constraints.shouldShowSubjectSection,
+ isSanSectionShown: constraints.shouldShowSanSection,
+ isEnabled: requestMethod === RequestMethod.MANAGED
+ });
+
+ const hasPolicyIssuesRef = useRef(false);
+ hasPolicyIssuesRef.current = policyGuidance.hasBlockingIssues;
+
const resetAllState = useCallback(() => {
resetConstraints();
reset();
@@ -405,7 +420,12 @@ export const CertificateIssuanceModal = ({
stepKeys,
stepFields: STEP_FIELDS,
invalidMessage: "Please fix the highlighted fields before requesting.",
- validateStep: (fields) => trigger(fields as (keyof FormData)[])
+ validateStep: async (fields) => {
+ const isValid = await trigger(fields as (keyof FormData)[]);
+ if (!isValid) return false;
+ // The subject step is where policy violations can be fixed, so don't let them reach issuance.
+ return !fields.includes("subjectAttributes") || !hasPolicyIssuesRef.current;
+ }
});
const steps = useMemo(() => stepKeys.map((key) => STEP_META[key]), [stepKeys]);
@@ -470,6 +490,16 @@ export const CertificateIssuanceModal = ({
return;
}
+ if (formData.requestMethod === RequestMethod.MANAGED && hasPolicyIssuesRef.current) {
+ const subjectStepIndex = stepKeys.indexOf("subject");
+ if (subjectStepIndex >= 0) setStep(subjectStepIndex);
+ createNotification({
+ text: "Resolve the policy violations on the Subject step before requesting.",
+ type: "error"
+ });
+ return;
+ }
+
const handleIssuanceResponse = (response: Awaited<ReturnType<typeof issueCertificate>>) => {
if ("certificate" in response && response.certificate) {
createNotification({ text: "Successfully created certificate", type: "success" });
@@ -550,7 +580,9 @@ export const CertificateIssuanceModal = ({
isAdcsProfile,
handlePopUpToggle,
navigate,
- resetAllState
+ resetAllState,
+ stepKeys,
+ setStep
]
);
@@ -721,6 +753,13 @@ export const CertificateIssuanceModal = ({
/>
)}
+ {currentStepKey === "subject" && (
+ <PolicyRequirementsAlert
+ requirements={policyGuidance.requirements}
+ onAddMissing={policyGuidance.addMissingFields}
+ />
+ )}
+
{currentStepKey === "subject" && constraints.shouldShowSubjectSection && (
<SubjectAttributesField
control={control}
@@ -729,9 +768,14 @@ export const CertificateIssuanceModal = ({
(formState.errors as { subjectAttributes?: { message?: string } }).subjectAttributes
?.message
}
- rowErrors={rowErrorsOf(
- (formState.errors as { subjectAttributes?: unknown }).subjectAttributes
+ rowErrors={mergeRowErrors(
+ rowErrorsOf(
+ (formState.errors as { subjectAttributes?: unknown }).subjectAttributes
+ ),
+ policyGuidance.subjectRowErrors
)}
+ rowHints={policyGuidance.subjectRowHints}
+ notices={policyGuidance.subjectNotices}
/>
)}
@@ -743,9 +787,11 @@ export const CertificateIssuanceModal = ({
(formState.errors as { subjectAltNames?: { message?: string } }).subjectAltNames
?.message
}
- rowErrors={rowErrorsOf(
- (formState.errors as { subjectAltNames?: unknown }).subjectAltNames
+ rowErrors={mergeRowErrors(
+ rowErrorsOf((formState.errors as { subjectAltNames?: unknown }).subjectAltNames),
+ policyGuidance.sanRowErrors
)}
+ rowHints={policyGuidance.sanRowHints}
/>
)}
diff --git a/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateRenewalModal.tsx b/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateRenewalModal.tsx
index 9cce703ac3..4a228402ee 100644
--- a/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateRenewalModal.tsx
+++ b/frontend/src/pages/cert-manager/CertificatesPage/components/CertificateRenewalModal.tsx
@@ -42,6 +42,7 @@ import {
import { AlgorithmSelectors } from "./AlgorithmSelectors";
import { BasicConstraintsField } from "./BasicConstraintsField";
+import { mergeRowErrors } from "./certificatePolicyGuidance";
import {
buildRenewalFormDefaults,
buildRenewalRequestAttributes,
@@ -50,6 +51,7 @@ import {
import { isExternalTemplateCa, rowErrorsOf } from "./certificateUtils";
import { CertificateWizardSheet, useWizardSteps, WizardStep } from "./CertificateWizardSheet";
import { KeyUsageSection } from "./KeyUsageSection";
+import { PolicyRequirementsAlert } from "./PolicyRequirementsAlert";
import { SubjectAltNamesField } from "./SubjectAltNamesField";
import { SubjectAttributesField } from "./SubjectAttributesField";
import {
@@ -57,6 +59,7 @@ import {
deriveTemplateConstraints,
useCertificatePolicyOptions
} from "./useCertificatePolicy";
+import { useSubjectPolicyGuidance } from "./useSubjectPolicyGuidance";
const formSchema = z
.object({
@@ -370,11 +373,28 @@ export const CertificateRenewalModal = ({ popUp, applicationName, handlePopUpTog
return keys;
}, [keySource, constraints.shouldShowSubjectSection, constraints.shouldShowSanSection]);
+ const policyGuidance = useSubjectPolicyGuidance({
+ policy: policyData,
+ watch,
+ setValue,
+ isSubjectSectionShown: constraints.shouldShowSubjectSection,
+ isSanSectionShown: constraints.shouldShowSanSection,
+ isEnabled: keySource !== CertificateRenewalKeySource.Csr
+ });
+
+ const hasPolicyIssuesRef = useRef(false);
+ hasPolicyIssuesRef.current = policyGuidance.hasBlockingIssues;
+
const { step, setStep, currentStepKey, goBack, goNext, onFormInvalid } = useWizardSteps({
stepKeys,
stepFields: STEP_FIELDS,
invalidMessage: "Please fix the highlighted fields before renewing.",
- validateStep: (fields) => trigger(fields as (keyof RenewalFormData)[])
+ validateStep: async (fields) => {
+ const isValid = await trigger(fields as (keyof RenewalFormData)[]);
+ if (!isValid) return false;
+ // The subject step is where policy violations can be fixed, so don't let them reach renewal.
+ return !fields.includes("subjectAttributes") || !hasPolicyIssuesRef.current;
+ }
});
const steps = useMemo(
@@ -410,6 +430,16 @@ export const CertificateRenewalModal = ({ popUp, applicationName, handlePopUpTog
const onFormSubmit = async (formData: RenewalFormData) => {
if (!certificateId) return;
+ if (keySource !== CertificateRenewalKeySource.Csr && hasPolicyIssuesRef.current) {
+ const subjectStepIndex = stepKeys.indexOf("subject");
+ if (subjectStepIndex >= 0) setStep(subjectStepIndex);
+ createNotification({
+ text: "Resolve the policy violations on the Subject step before renewing.",
+ type: "error"
+ });
+ return;
+ }
+
const result = await renewCertificate({
certificateId,
renewalKeySource: formData.keySource,
@@ -572,6 +602,10 @@ export const CertificateRenewalModal = ({ popUp, applicationName, handlePopUpTog
{currentStepKey === "subject" && (
<div className="space-y-4">
+ <PolicyRequirementsAlert
+ requirements={policyGuidance.requirements}
+ onAddMissing={policyGuidance.addMissingFields}
+ />
{constraints.shouldShowSubjectSection && (
<SubjectAttributesField
control={control}
@@ -580,9 +614,14 @@ export const CertificateRenewalModal = ({ popUp, applicationName, handlePopUpTog
(formState.errors as { subjectAttributes?: { message?: string } }).subjectAttributes
?.message
}
- rowErrors={rowErrorsOf(
- (formState.errors as { subjectAttributes?: unknown }).subjectAttributes
+ rowErrors={mergeRowErrors(
+ rowErrorsOf(
+ (formState.errors as { subjectAttributes?: unknown }).subjectAttributes
+ ),
+ policyGuidance.subjectRowErrors
)}
+ rowHints={policyGuidance.subjectRowHints}
+ notices={policyGuidance.subjectNotices}
/>
)}
{constraints.shouldShowSanSection && (
@@ -593,9 +632,11 @@ export const CertificateRenewalModal = ({ popUp, applicationName, handlePopUpTog
(formState.errors as { subjectAltNames?: { message?: string } }).subjectAltNames
?.message
}
- rowErrors={rowErrorsOf(
- (formState.errors as { subjectAltNames?: unknown }).subjectAltNames
+ rowErrors={mergeRowErrors(
+ rowErrorsOf((formState.errors as { subjectAltNames?: unknown }).subjectAltNames),
+ policyGuidance.sanRowErrors
)}
+ rowHints={policyGuidance.sanRowHints}
/>
)}
</div>
diff --git a/frontend/src/pages/cert-manager/CertificatesPage/components/PolicyRequirementsAlert.tsx b/frontend/src/pages/cert-manager/CertificatesPage/components/PolicyRequirementsAlert.tsx
new file mode 100644
index 0000000000..4d1b5ccbbf
--- /dev/null
+++ b/frontend/src/pages/cert-manager/CertificatesPage/components/PolicyRequirementsAlert.tsx
@@ -0,0 +1,35 @@
+import { ListChecks, Plus } from "lucide-react";
+
+import { Alert, AlertDescription, AlertTitle, Button } from "@app/components/v3";
+
+import { PolicyRequirement } from "./certificatePolicyGuidance";
+
+type Props = {
+ requirements: PolicyRequirement[];
+ onAddMissing?: () => void;
+};
+
+export const PolicyRequirementsAlert = ({ requirements, onAddMissing }: Props) => {
+ if (requirements.length === 0) return null;
+
+ const canAddMissing = Boolean(onAddMissing) && requirements.some(({ addRows }) => addRows);
+
+ return (
+ <Alert variant="warning" className="mb-4">
+ <ListChecks />
+ <AlertTitle>Still required by this profile&apos;s policy</AlertTitle>
+ <AlertDescription>
+ <ul className="list-disc space-y-0.5 pl-4">
+ {requirements.map(({ id, message }) => (
+ <li key={id}>{message}</li>
+ ))}
+ </ul>
+ {canAddMissing && (
+ <Button type="button" variant="outline" size="xs" className="mt-2" onClick={onAddMissing}>
+ <Plus /> Add Missing Fields
+ </Button>
+ )}
+ </AlertDescription>
+ </Alert>
+ );
+};
diff --git a/frontend/src/pages/cert-manager/CertificatesPage/components/SubjectAltNamesField.tsx b/frontend/src/pages/cert-manager/CertificatesPage/components/SubjectAltNamesField.tsx
index 811a0a9dcd..7ec46524fa 100644
--- a/frontend/src/pages/cert-manager/CertificatesPage/components/SubjectAltNamesField.tsx
+++ b/frontend/src/pages/cert-manager/CertificatesPage/components/SubjectAltNamesField.tsx
@@ -4,6 +4,7 @@ import { Plus, Trash2 } from "lucide-react";
import {
Button,
Field,
+ FieldDescription,
FieldError,
FieldLabel,
IconButton,
@@ -23,6 +24,7 @@ type SubjectAltNamesFieldProps = {
allowedSanTypes: CertSubjectAlternativeNameType[];
error?: string;
rowErrors?: (string | undefined)[];
+ rowHints?: (string | undefined)[];
shouldUnregister?: boolean;
namePrefix?: string;
};
@@ -32,6 +34,7 @@ export const SubjectAltNamesField = ({
allowedSanTypes,
error,
rowErrors,
+ rowHints,
shouldUnregister,
namePrefix = "subjectAltNames"
}: SubjectAltNamesFieldProps) => {
@@ -47,7 +50,7 @@ export const SubjectAltNamesField = ({
return (
<Field className="mb-4">
<FieldLabel>Subject Alternative Names (SANs)</FieldLabel>
- <div className="space-y-2">
+ <div className="space-y-3">
{currentValues.map((san, index) => (
// eslint-disable-next-line react/no-array-index-key
<div key={`subject-alt-name-${index}`} className="flex items-start gap-2">
@@ -85,7 +88,12 @@ export const SubjectAltNamesField = ({
isError={Boolean(rowErrors?.[index])}
className="w-full"
/>
- {rowErrors?.[index] ? <FieldError>{rowErrors[index]}</FieldError> : null}
+ {rowErrors?.[index] ? (
+ <FieldError className="mt-1.5">{rowErrors[index]}</FieldError>
+ ) : null}
+ {!rowErrors?.[index] && rowHints?.[index] && (
+ <FieldDescription className="mt-1.5">{rowHints[index]}</FieldDescription>
+ )}
</div>
<IconButton
type="button"
diff --git a/frontend/src/pages/cert-manager/CertificatesPage/components/SubjectAttributesField.tsx b/frontend/src/pages/cert-manager/CertificatesPage/components/SubjectAttributesField.tsx
index 0755b2b7ce..2dae8457a4 100644
--- a/frontend/src/pages/cert-manager/CertificatesPage/components/SubjectAttributesField.tsx
+++ b/frontend/src/pages/cert-manager/CertificatesPage/components/SubjectAttributesField.tsx
@@ -4,6 +4,7 @@ import { Plus, Trash2 } from "lucide-react";
import {
Button,
Field,
+ FieldDescription,
FieldError,
FieldLabel,
IconButton,
@@ -16,20 +17,7 @@ import {
} from "@app/components/v3";
import { CertSubjectAttributeType } from "@app/pages/cert-manager/PoliciesPage/components/CertificatePoliciesTab/shared/certificate-constants";
-export type SubjectAttribute = {
- type: CertSubjectAttributeType;
- value: string;
-};
-
-const SUBJECT_ATTRIBUTE_LABELS: Record<CertSubjectAttributeType, string> = {
- [CertSubjectAttributeType.COMMON_NAME]: "Common Name",
- [CertSubjectAttributeType.ORGANIZATION]: "Organization",
- [CertSubjectAttributeType.ORGANIZATIONAL_UNIT]: "Organizational Unit",
- [CertSubjectAttributeType.COUNTRY]: "Country",
- [CertSubjectAttributeType.STATE]: "State/Province",
- [CertSubjectAttributeType.LOCALITY]: "Locality",
- [CertSubjectAttributeType.DOMAIN_COMPONENT]: "Domain Component"
-};
+import { SUBJECT_ATTRIBUTE_LABELS, SubjectAttribute } from "./certificateUtils";
const getSubjectAttributePlaceholder = (type: CertSubjectAttributeType): string => {
switch (type) {
@@ -58,6 +46,8 @@ type SubjectAttributesFieldProps = {
allowedAttributeTypes: CertSubjectAttributeType[];
error?: string;
rowErrors?: (string | undefined)[];
+ rowHints?: (string | undefined)[];
+ notices?: string[];
shouldUnregister?: boolean;
namePrefix?: string;
};
@@ -67,6 +57,8 @@ export const SubjectAttributesField = ({
allowedAttributeTypes,
error,
rowErrors,
+ rowHints,
+ notices,
shouldUnregister,
namePrefix = "subjectAttributes"
}: SubjectAttributesFieldProps) => {
@@ -89,7 +81,7 @@ export const SubjectAttributesField = ({
return (
<Field className="mb-4">
<FieldLabel>Subject Attributes</FieldLabel>
- <div className="space-y-2">
+ <div className="space-y-3">
{currentValues.map((attr, index) => {
const selectableTypes = allowedAttributeTypes.filter(
(type) => type === attr.type || isMultiValued(type) || !usedTypes.includes(type)
@@ -132,7 +124,10 @@ export const SubjectAttributesField = ({
isError={Boolean(rowErrors?.[index])}
className="w-full"
/>
- <FieldError>{rowErrors?.[index]}</FieldError>
+ <FieldError className="mt-1.5">{rowErrors?.[index]}</FieldError>
+ {!rowErrors?.[index] && rowHints?.[index] && (
+ <FieldDescription className="mt-1.5">{rowHints[index]}</FieldDescription>
+ )}
</div>
<IconButton
type="button"
@@ -159,6 +154,7 @@ export const SubjectAttributesField = ({
)}
</div>
<FieldError>{error}</FieldError>
+ {notices?.map((notice) => <FieldError key={notice}>{notice}</FieldError>)}
</Field>
);
}}
diff --git a/frontend/src/pages/cert-manager/CertificatesPage/components/certificatePolicyGuidance.ts b/frontend/src/pages/cert-manager/CertificatesPage/components/certificatePolicyGuidance.ts
new file mode 100644
index 0000000000..371ccdf8a7
--- /dev/null
+++ b/frontend/src/pages/cert-manager/CertificatesPage/components/certificatePolicyGuidance.ts
@@ -0,0 +1,490 @@
+import {
+ TCertificatePolicy,
+ TCertificatePolicyRule,
+ TSubjectRule
+} from "@app/hooks/api/certificatePolicies";
+import {
+ CertSubjectAlternativeNameType,
+ CertSubjectAttributeType,
+ formatSANType
+} from "@app/pages/cert-manager/PoliciesPage/components/CertificatePoliciesTab/shared/certificate-constants";
+
+import { SUBJECT_ATTRIBUTE_LABELS, SubjectAltName, SubjectAttribute } from "./certificateUtils";
+
+export type SanRule = NonNullable<TCertificatePolicyRule["sans"]>[number];
+
+type ValueRule = {
+ allowed?: string[];
+ required?: string[];
+ denied?: string[];
+};
+
+const MAX_LISTED_PATTERNS = 6;
+
+const formatPatterns = (patterns: string[]): string => {
+ const shown = patterns.slice(0, MAX_LISTED_PATTERNS);
+ const remaining = patterns.length - shown.length;
+ return remaining > 0 ? `${shown.join(", ")} (+${remaining} more)` : shown.join(", ");
+};
+
+// Messages end on the pattern list rather than a period, because a trailing period reads as part of
+// a domain name ("dawg.com." is a valid FQDN).
+const asSentence = (clauses: string[]): string | undefined => {
+ if (clauses.length === 0) return undefined;
+ const joined = clauses.join("; ");
+ return `${joined.charAt(0).toUpperCase()}${joined.slice(1)}`;
+};
+
+const patternClause = (verb: string, connector: string, patterns: string[]): string =>
+ patterns.length === 1
+ ? `${verb} ${patterns[0]}`
+ : `${verb} ${connector}: ${formatPatterns(patterns)}`;
+
+const isWildcardPattern = (pattern: string) => pattern.includes("*");
+
+// Mirrors matchesNormalizedPattern in backend/src/services/certificate-policy/certificate-policy-fns.ts.
+// Both sides must already be normalized by the caller.
+const matchesNormalizedPattern = (value: string, pattern: string): boolean => {
+ if (!isWildcardPattern(pattern)) return pattern === value;
+
+ try {
+ const expression = pattern.replace(/[.+?^${}()|[\]\\]/g, "\\$&").replace(/\*/g, ".*");
+ return new RegExp(`^${expression}$`).test(value);
+ } catch {
+ return pattern === value;
+ }
+};
+
+const normalizeUri = (value: string): string => {
+ const match = /^([a-zA-Z][a-zA-Z0-9+.-]*:\/\/[^/?#]*)([/?#].*)?$/.exec(value);
+ if (!match) return value;
+ return `${match[1].toLowerCase()}${match[2] ?? ""}`;
+};
+
+const normalizeValue = (value: string, isUri: boolean) =>
+ isUri ? normalizeUri(value) : value.toLowerCase();
+
+const matchesAny = (value: string, patterns?: string[], isUri = false): boolean =>
+ Boolean(
+ patterns?.some((pattern) =>
+ matchesNormalizedPattern(normalizeValue(value, isUri), normalizeValue(pattern, isUri))
+ )
+ );
+
+const parseSequence = (value: string): string[] =>
+ value
+ .split(",")
+ .map((component) => component.trim())
+ .filter((component) => component.length > 0);
+
+const formatSequence = (sequence: string[]): string =>
+ sequence.map((component) => `DC=${component}`).join(",");
+
+const formatSequences = (sequences: string[][]): string =>
+ formatPatterns(sequences.map(formatSequence));
+
+const sequenceClause = (verb: string, connector: string, sequences: string[][]): string =>
+ patternClause(verb, connector, sequences.map(formatSequence));
+
+const matchesSequence = (request: string[], policy: string[]): boolean =>
+ request.length === policy.length &&
+ request.every((component, index) =>
+ matchesNormalizedPattern(component.toLowerCase(), policy[index].toLowerCase())
+ );
+
+const matchesAnySequence = (request: string[], policies: string[][]): boolean =>
+ policies.some((policy) => matchesSequence(request, policy));
+
+const containsSequence = (request: string[], policy: string[]): boolean => {
+ if (policy.length === 0 || policy.length > request.length) return false;
+ return request.some(
+ (_, offset) =>
+ offset + policy.length <= request.length &&
+ matchesSequence(request.slice(offset, offset + policy.length), policy)
+ );
+};
+
+const containsAnySequence = (request: string[], policies: string[][]): boolean =>
+ policies.some((policy) => containsSequence(request, policy));
+
+const concatValues = (first?: string[], second?: string[]): string[] | undefined =>
+ first || second ? [...(first ?? []), ...(second ?? [])] : undefined;
+
+const mergeRules = <T extends ValueRule>(existing: T | undefined, incoming: T): T =>
+ existing
+ ? {
+ ...existing,
+ allowed: concatValues(existing.allowed, incoming.allowed),
+ required: concatValues(existing.required, incoming.required),
+ denied: concatValues(existing.denied, incoming.denied)
+ }
+ : incoming;
+
+export type CertificatePolicyRules = {
+ subject: Partial<Record<CertSubjectAttributeType, TSubjectRule>>;
+ sans: Partial<Record<CertSubjectAlternativeNameType, SanRule>>;
+ /** An absent subject/SAN policy means no constraint at all, which is different from an empty one. */
+ hasSubjectPolicy: boolean;
+ hasSanPolicy: boolean;
+};
+
+export const EMPTY_POLICY_RULES: CertificatePolicyRules = {
+ subject: {},
+ sans: {},
+ hasSubjectPolicy: false,
+ hasSanPolicy: false
+};
+
+export const buildPolicyRules = (policy?: TCertificatePolicy | null): CertificatePolicyRules => {
+ if (!policy) return EMPTY_POLICY_RULES;
+
+ const subject: Partial<Record<CertSubjectAttributeType, TSubjectRule>> = {};
+ policy.subject?.forEach((rule) => {
+ const type = rule.type as CertSubjectAttributeType;
+ subject[type] = mergeRules(subject[type], rule);
+ });
+
+ const sans: Partial<Record<CertSubjectAlternativeNameType, SanRule>> = {};
+ policy.sans?.forEach((rule) => {
+ const type = rule.type as CertSubjectAlternativeNameType;
+ sans[type] = mergeRules(sans[type], rule);
+ });
+
+ return {
+ subject,
+ sans,
+ hasSubjectPolicy: Boolean(policy.subject),
+ hasSanPolicy: Boolean(policy.sans)
+ };
+};
+
+/**
+ * The values a rule accepts. When a rule carries `required` patterns the backend demands a match
+ * against those specifically, so `allowed` no longer widens the set for subject attributes.
+ */
+const acceptedSubjectPatterns = (rule: TSubjectRule): string[] | undefined =>
+ rule.required?.length ? rule.required : rule.allowed;
+
+export const getSubjectAttributeHint = (
+ type: CertSubjectAttributeType,
+ rule?: TSubjectRule
+): string | undefined => {
+ if (!rule) return undefined;
+
+ if (type === CertSubjectAttributeType.DOMAIN_COMPONENT) {
+ const sequences = (rule.required?.length ? rule.required : rule.allowed)?.map(parseSequence);
+ const clauses: string[] = [];
+ if (sequences?.length) {
+ clauses.push(sequenceClause("the ordered sequence must match", "one of", sequences));
+ }
+ if (rule.denied?.length) {
+ clauses.push(sequenceClause("cannot contain", "any of", rule.denied.map(parseSequence)));
+ }
+ return asSentence(clauses);
+ }
+
+ const clauses: string[] = [];
+ const accepted = acceptedSubjectPatterns(rule);
+ if (accepted?.length) clauses.push(patternClause("must match", "one of", accepted));
+ if (rule.denied?.length) clauses.push(patternClause("cannot match", "any of", rule.denied));
+ return asSentence(clauses);
+};
+
+export const getSanHint = (rule?: SanRule): string | undefined => {
+ if (!rule) return undefined;
+
+ const clauses: string[] = [];
+ if (rule.allowed?.length) {
+ clauses.push(
+ patternClause("must match", "one of", [...(rule.required ?? []), ...rule.allowed])
+ );
+ } else if (rule.required?.length) {
+ clauses.push(patternClause("this policy requires one matching", "any of", rule.required));
+ }
+ if (rule.denied?.length) clauses.push(patternClause("cannot match", "any of", rule.denied));
+ return asSentence(clauses);
+};
+
+export const validateSubjectAttributeValue = (
+ type: CertSubjectAttributeType,
+ value: string,
+ rule: TSubjectRule | undefined,
+ hasSubjectPolicy: boolean
+): string | undefined => {
+ const trimmed = value.trim();
+ if (!trimmed) return undefined;
+
+ const label = SUBJECT_ATTRIBUTE_LABELS[type];
+ // A subject policy that carries no rule for this type permits nothing of that type.
+ if (!rule) return hasSubjectPolicy ? `${label} is not allowed by this policy` : undefined;
+
+ // Domain components are validated as one ordered sequence, not row by row.
+ if (type === CertSubjectAttributeType.DOMAIN_COMPONENT) return undefined;
+ if (matchesAny(trimmed, rule.denied)) {
+ return `${label} "${trimmed}" is denied by this policy`;
+ }
+ if (rule.required?.length && !matchesAny(trimmed, rule.required)) {
+ return `${label} ${patternClause("must match", "one of", rule.required)}`;
+ }
+ if (!rule.required?.length && rule.allowed?.length && !matchesAny(trimmed, rule.allowed)) {
+ return `${label} ${patternClause("must match", "one of", rule.allowed)}`;
+ }
+ return undefined;
+};
+
+export const validateSanValue = (
+ type: CertSubjectAlternativeNameType,
+ value: string,
+ rule: SanRule | undefined,
+ hasSanPolicy: boolean
+): string | undefined => {
+ const trimmed = value.trim();
+ if (!trimmed) return undefined;
+
+ const isUri = type === CertSubjectAlternativeNameType.URI;
+ const label = `${formatSANType(type)} SAN`;
+ if (!rule) return hasSanPolicy ? `${label} is not allowed by this policy` : undefined;
+ if (matchesAny(trimmed, rule.denied, isUri)) {
+ return `${label} "${trimmed}" is denied by this policy`;
+ }
+ if (matchesAny(trimmed, rule.required, isUri)) return undefined;
+ if (rule.allowed?.length && !matchesAny(trimmed, rule.allowed, isUri)) {
+ const accepted = [...(rule.required ?? []), ...rule.allowed];
+ return `${label} ${patternClause("must match", "one of", accepted)}`;
+ }
+ return undefined;
+};
+
+const DOMAIN_COMPONENT_ORDER_NOTE =
+ "Rows are order-sensitive, so they must follow the policy's order.";
+
+const reversalHint = (request: string[], policies: string[][]): string => {
+ const reversed = [...request].reverse();
+ if (request.length < 2 || !matchesAnySequence(reversed, policies)) return "";
+ return " The same components in the opposite order would match, so check the row order.";
+};
+
+/** Sequence-level domain component errors. An absent sequence is reported as a requirement instead. */
+export const validateDomainComponents = (components: string[], rule?: TSubjectRule): string[] => {
+ if (!rule || components.length === 0) return [];
+
+ const errors: string[] = [];
+ const allowed = (rule.allowed ?? []).map(parseSequence);
+ const required = (rule.required ?? []).map(parseSequence);
+ const denied = (rule.denied ?? []).map(parseSequence);
+ const formatted = formatSequence(components);
+
+ const isDenied = containsAnySequence(components, denied);
+ if (isDenied) {
+ errors.push(
+ `Domain components "${formatted}" are denied by this policy. Denied: ${formatSequences(denied)}`
+ );
+ }
+
+ const satisfiesRequired = required.length > 0 && matchesAnySequence(components, required);
+ if (required.length > 0 && !satisfiesRequired) {
+ errors.push(
+ `Domain components "${formatted}" do not match a required sequence. ${DOMAIN_COMPONENT_ORDER_NOTE}${reversalHint(components, required)} Required: ${formatSequences(required)}`
+ );
+ }
+
+ if (!isDenied && !satisfiesRequired && allowed.length > 0) {
+ if (!matchesAnySequence(components, allowed)) {
+ errors.push(
+ `Domain components "${formatted}" are not allowed by this policy. ${DOMAIN_COMPONENT_ORDER_NOTE}${reversalHint(components, allowed)} Allowed: ${formatSequences(allowed)}`
+ );
+ }
+ }
+
+ return errors;
+};
+
+export type PolicyRequirement = {
+ id: string;
+ message: string;
+ /** Rows to append when the request is missing this attribute or SAN entirely. */
+ addRows?:
+ | { kind: "subject"; type: CertSubjectAttributeType; values: string[] }
+ | { kind: "san"; type: CertSubjectAlternativeNameType; values: string[] };
+};
+
+/** A single literal pattern can be filled in for the user; wildcards cannot. */
+const literalSuggestion = (patterns: string[]): string =>
+ patterns.length === 1 && !isWildcardPattern(patterns[0]) ? patterns[0] : "";
+
+export type SubjectPolicyGuidance = {
+ subjectRowHints: (string | undefined)[];
+ subjectRowErrors: (string | undefined)[];
+ subjectNotices: string[];
+ sanRowHints: (string | undefined)[];
+ sanRowErrors: (string | undefined)[];
+ requirements: PolicyRequirement[];
+ hasBlockingIssues: boolean;
+};
+
+export const EMPTY_SUBJECT_POLICY_GUIDANCE: SubjectPolicyGuidance = {
+ subjectRowHints: [],
+ subjectRowErrors: [],
+ subjectNotices: [],
+ sanRowHints: [],
+ sanRowErrors: [],
+ requirements: [],
+ hasBlockingIssues: false
+};
+
+export const evaluateSubjectStep = ({
+ rules,
+ subjectAttributes,
+ subjectAltNames,
+ isSubjectSectionShown,
+ isSanSectionShown
+}: {
+ rules: CertificatePolicyRules;
+ subjectAttributes: SubjectAttribute[];
+ subjectAltNames: SubjectAltName[];
+ isSubjectSectionShown: boolean;
+ isSanSectionShown: boolean;
+}): SubjectPolicyGuidance => {
+ const requirements: PolicyRequirement[] = [];
+
+ const subjectRowHints = subjectAttributes.map((attr, index) => {
+ const isFirstOfType =
+ subjectAttributes.findIndex((other) => other.type === attr.type) === index;
+ // A domain component rule spans every DC row, so only the first row carries the hint.
+ if (attr.type === CertSubjectAttributeType.DOMAIN_COMPONENT && !isFirstOfType) return undefined;
+ return getSubjectAttributeHint(attr.type, rules.subject[attr.type]);
+ });
+
+ const subjectRowErrors = subjectAttributes.map((attr) =>
+ validateSubjectAttributeValue(
+ attr.type,
+ attr.value,
+ rules.subject[attr.type],
+ rules.hasSubjectPolicy
+ )
+ );
+
+ const domainComponents = subjectAttributes
+ .filter((attr) => attr.type === CertSubjectAttributeType.DOMAIN_COMPONENT)
+ .map((attr) => attr.value.trim())
+ .filter(Boolean);
+
+ const domainComponentRule = rules.subject[CertSubjectAttributeType.DOMAIN_COMPONENT];
+ const subjectNotices = validateDomainComponents(domainComponents, domainComponentRule);
+
+ if (isSubjectSectionShown) {
+ Object.entries(rules.subject).forEach(([rawType, rule]) => {
+ const type = rawType as CertSubjectAttributeType;
+ if (!rule?.required?.length) return;
+
+ const label = SUBJECT_ATTRIBUTE_LABELS[type];
+ if (type === CertSubjectAttributeType.DOMAIN_COMPONENT) {
+ const sequences = rule.required.map(parseSequence);
+ // A populated sequence that does not match already produces its own notice.
+ if (domainComponents.length > 0) return;
+
+ const onlySequence = sequences.length === 1 ? sequences[0] : undefined;
+ const isFillable = Boolean(onlySequence?.every((part) => !isWildcardPattern(part)));
+ requirements.push({
+ id: `subject-${type}`,
+ message:
+ sequences.length === 1
+ ? `${label} rows must form the sequence ${formatSequence(sequences[0])}`
+ : `${label} rows must form one of: ${formatSequences(sequences)}`,
+ ...(subjectAttributes.every((attr) => attr.type !== type) && {
+ addRows: {
+ kind: "subject" as const,
+ type,
+ values: isFillable && onlySequence ? onlySequence : [""]
+ }
+ })
+ });
+ return;
+ }
+
+ const current = subjectAttributes.find((attr) => attr.type === type);
+ const value = current?.value.trim() ?? "";
+ if (value && matchesAny(value, rule.required)) return;
+
+ requirements.push({
+ id: `subject-${type}`,
+ message: `${label} is required and ${patternClause("must match", "one of", rule.required)}`,
+ ...(!current && {
+ addRows: {
+ kind: "subject" as const,
+ type,
+ values: [literalSuggestion(rule.required)]
+ }
+ })
+ });
+ });
+ }
+
+ const sanRowHints = subjectAltNames.map((san) => getSanHint(rules.sans[san.type]));
+ const sanRowErrors = subjectAltNames.map((san) =>
+ validateSanValue(san.type, san.value, rules.sans[san.type], rules.hasSanPolicy)
+ );
+
+ if (isSanSectionShown) {
+ Object.entries(rules.sans).forEach(([rawType, rule]) => {
+ const type = rawType as CertSubjectAlternativeNameType;
+ if (!rule?.required?.length) return;
+
+ const isUri = type === CertSubjectAlternativeNameType.URI;
+ const presentValues = subjectAltNames
+ .filter((san) => san.type === type)
+ .map((san) => san.value.trim())
+ .filter(Boolean);
+
+ // A wildcard pattern cannot be filled in for the user, so each unmet one needs its own blank
+ // row. Blank rows already on the form are claimed first, one per requirement.
+ let unclaimedEmptyRows = subjectAltNames.filter(
+ (san) => san.type === type && !san.value.trim()
+ ).length;
+
+ rule.required.forEach((pattern) => {
+ if (presentValues.some((value) => matchesAny(value, [pattern], isUri))) return;
+
+ const requirement: PolicyRequirement = {
+ id: `san-${type}-${pattern}`,
+ message: `A ${formatSANType(type)} SAN matching ${pattern} is required`
+ };
+
+ if (!isWildcardPattern(pattern)) {
+ requirement.addRows = { kind: "san", type, values: [pattern] };
+ } else if (unclaimedEmptyRows > 0) {
+ unclaimedEmptyRows -= 1;
+ } else {
+ requirement.addRows = { kind: "san", type, values: [""] };
+ }
+
+ requirements.push(requirement);
+ });
+ });
+ }
+
+ // Only issues on a rendered section can block, otherwise there is nowhere to go and fix them.
+ const hasBlockingIssues =
+ (isSubjectSectionShown && (subjectRowErrors.some(Boolean) || subjectNotices.length > 0)) ||
+ (isSanSectionShown && sanRowErrors.some(Boolean)) ||
+ requirements.length > 0;
+
+ return {
+ subjectRowHints,
+ subjectRowErrors,
+ subjectNotices,
+ sanRowHints,
+ sanRowErrors,
+ requirements,
+ hasBlockingIssues
+ };
+};
+
+export const mergeRowErrors = (
+ formErrors: (string | undefined)[] | undefined,
+ policyErrors: (string | undefined)[]
+): (string | undefined)[] =>
+ Array.from(
+ { length: Math.max(formErrors?.length ?? 0, policyErrors.length) },
+ (_, index) => formErrors?.[index] ?? policyErrors[index]
+ );
diff --git a/frontend/src/pages/cert-manager/CertificatesPage/components/certificateUtils.ts b/frontend/src/pages/cert-manager/CertificatesPage/components/certificateUtils.ts
index ae58689e39..65d7abfbce 100644
--- a/frontend/src/pages/cert-manager/CertificatesPage/components/certificateUtils.ts
+++ b/frontend/src/pages/cert-manager/CertificatesPage/components/certificateUtils.ts
@@ -35,6 +35,21 @@ export type SubjectAltName = {
value: string;
};
+export type SubjectAttribute = {
+ type: CertSubjectAttributeType;
+ value: string;
+};
+
+export const SUBJECT_ATTRIBUTE_LABELS: Record<CertSubjectAttributeType, string> = {
+ [CertSubjectAttributeType.COMMON_NAME]: "Common Name",
+ [CertSubjectAttributeType.ORGANIZATION]: "Organization",
+ [CertSubjectAttributeType.ORGANIZATIONAL_UNIT]: "Organizational Unit",
+ [CertSubjectAttributeType.COUNTRY]: "Country",
+ [CertSubjectAttributeType.STATE]: "State/Province",
+ [CertSubjectAttributeType.LOCALITY]: "Locality",
+ [CertSubjectAttributeType.DOMAIN_COMPONENT]: "Domain Component"
+};
+
export const sanTypeCandidatesFromValue = (value: string): CertSubjectAlternativeNameType[] => {
if (isIPv4(value) || isIPv6(value)) return [CertSubjectAlternativeNameType.IP_ADDRESS];
if (value.includes("@"))
diff --git a/frontend/src/pages/cert-manager/CertificatesPage/components/useSubjectPolicyGuidance.ts b/frontend/src/pages/cert-manager/CertificatesPage/components/useSubjectPolicyGuidance.ts
new file mode 100644
index 0000000000..f1a7f0d599
--- /dev/null
+++ b/frontend/src/pages/cert-manager/CertificatesPage/components/useSubjectPolicyGuidance.ts
@@ -0,0 +1,88 @@
+import { useCallback, useMemo, useRef } from "react";
+import { UseFormSetValue, UseFormWatch } from "react-hook-form";
+
+import { TCertificatePolicy } from "@app/hooks/api/certificatePolicies";
+
+import {
+ buildPolicyRules,
+ evaluateSubjectStep,
+ SubjectPolicyGuidance
+} from "./certificatePolicyGuidance";
+import { SubjectAltName, SubjectAttribute } from "./certificateUtils";
+
+const EMPTY_SUBJECT_ATTRIBUTES: SubjectAttribute[] = [];
+const EMPTY_SUBJECT_ALT_NAMES: SubjectAltName[] = [];
+
+type UseSubjectPolicyGuidanceParams = {
+ policy?: TCertificatePolicy | null;
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ watch: UseFormWatch<any>;
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ setValue: UseFormSetValue<any>;
+ isSubjectSectionShown: boolean;
+ isSanSectionShown: boolean;
+ isEnabled?: boolean;
+};
+
+/**
+ * Evaluates the subject step against the profile's policy on every keystroke so the constraints and
+ * their violations surface where they can be fixed, rather than as a rejection at issuance.
+ */
+export const useSubjectPolicyGuidance = ({
+ policy,
+ watch,
+ setValue,
+ isSubjectSectionShown,
+ isSanSectionShown,
+ isEnabled = true
+}: UseSubjectPolicyGuidanceParams): SubjectPolicyGuidance & { addMissingFields: () => void } => {
+ const subjectAttributes: SubjectAttribute[] =
+ watch("subjectAttributes") ?? EMPTY_SUBJECT_ATTRIBUTES;
+ const subjectAltNames: SubjectAltName[] = watch("subjectAltNames") ?? EMPTY_SUBJECT_ALT_NAMES;
+
+ const rules = useMemo(
+ () => buildPolicyRules(isEnabled ? policy : undefined),
+ [policy, isEnabled]
+ );
+
+ const guidance = useMemo(
+ () =>
+ evaluateSubjectStep({
+ rules,
+ subjectAttributes,
+ subjectAltNames,
+ isSubjectSectionShown,
+ isSanSectionShown
+ }),
+ [rules, subjectAttributes, subjectAltNames, isSubjectSectionShown, isSanSectionShown]
+ );
+
+ const requirementsRef = useRef(guidance.requirements);
+ requirementsRef.current = guidance.requirements;
+
+ const addMissingFields = useCallback(() => {
+ const additions = requirementsRef.current
+ .map(({ addRows }) => addRows)
+ .filter((addRows): addRows is NonNullable<typeof addRows> => Boolean(addRows));
+
+ const subjectRows = additions.flatMap((addition) =>
+ addition.kind === "subject"
+ ? addition.values.map((value) => ({ type: addition.type, value }))
+ : []
+ );
+ const sanRows = additions.flatMap((addition) =>
+ addition.kind === "san"
+ ? addition.values.map((value) => ({ type: addition.type, value }))
+ : []
+ );
+
+ if (subjectRows.length > 0) {
+ setValue("subjectAttributes", [...subjectAttributes, ...subjectRows], { shouldDirty: true });
+ }
+ if (sanRows.length > 0) {
+ setValue("subjectAltNames", [...subjectAltNames, ...sanRows], { shouldDirty: true });
+ }
+ }, [setValue, subjectAttributes, subjectAltNames]);
+
+ return { ...guidance, addMissingFields };
+};
diff --git a/frontend/src/pages/cert-manager/DiscoveryPage/DiscoveryPage.tsx b/frontend/src/pages/cert-manager/DiscoveryPage/DiscoveryPage.tsx
index 919baf612e..da34f41a16 100644
--- a/frontend/src/pages/cert-manager/DiscoveryPage/DiscoveryPage.tsx
+++ b/frontend/src/pages/cert-manager/DiscoveryPage/DiscoveryPage.tsx
@@ -43,6 +43,7 @@ export const DiscoveryPage = () => {
</Helmet>
<div className="mx-auto mb-6 w-full max-w-8xl">
<PageHeader
+ className="mb-6"
scope={ProjectType.CertificateManager}
title={
<span className="inline-flex items-center gap-x-2">
diff --git a/frontend/src/pages/cert-manager/PoliciesPage/components/CertificatePoliciesTab/PolicyList.tsx b/frontend/src/pages/cert-manager/PoliciesPage/components/CertificatePoliciesTab/PolicyList.tsx
index e515ef488c..6edd021bcb 100644
--- a/frontend/src/pages/cert-manager/PoliciesPage/components/CertificatePoliciesTab/PolicyList.tsx
+++ b/frontend/src/pages/cert-manager/PoliciesPage/components/CertificatePoliciesTab/PolicyList.tsx
@@ -1,6 +1,6 @@
import { useCallback } from "react";
import { subject } from "@casl/ability";
-import { Link } from "@tanstack/react-router";
+import { Link, useNavigate } from "@tanstack/react-router";
import {
CheckIcon,
CopyIcon,
@@ -49,6 +49,7 @@ interface Props {
export const PolicyList = ({ onEditPolicy, onDeletePolicy }: Props) => {
const { currentProject } = useProject();
const { currentOrg } = useOrganization();
+ const navigate = useNavigate();
const [isIdCopied, setIsIdCopied] = useToggle(false);
const { data, isLoading } = useListCertificatePolicies({
@@ -113,7 +114,19 @@ export const PolicyList = ({ onEditPolicy, onDeletePolicy }: Props) => {
</TableHeader>
<TableBody>
{policies.map((policy) => (
- <TableRow key={policy.id}>
+ <TableRow
+ key={policy.id}
+ onClick={() =>
+ navigate({
+ to: "/organizations/$orgId/projects/cert-manager/$projectId/certificate-policies/$policyId",
+ params: {
+ orgId: currentOrg.id,
+ projectId: currentProject.id,
+ policyId: policy.id
+ }
+ })
+ }
+ >
<TableCell>
<div className="flex items-center gap-2">
<Link
@@ -124,6 +137,7 @@ export const PolicyList = ({ onEditPolicy, onDeletePolicy }: Props) => {
policyId: policy.id
}}
className="hover:underline"
+ onClick={(e) => e.stopPropagation()}
>
{policy.name}
</Link>
@@ -140,7 +154,7 @@ export const PolicyList = ({ onEditPolicy, onDeletePolicy }: Props) => {
<TableCell>
<span className="text-sm">{formatDate(policy.createdAt)}</span>
</TableCell>
- <TableCell className="text-right">
+ <TableCell className="text-right" onClick={(e) => e.stopPropagation()}>
<DropdownMenu>
<DropdownMenuTrigger asChild>
<IconButton variant="ghost" size="xs" aria-label="Policy actions">
diff --git a/frontend/src/pages/cert-manager/PoliciesPage/components/CertificateProfilesTab/ProfileRow.tsx b/frontend/src/pages/cert-manager/PoliciesPage/components/CertificateProfilesTab/ProfileRow.tsx
index 77203f9a98..fc92cc65e7 100644
--- a/frontend/src/pages/cert-manager/PoliciesPage/components/CertificateProfilesTab/ProfileRow.tsx
+++ b/frontend/src/pages/cert-manager/PoliciesPage/components/CertificateProfilesTab/ProfileRow.tsx
@@ -1,7 +1,7 @@
/* eslint-disable no-nested-ternary */
import { useCallback } from "react";
import { subject } from "@casl/ability";
-import { Link } from "@tanstack/react-router";
+import { Link, useNavigate } from "@tanstack/react-router";
import {
CheckIcon,
CopyIcon,
@@ -46,6 +46,7 @@ interface Props {
export const ProfileRow = ({ profile, onEditProfile, onCloneProfile, onDeleteProfile }: Props) => {
const { currentOrg } = useOrganization();
const { currentProject } = useProject();
+ const navigate = useNavigate();
const isInternalCa = !profile.certificateAuthority?.isExternal;
const { data: caData } = useGetInternalCaById(isInternalCa ? (profile.caId ?? "") : "");
@@ -68,7 +69,19 @@ export const ProfileRow = ({ profile, onEditProfile, onCloneProfile, onDeletePro
});
return (
- <TableRow key={profile.id}>
+ <TableRow
+ key={profile.id}
+ onClick={() =>
+ navigate({
+ to: "/organizations/$orgId/projects/cert-manager/$projectId/certificate-profiles/$profileId",
+ params: {
+ orgId: currentOrg.id,
+ projectId: currentProject.id,
+ profileId: profile.id
+ }
+ })
+ }
+ >
<TableCell>
<div className="flex items-center gap-2">
<Link
@@ -79,6 +92,7 @@ export const ProfileRow = ({ profile, onEditProfile, onCloneProfile, onDeletePro
profileId: profile.id
}}
className="hover:underline"
+ onClick={(e) => e.stopPropagation()}
>
{profile.slug}
</Link>
@@ -103,7 +117,7 @@ export const ProfileRow = ({ profile, onEditProfile, onCloneProfile, onDeletePro
profile.caId}
</span>
</TableCell>
- <TableCell>
+ <TableCell onClick={(e) => e.stopPropagation()}>
<Link
to="/organizations/$orgId/projects/cert-manager/$projectId/certificate-policies/$policyId"
params={{
@@ -116,7 +130,7 @@ export const ProfileRow = ({ profile, onEditProfile, onCloneProfile, onDeletePro
{policyData?.name || profile.certificatePolicyId}
</Link>
</TableCell>
- <TableCell className="text-right">
+ <TableCell className="text-right" onClick={(e) => e.stopPropagation()}>
<DropdownMenu>
<DropdownMenuTrigger asChild>
<IconButton variant="ghost" size="xs" aria-label="Profile actions">
diff --git a/frontend/src/pages/cert-manager/RequestsPage/RequestsPage.tsx b/frontend/src/pages/cert-manager/RequestsPage/RequestsPage.tsx
index 3a970c4662..4eb073466d 100644
--- a/frontend/src/pages/cert-manager/RequestsPage/RequestsPage.tsx
+++ b/frontend/src/pages/cert-manager/RequestsPage/RequestsPage.tsx
@@ -231,6 +231,7 @@ export const RequestsPage = () => {
<div className="mx-auto flex flex-col text-white">
<div className="mx-auto mb-6 w-full max-w-8xl">
<PageHeader
+ className="mb-6"
scope={ProjectType.CertificateManager}
title="Approval Requests"
description="Review pending approval requests across your applications and signers"
diff --git a/frontend/src/pages/cert-manager/SettingsPage/SettingsPage.tsx b/frontend/src/pages/cert-manager/SettingsPage/SettingsPage.tsx
index 25de731c6e..d4b822f14c 100644
--- a/frontend/src/pages/cert-manager/SettingsPage/SettingsPage.tsx
+++ b/frontend/src/pages/cert-manager/SettingsPage/SettingsPage.tsx
@@ -27,6 +27,7 @@ export const SettingsPage = () => {
</Helmet>
<div className="w-full max-w-8xl">
<PageHeader
+ className="mb-6"
scope={ProjectType.CertificateManager}
title="Settings"
description="Configure app connections, HSM connectors, and cleanup rules."
diff --git a/frontend/src/pages/project/AccessControlPage/AccessControlPage.tsx b/frontend/src/pages/project/AccessControlPage/AccessControlPage.tsx
index 33a057bd53..04775522f9 100644
--- a/frontend/src/pages/project/AccessControlPage/AccessControlPage.tsx
+++ b/frontend/src/pages/project/AccessControlPage/AccessControlPage.tsx
@@ -67,6 +67,7 @@ const Page = () => {
<div className="mx-auto flex flex-col justify-between text-foreground">
<div className="mx-auto mb-6 w-full max-w-8xl">
<PageHeader
+ className={hasTabs ? "mb-6" : undefined}
scope={currentProject.type}
title={isCertManager ? "Access Control" : "Project Access Control"}
description={