Skip to content

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

Cert Manager export nits and improvements

Carlos Monastyrski07329caf29eb
diff --git a/backend/src/@types/fastify.d.ts b/backend/src/@types/fastify.d.ts
index 5687bf07e1..d57f51c23d 100644
--- a/backend/src/@types/fastify.d.ts
+++ b/backend/src/@types/fastify.d.ts
@@ -84,9 +84,9 @@ import { TAuthPasswordFactory } from "@app/services/auth/auth-password-service";
import { TAuthSignupFactory } from "@app/services/auth/auth-signup-service";
import { ActorAuthMethod, ActorType, MfaMethod, TProviderAuthCallback } from "@app/services/auth/auth-type";
import { TAuthTokenServiceFactory } from "@app/services/auth-token/auth-token-service";
+import { TCertManagerExportServiceFactory } from "@app/services/cert-manager-export/cert-manager-export-service";
import { TCertManagerInstanceServiceFactory } from "@app/services/cert-manager-instance/cert-manager-instance-service";
import { TCertManagerProjectResolverFactory } from "@app/services/cert-manager-instance/cert-manager-project-resolver";
-import { TCertManagerMigrationServiceFactory } from "@app/services/cert-manager-migration/cert-manager-migration-service";
import { TCertificateServiceFactory } from "@app/services/certificate/certificate-service";
import { TCaAutoRenewalQueueFactory } from "@app/services/certificate-authority/ca-auto-renewal-queue";
import { TCaSigningConfigServiceFactory } from "@app/services/certificate-authority/ca-signing-config/ca-signing-config-service";
@@ -338,7 +338,7 @@ declare module "fastify" {
pkiApplicationEnrollment: TPkiApplicationEnrollmentServiceFactory;
certManagerProjectResolver: TCertManagerProjectResolverFactory;
certManagerInstance: TCertManagerInstanceServiceFactory;
- certManagerMigration: TCertManagerMigrationServiceFactory;
+ certManagerExport: TCertManagerExportServiceFactory;
sshCertificateAuthority: TSshCertificateAuthorityServiceFactory;
sshCertificateTemplate: TSshCertificateTemplateServiceFactory;
sshHost: TSshHostServiceFactory;
diff --git a/backend/src/ee/services/audit-log/audit-log-types.ts b/backend/src/ee/services/audit-log/audit-log-types.ts
index e65fa57ddd..c77ac6c8c4 100644
--- a/backend/src/ee/services/audit-log/audit-log-types.ts
+++ b/backend/src/ee/services/audit-log/audit-log-types.ts
@@ -366,7 +366,7 @@ export enum EventType {
UPDATE_CA = "update-certificate-authority",
DELETE_CA = "delete-certificate-authority",
RENEW_CA = "renew-certificate-authority",
- MIGRATE_CERT_MANAGER_PROJECT = "migrate-cert-manager-project",
+ EXPORT_CERT_MANAGER_PROJECT = "export-cert-manager-project",
GET_CA_CSR = "get-certificate-authority-csr",
GET_CA_CERTS = "get-certificate-authority-certs",
GET_CA_CERT = "get-certificate-authority-cert",
@@ -3031,16 +3031,16 @@ interface RenewCa {
};
}
-interface MigrateCertManagerProject {
- type: EventType.MIGRATE_CERT_MANAGER_PROJECT;
+interface ExportCertManagerProject {
+ type: EventType.EXPORT_CERT_MANAGER_PROJECT;
metadata: {
sourceProjectId: string;
destinationProjectId: string;
- migratedCertificateAuthorities: number;
+ exportedCertificateAuthorities: number;
renamedCertificateAuthorities: { originalName: string; newName: string }[];
- migratedCertificatePolicies: number;
+ exportedCertificatePolicies: number;
renamedCertificatePolicies: { originalName: string; newName: string }[];
- migratedCertificateProfiles: number;
+ exportedCertificateProfiles: number;
skippedCertificateProfiles: number;
renamedCertificateProfiles: { originalSlug: string; newSlug: string }[];
};
@@ -7240,7 +7240,7 @@ export type Event =
| UpdateCa
| DeleteCa
| RenewCa
- | MigrateCertManagerProject
+ | ExportCertManagerProject
| GetCaCsr
| GetCaCerts
| GetCaCert
diff --git a/backend/src/server/plugins/inject-cert-manager-project-id.ts b/backend/src/server/plugins/inject-cert-manager-project-id.ts
index 93e166cbd7..2050b330a8 100644
--- a/backend/src/server/plugins/inject-cert-manager-project-id.ts
+++ b/backend/src/server/plugins/inject-cert-manager-project-id.ts
@@ -44,7 +44,7 @@ export const injectCertManagerProjectId: FastifyPluginAsync = fp(async (server)
return;
}
- if (routePath === "/api/v1/cert-manager/migrate") {
+ if (routePath === "/api/v1/cert-manager/export") {
return;
}
diff --git a/backend/src/server/routes/index.ts b/backend/src/server/routes/index.ts
index 464f9bcf34..3aecd5ba67 100644
--- a/backend/src/server/routes/index.ts
+++ b/backend/src/server/routes/index.ts
@@ -258,9 +258,9 @@ import { authPaswordServiceFactory } from "@app/services/auth/auth-password-serv
import { authSignupServiceFactory } from "@app/services/auth/auth-signup-service";
import { tokenDALFactory } from "@app/services/auth-token/auth-token-dal";
import { tokenServiceFactory } from "@app/services/auth-token/auth-token-service";
+import { certManagerExportServiceFactory } from "@app/services/cert-manager-export/cert-manager-export-service";
import { certManagerInstanceServiceFactory } from "@app/services/cert-manager-instance/cert-manager-instance-service";
import { certManagerProjectResolverFactory } from "@app/services/cert-manager-instance/cert-manager-project-resolver";
-import { certManagerMigrationServiceFactory } from "@app/services/cert-manager-migration/cert-manager-migration-service";
import { certificateBodyDALFactory } from "@app/services/certificate/certificate-body-dal";
import { certificateDALFactory } from "@app/services/certificate/certificate-dal";
import { certificateSecretDALFactory } from "@app/services/certificate/certificate-secret-dal";
@@ -2680,7 +2680,7 @@ export const registerRoutes = async (
licenseService
});
- const certManagerMigrationService = certManagerMigrationServiceFactory({
+ const certManagerExportService = certManagerExportServiceFactory({
certificateAuthorityDAL,
internalCertificateAuthorityDAL,
certificateAuthorityCertDAL,
@@ -2689,6 +2689,7 @@ export const registerRoutes = async (
certificatePolicyDAL,
certificateProfileDAL,
projectDAL,
+ orgDAL,
kmsService,
permissionService
});
@@ -3465,7 +3466,7 @@ export const registerRoutes = async (
pkiApplicationEnrollment: pkiApplicationEnrollmentService,
certManagerProjectResolver,
certManagerInstance: certManagerInstanceService,
- certManagerMigration: certManagerMigrationService,
+ certManagerExport: certManagerExportService,
certificateAuthorityCrl: certificateAuthorityCrlService,
certificateEst: certificateEstService,
pkiAcme: pkiAcmeService,
diff --git a/backend/src/server/routes/v1/cert-manager-migration-router.ts b/backend/src/server/routes/v1/cert-manager-export-router.ts
similarity index 66%
rename from backend/src/server/routes/v1/cert-manager-migration-router.ts
rename to backend/src/server/routes/v1/cert-manager-export-router.ts
index 97d1b6f2fa..66d9f9a005 100644
--- a/backend/src/server/routes/v1/cert-manager-migration-router.ts
+++ b/backend/src/server/routes/v1/cert-manager-export-router.ts
@@ -6,24 +6,24 @@ import { writeLimit } from "@app/server/config/rateLimiter";
import { verifyAuth } from "@app/server/plugins/auth/verify-auth";
import { AuthMode } from "@app/services/auth/auth-type";
-const MigrationResultSchema = z.object({
+const ExportResultSchema = z.object({
sourceProjectId: z.string(),
destinationProjectId: z.string(),
- migratedCertificateAuthorities: z.number().int().nonnegative(),
+ exportedCertificateAuthorities: z.number().int().nonnegative(),
renamedCertificateAuthorities: z.array(
z.object({
originalName: z.string(),
newName: z.string()
})
),
- migratedCertificatePolicies: z.number().int().nonnegative(),
+ exportedCertificatePolicies: z.number().int().nonnegative(),
renamedCertificatePolicies: z.array(
z.object({
originalName: z.string(),
newName: z.string()
})
),
- migratedCertificateProfiles: z.number().int().nonnegative(),
+ exportedCertificateProfiles: z.number().int().nonnegative(),
skippedCertificateProfiles: z.number().int().nonnegative(),
renamedCertificateProfiles: z.array(
z.object({
@@ -33,30 +33,28 @@ const MigrationResultSchema = z.object({
)
});
-export const registerCertManagerMigrationRouter = async (server: FastifyZodProvider) => {
+export const registerCertManagerExportRouter = async (server: FastifyZodProvider) => {
server.route({
method: "POST",
- url: "/migrate",
+ url: "/export",
config: { rateLimit: writeLimit },
schema: {
hide: true,
- operationId: "migrateCertManagerProject",
+ operationId: "exportCertManagerProject",
tags: [ApiDocsTags.PkiCertificateAuthorities],
description:
- "Duplicate internal certificate authorities, certificate policies, and certificate profiles from one project to another within the same organization. External CAs, certificates, and enrollment configs are not migrated.",
+ "Duplicate internal certificate authorities, certificate policies, and certificate profiles from the source project into the organization's active Certificate Manager instance. External CAs, certificates, and enrollment configs are not exported.",
body: z.object({
- sourceProjectId: z.string().trim().uuid(),
- destinationProjectId: z.string().trim().uuid()
+ sourceProjectId: z.string().trim().uuid()
}),
response: {
- 200: MigrationResultSchema
+ 200: ExportResultSchema
}
},
onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),
handler: async (req) => {
- const result = await server.services.certManagerMigration.migrateCertManagerProject({
+ const result = await server.services.certManagerExport.exportCertManagerProject({
sourceProjectId: req.body.sourceProjectId,
- destinationProjectId: req.body.destinationProjectId,
actor: req.permission.type,
actorId: req.permission.id,
actorOrgId: req.permission.orgId,
@@ -68,15 +66,15 @@ export const registerCertManagerMigrationRouter = async (server: FastifyZodProvi
orgId: req.permission.orgId,
projectId: result.destinationProjectId,
event: {
- type: EventType.MIGRATE_CERT_MANAGER_PROJECT,
+ type: EventType.EXPORT_CERT_MANAGER_PROJECT,
metadata: {
sourceProjectId: result.sourceProjectId,
destinationProjectId: result.destinationProjectId,
- migratedCertificateAuthorities: result.migratedCertificateAuthorities,
+ exportedCertificateAuthorities: result.exportedCertificateAuthorities,
renamedCertificateAuthorities: result.renamedCertificateAuthorities,
- migratedCertificatePolicies: result.migratedCertificatePolicies,
+ exportedCertificatePolicies: result.exportedCertificatePolicies,
renamedCertificatePolicies: result.renamedCertificatePolicies,
- migratedCertificateProfiles: result.migratedCertificateProfiles,
+ exportedCertificateProfiles: result.exportedCertificateProfiles,
skippedCertificateProfiles: result.skippedCertificateProfiles,
renamedCertificateProfiles: result.renamedCertificateProfiles
}
diff --git a/backend/src/server/routes/v1/index.ts b/backend/src/server/routes/v1/index.ts
index 6826a37aac..ebf5638979 100644
--- a/backend/src/server/routes/v1/index.ts
+++ b/backend/src/server/routes/v1/index.ts
@@ -14,8 +14,8 @@ import { APPROVAL_POLICY_REGISTER_ROUTER_MAP } from "./approval-policy-routers";
import { registerAuthRoutes } from "./auth-router";
import { registerProjectBotRouter } from "./bot-router";
import { registerCertManagerAccessRouter } from "./cert-manager-access-routers";
+import { registerCertManagerExportRouter } from "./cert-manager-export-router";
import { registerCertManagerInstanceRouter } from "./cert-manager-instance-router";
-import { registerCertManagerMigrationRouter } from "./cert-manager-migration-router";
import { registerCaRouter } from "./certificate-authority-router";
import { CERTIFICATE_AUTHORITY_REGISTER_ROUTER_MAP } from "./certificate-authority-routers";
import { registerGeneralCertificateAuthorityRouter } from "./certificate-authority-routers/general-certificate-authority-router";
@@ -205,7 +205,7 @@ export const registerV1Routes = async (server: FastifyZodProvider) => {
await pkiRouter.register(registerPkiAlertRouter, { prefix: "/alerts" });
await pkiRouter.register(registerPkiApplicationRouter, { prefix: "/applications" });
await pkiRouter.register(registerCertManagerInstanceRouter);
- await pkiRouter.register(registerCertManagerMigrationRouter);
+ await pkiRouter.register(registerCertManagerExportRouter);
await pkiRouter.register(registerSignerRouter, { prefix: "/signers" });
await pkiRouter.register(registerCertificateCleanupRouter, { prefix: "/certificate-cleanup" });
await pkiRouter.register(registerCertificateInventoryViewRouter, { prefix: "/certificate-inventory-views" });
diff --git a/backend/src/services/cert-manager-migration/cert-manager-migration-service.ts b/backend/src/services/cert-manager-export/cert-manager-export-service.ts
similarity index 90%
rename from backend/src/services/cert-manager-migration/cert-manager-migration-service.ts
rename to backend/src/services/cert-manager-export/cert-manager-export-service.ts
index f7b0b66644..e608f903cf 100644
--- a/backend/src/services/cert-manager-migration/cert-manager-migration-service.ts
+++ b/backend/src/services/cert-manager-export/cert-manager-export-service.ts
@@ -13,12 +13,13 @@ import { TCertificatePolicyDALFactory } from "@app/services/certificate-policy/c
import { TCertificateProfileDALFactory } from "@app/services/certificate-profile/certificate-profile-dal";
import { IssuerType } from "@app/services/certificate-profile/certificate-profile-types";
import { TKmsServiceFactory } from "@app/services/kms/kms-service";
+import { TOrgDALFactory } from "@app/services/org/org-dal";
import { TProjectDALFactory } from "@app/services/project/project-dal";
import { getProjectKmsCertificateKeyId } from "@app/services/project/project-fns";
-import { TMigrateCertManagerProjectDTO, TMigrateCertManagerProjectResult } from "./cert-manager-migration-types";
+import { TExportCertManagerProjectDTO, TExportCertManagerProjectResult } from "./cert-manager-export-types";
-type TCertManagerMigrationServiceFactoryDep = {
+type TCertManagerExportServiceFactoryDep = {
certificateAuthorityDAL: Pick<
TCertificateAuthorityDALFactory,
"find" | "findWithAssociatedCa" | "create" | "transaction"
@@ -30,13 +31,14 @@ type TCertManagerMigrationServiceFactoryDep = {
certificatePolicyDAL: Pick<TCertificatePolicyDALFactory, "find">;
certificateProfileDAL: Pick<TCertificateProfileDALFactory, "find">;
projectDAL: Pick<TProjectDALFactory, "findById" | "findOne" | "updateById" | "transaction">;
+ orgDAL: Pick<TOrgDALFactory, "findById">;
kmsService: Pick<TKmsServiceFactory, "encryptWithKmsKey" | "decryptWithKmsKey" | "generateKmsKey">;
permissionService: Pick<TPermissionServiceFactory, "getOrgPermission">;
};
-export type TCertManagerMigrationServiceFactory = ReturnType<typeof certManagerMigrationServiceFactory>;
+export type TCertManagerExportServiceFactory = ReturnType<typeof certManagerExportServiceFactory>;
-export const certManagerMigrationServiceFactory = ({
+export const certManagerExportServiceFactory = ({
certificateAuthorityDAL,
internalCertificateAuthorityDAL,
certificateAuthorityCertDAL,
@@ -45,9 +47,10 @@ export const certManagerMigrationServiceFactory = ({
certificatePolicyDAL,
certificateProfileDAL,
projectDAL,
+ orgDAL,
kmsService,
permissionService
-}: TCertManagerMigrationServiceFactoryDep) => {
+}: TCertManagerExportServiceFactoryDep) => {
const allocateUniqueName = (desired: string, taken: Set<string>): string => {
if (!taken.has(desired)) return desired;
let candidate: string;
@@ -57,29 +60,21 @@ export const certManagerMigrationServiceFactory = ({
return candidate;
};
- // knex auto-stringifies plain objects for jsonb columns, but treats JS arrays as Postgres
- // arrays — which corrupts jsonb columns whose value happens to be an array (e.g. policy
- // `subject` / `sans`). Pre-stringifying every jsonb-bound value sidesteps the heuristic.
const toJsonbValue = (value: unknown): string | null => {
if (value === null || value === undefined) return null;
if (typeof value === "string") return value;
return JSON.stringify(value);
};
- const migrateCertManagerProject = async ({
+ const exportCertManagerProject = async ({
sourceProjectId,
- destinationProjectId,
actor,
actorId,
actorOrgId,
actorAuthMethod
- }: TMigrateCertManagerProjectDTO): Promise<TMigrateCertManagerProjectResult> => {
+ }: TExportCertManagerProjectDTO): Promise<TExportCertManagerProjectResult> => {
if (actor !== ActorType.USER && actor !== ActorType.IDENTITY) {
- throw new BadRequestError({ message: "Invalid actor for cert manager migration" });
- }
-
- if (sourceProjectId === destinationProjectId) {
- throw new BadRequestError({ message: "Source and destination projects must be different" });
+ throw new BadRequestError({ message: "Invalid actor for cert manager export" });
}
const { hasRole } = await permissionService.getOrgPermission({
@@ -92,7 +87,23 @@ export const certManagerMigrationServiceFactory = ({
});
if (!hasRole(OrgMembershipRole.Admin)) {
throw new ForbiddenRequestError({
- message: "Only organization admins can migrate cert manager entities between projects"
+ message: "Only organization admins can export cert manager entities between projects"
+ });
+ }
+
+ const org = await orgDAL.findById(actorOrgId);
+ if (!org) {
+ throw new NotFoundError({ message: `Organization with ID '${actorOrgId}' not found` });
+ }
+ const destinationProjectId = org.defaultCertManagerProjectId;
+ if (!destinationProjectId) {
+ throw new BadRequestError({
+ message: "Set an active Certificate Manager instance for the organization before exporting"
+ });
+ }
+ if (sourceProjectId === destinationProjectId) {
+ throw new BadRequestError({
+ message: "Source project is already the active Certificate Manager instance"
});
}
@@ -211,7 +222,7 @@ export const certManagerMigrationServiceFactory = ({
const newSecretId = caSecretIdMap.get(sourceCaCert.caSecretId);
if (!newSecretId) {
throw new InternalServerError({
- message: `CA secret referenced by certificate authority cert '${sourceCaCert.id}' was not migrated`
+ message: `CA secret referenced by certificate authority cert '${sourceCaCert.id}' was not exported`
});
}
const newCaCert = await certificateAuthorityCertDAL.create(
@@ -262,7 +273,7 @@ export const certManagerMigrationServiceFactory = ({
const newCrlSecretId = caSecretIdMap.get(sourceCrl.caSecretId);
if (!newCrlSecretId) {
throw new InternalServerError({
- message: `CA secret referenced by CRL '${sourceCrl.id}' was not migrated`
+ message: `CA secret referenced by CRL '${sourceCrl.id}' was not exported`
});
}
await certificateAuthorityCrlDAL.create(
@@ -306,7 +317,7 @@ export const certManagerMigrationServiceFactory = ({
const sourceProfiles = await certificateProfileDAL.find({ projectId: sourceProjectId }, { tx });
const renamedCertificateProfiles: { originalSlug: string; newSlug: string }[] = [];
- let migratedCertificateProfiles = 0;
+ let exportedCertificateProfiles = 0;
let skippedCertificateProfiles = 0;
for (const sourceProfile of sourceProfiles) {
@@ -349,22 +360,22 @@ export const certManagerMigrationServiceFactory = ({
acmeConfigId: null,
scepConfigId: null
});
- migratedCertificateProfiles += 1;
+ exportedCertificateProfiles += 1;
}
return {
sourceProjectId,
destinationProjectId,
- migratedCertificateAuthorities: sortedCAs.length,
+ exportedCertificateAuthorities: sortedCAs.length,
renamedCertificateAuthorities,
- migratedCertificatePolicies: sourcePolicies.length,
+ exportedCertificatePolicies: sourcePolicies.length,
renamedCertificatePolicies,
- migratedCertificateProfiles,
+ exportedCertificateProfiles,
skippedCertificateProfiles,
renamedCertificateProfiles
};
});
};
- return { migrateCertManagerProject };
+ return { exportCertManagerProject };
};
diff --git a/backend/src/services/cert-manager-migration/cert-manager-migration-types.ts b/backend/src/services/cert-manager-export/cert-manager-export-types.ts
similarity index 68%
rename from backend/src/services/cert-manager-migration/cert-manager-migration-types.ts
rename to backend/src/services/cert-manager-export/cert-manager-export-types.ts
index 38c1141166..40b18ceeb5 100644
--- a/backend/src/services/cert-manager-migration/cert-manager-migration-types.ts
+++ b/backend/src/services/cert-manager-export/cert-manager-export-types.ts
@@ -1,22 +1,21 @@
import { ActorAuthMethod, ActorType } from "@app/services/auth/auth-type";
-export type TMigrateCertManagerProjectDTO = {
+export type TExportCertManagerProjectDTO = {
sourceProjectId: string;
- destinationProjectId: string;
actor: ActorType;
actorId: string;
actorOrgId: string;
actorAuthMethod: ActorAuthMethod;
};
-export type TMigrateCertManagerProjectResult = {
+export type TExportCertManagerProjectResult = {
sourceProjectId: string;
destinationProjectId: string;
- migratedCertificateAuthorities: number;
+ exportedCertificateAuthorities: number;
renamedCertificateAuthorities: { originalName: string; newName: string }[];
- migratedCertificatePolicies: number;
+ exportedCertificatePolicies: number;
renamedCertificatePolicies: { originalName: string; newName: string }[];
- migratedCertificateProfiles: number;
+ exportedCertificateProfiles: number;
skippedCertificateProfiles: number;
renamedCertificateProfiles: { originalSlug: string; newSlug: string }[];
};
diff --git a/frontend/src/components/projects/CertManagerSelectInstanceModal.tsx b/frontend/src/components/projects/CertManagerSelectInstanceModal.tsx
index 508161a8ef..8c11b227a3 100644
--- a/frontend/src/components/projects/CertManagerSelectInstanceModal.tsx
+++ b/frontend/src/components/projects/CertManagerSelectInstanceModal.tsx
@@ -62,7 +62,7 @@ export const CertManagerSelectInstanceModal = ({
rel="noopener noreferrer"
className="text-primary-500 hover:underline"
>
- Migration guide
+ Deprecation guide
</a>
</DialogDescription>
</DialogHeader>
@@ -71,7 +71,7 @@ export const CertManagerSelectInstanceModal = ({
<SelectTrigger className="w-full">
<SelectValue placeholder="Select a project" />
</SelectTrigger>
- <SelectContent className="max-h-[60vh]">
+ <SelectContent position="popper" className="max-h-72 w-(--radix-select-trigger-width)">
{instances.map((instance) => (
<SelectItem key={instance.id} value={instance.id}>
<div className="flex min-w-0 flex-1 items-center gap-2">
diff --git a/frontend/src/hooks/api/certManagerInstance/index.ts b/frontend/src/hooks/api/certManagerInstance/index.ts
index 13b9983a53..b76685182c 100644
--- a/frontend/src/hooks/api/certManagerInstance/index.ts
+++ b/frontend/src/hooks/api/certManagerInstance/index.ts
@@ -79,31 +79,25 @@ export const useSetCertManagerActiveProject = () => {
});
};
-export type TMigrateCertManagerProjectResult = {
+export type TExportCertManagerProjectResult = {
sourceProjectId: string;
destinationProjectId: string;
- migratedCertificateAuthorities: number;
+ exportedCertificateAuthorities: number;
renamedCertificateAuthorities: { originalName: string; newName: string }[];
- migratedCertificatePolicies: number;
+ exportedCertificatePolicies: number;
renamedCertificatePolicies: { originalName: string; newName: string }[];
- migratedCertificateProfiles: number;
+ exportedCertificateProfiles: number;
skippedCertificateProfiles: number;
renamedCertificateProfiles: { originalSlug: string; newSlug: string }[];
};
-export const useMigrateCertManagerProject = () => {
+export const useExportCertManagerProject = () => {
const qc = useQueryClient();
return useMutation({
- mutationFn: async ({
- sourceProjectId,
- destinationProjectId
- }: {
- sourceProjectId: string;
- destinationProjectId: string;
- }) => {
- const { data } = await apiRequest.post<TMigrateCertManagerProjectResult>(
- "/api/v1/cert-manager/migrate",
- { sourceProjectId, destinationProjectId }
+ mutationFn: async ({ sourceProjectId }: { sourceProjectId: string }) => {
+ const { data } = await apiRequest.post<TExportCertManagerProjectResult>(
+ "/api/v1/cert-manager/export",
+ { sourceProjectId }
);
return data;
},
diff --git a/frontend/src/layouts/PkiManagerLayout/components/CertManagerInstanceBanner.tsx b/frontend/src/layouts/PkiManagerLayout/components/CertManagerInstanceBanner.tsx
index 93dc6e2609..ce9822e0e0 100644
--- a/frontend/src/layouts/PkiManagerLayout/components/CertManagerInstanceBanner.tsx
+++ b/frontend/src/layouts/PkiManagerLayout/components/CertManagerInstanceBanner.tsx
@@ -18,7 +18,7 @@ export const CertManagerInstanceBanner = () => {
const message = isViewingActive
? "This is your organization's active instance. Use this for all work going forward."
- : `This project will be retired. Migrate your CAs, policies, and profiles to your active instance "${activeProject?.name ?? "not set"}", then update your clients and workflows to use it instead.`;
+ : `This project will be retired. Export your CAs, policies, and profiles to your active instance "${activeProject?.name ?? "not set"}", then update your clients and workflows to use it instead.`;
return (
<div className="flex w-full items-start gap-x-2 border-b border-yellow/50 bg-yellow/30 px-4 py-2 text-sm text-yellow-200">
@@ -41,7 +41,7 @@ export const CertManagerInstanceBanner = () => {
rel="noopener noreferrer"
className="underline underline-offset-2 hover:text-yellow"
>
- Migration guide
+ Deprecation guide
</a>
)}
</p>
diff --git a/frontend/src/layouts/ProjectLayout/components/TypeSelect/TypeSelect.tsx b/frontend/src/layouts/ProjectLayout/components/TypeSelect/TypeSelect.tsx
index fd7105067a..eccec12e14 100644
--- a/frontend/src/layouts/ProjectLayout/components/TypeSelect/TypeSelect.tsx
+++ b/frontend/src/layouts/ProjectLayout/components/TypeSelect/TypeSelect.tsx
@@ -16,6 +16,7 @@ import {
PopoverTrigger
} from "@app/components/v3";
import { useOrganization } from "@app/context";
+import { getCertManagerActiveProjectCookie } from "@app/helpers/certManagerActiveProject";
import {
getProjectLottieIcon,
getProjectTitle,
@@ -46,7 +47,8 @@ const TypeSelectInner = ({
const navigate = useNavigate();
const { currentOrg } = useOrganization();
const { data: projects = [] } = useGetUserProjects();
- const { data: certManagerInstance } = useCertManagerInstanceState();
+ const { data: certManagerInstance, isPending: isCertManagerInstancePending } =
+ useCertManagerInstanceState();
const projectCountsByType = useMemo(
() =>
@@ -56,6 +58,26 @@ const TypeSelectInner = ({
[projects]
);
+ const certManagerTargetProjectId = useMemo(() => {
+ const cookieValue = currentOrg?.id ? getCertManagerActiveProjectCookie(currentOrg.id) : null;
+ if (cookieValue && projects.some((p) => p.id === cookieValue)) {
+ return cookieValue;
+ }
+ return certManagerInstance?.activeProjectId ?? null;
+ }, [currentOrg?.id, projects, certManagerInstance?.activeProjectId]);
+
+ const navigateToCertManager = () => {
+ if (isCertManagerInstancePending) return;
+ if (certManagerTargetProjectId) {
+ navigate({
+ to: "/organizations/$orgId/projects/cert-manager/$projectId/overview",
+ params: { orgId: currentOrg?.id || "", projectId: certManagerTargetProjectId }
+ });
+ } else {
+ setIsCertManagerSetupOpen(true);
+ }
+ };
+
const handleSelectType = (type: ProjectType) => {
setOpen(false);
const orgId = currentOrg?.id || "";
@@ -63,14 +85,7 @@ const TypeSelectInner = ({
if (type === currentType) return;
if (type === ProjectType.CertificateManager) {
- if (certManagerInstance?.activeProjectId) {
- navigate({
- to: "/organizations/$orgId/projects/cert-manager/$projectId/overview",
- params: { orgId, projectId: certManagerInstance.activeProjectId }
- });
- } else {
- setIsCertManagerSetupOpen(true);
- }
+ navigateToCertManager();
return;
}
@@ -92,17 +107,7 @@ const TypeSelectInner = ({
type="button"
onClick={() => {
if (currentType === ProjectType.CertificateManager) {
- if (certManagerInstance?.activeProjectId) {
- navigate({
- to: "/organizations/$orgId/projects/cert-manager/$projectId/overview",
- params: {
- orgId: currentOrg?.id || "",
- projectId: certManagerInstance.activeProjectId
- }
- });
- } else {
- setIsCertManagerSetupOpen(true);
- }
+ navigateToCertManager();
} else {
navigate({
to: "/organizations/$orgId/projects/$type",
diff --git a/frontend/src/pages/organization/SettingsPage/components/OrgCertManagerTab/CertManagerMigrateProjectModal.tsx b/frontend/src/pages/organization/SettingsPage/components/OrgCertManagerTab/CertManagerExportProjectModal.tsx
similarity index 50%
rename from frontend/src/pages/organization/SettingsPage/components/OrgCertManagerTab/CertManagerMigrateProjectModal.tsx
rename to frontend/src/pages/organization/SettingsPage/components/OrgCertManagerTab/CertManagerExportProjectModal.tsx
index af075b8411..72131209b0 100644
--- a/frontend/src/pages/organization/SettingsPage/components/OrgCertManagerTab/CertManagerMigrateProjectModal.tsx
+++ b/frontend/src/pages/organization/SettingsPage/components/OrgCertManagerTab/CertManagerExportProjectModal.tsx
@@ -1,5 +1,5 @@
import { useEffect, useState } from "react";
-import { CheckCircle2Icon, InfoIcon } from "lucide-react";
+import { CheckCircle2Icon, CircleHelpIcon, InfoIcon } from "lucide-react";
import { createNotification } from "@app/components/notifications";
import {
@@ -11,20 +11,23 @@ import {
DialogDescription,
DialogFooter,
DialogHeader,
- DialogTitle
+ DialogTitle,
+ Tooltip,
+ TooltipContent,
+ TooltipTrigger
} from "@app/components/v3";
import { cn } from "@app/components/v3/utils";
import {
TCertManagerLegacyInstance,
- TMigrateCertManagerProjectResult,
- useMigrateCertManagerProject
+ TExportCertManagerProjectResult,
+ useExportCertManagerProject
} from "@app/hooks/api/certManagerInstance";
type Props = {
isOpen: boolean;
onOpenChange: (open: boolean) => void;
source: TCertManagerLegacyInstance | null;
- candidates: TCertManagerLegacyInstance[];
+ activeInstance: TCertManagerLegacyInstance | null;
};
const SummaryRow = ({ label, value, muted }: { label: string; value: number; muted?: boolean }) => (
@@ -39,11 +42,33 @@ const SummaryRow = ({ label, value, muted }: { label: string; value: number; mut
</div>
);
-const RenameList = ({ title, items }: { title: string; items: { from: string; to: string }[] }) => {
+const RenameList = ({
+ title,
+ tooltip,
+ items
+}: {
+ title: string;
+ tooltip: string;
+ items: { from: string; to: string }[];
+}) => {
if (items.length === 0) return null;
return (
<div className="flex flex-col gap-1">
- <div className="text-xs font-medium tracking-wide text-accent uppercase">{title}</div>
+ <div className="flex items-center gap-1.5 text-xs font-medium tracking-wide text-accent uppercase">
+ <span>{title}</span>
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <button
+ type="button"
+ aria-label={`About ${title}`}
+ className="text-accent transition-colors hover:text-foreground"
+ >
+ <CircleHelpIcon className="h-3.5 w-3.5" />
+ </button>
+ </TooltipTrigger>
+ <TooltipContent className="max-w-xs text-xs normal-case">{tooltip}</TooltipContent>
+ </Tooltip>
+ </div>
<ul className="flex flex-col gap-1 text-sm">
{items.map((item) => (
<li
@@ -60,46 +85,39 @@ const RenameList = ({ title, items }: { title: string; items: { from: string; to
);
};
-export const CertManagerMigrateProjectModal = ({
+export const CertManagerExportProjectModal = ({
isOpen,
onOpenChange,
source,
- candidates
+ activeInstance
}: Props) => {
- const [destinationId, setDestinationId] = useState<string | null>(null);
- const [result, setResult] = useState<TMigrateCertManagerProjectResult | null>(null);
- const migrate = useMigrateCertManagerProject();
+ const [result, setResult] = useState<TExportCertManagerProjectResult | null>(null);
+ const exportMutation = useExportCertManagerProject();
+ const { reset: resetMutation } = exportMutation;
useEffect(() => {
if (isOpen) {
- setDestinationId(null);
setResult(null);
+ resetMutation();
}
- }, [isOpen]);
+ }, [isOpen, resetMutation]);
- const availableDestinations = candidates.filter((c) => c.id !== source?.id);
-
- const handleMigrate = async () => {
- if (!source || !destinationId) return;
+ const handleExport = async () => {
+ if (!source) return;
try {
- const res = await migrate.mutateAsync({
- sourceProjectId: source.id,
- destinationProjectId: destinationId
- });
+ const res = await exportMutation.mutateAsync({ sourceProjectId: source.id });
setResult(res);
createNotification({
type: "success",
- text: `Migrated ${res.migratedCertificateAuthorities} CA(s), ${res.migratedCertificatePolicies} policy(ies), and ${res.migratedCertificateProfiles} profile(s).`
+ text: `Exported ${res.exportedCertificateAuthorities} CA(s), ${res.exportedCertificatePolicies} policy(ies), and ${res.exportedCertificateProfiles} profile(s).`
});
} catch (err) {
- const detail = err instanceof Error ? err.message : "Failed to migrate project.";
+ const detail = err instanceof Error ? err.message : "Failed to export project.";
createNotification({ type: "error", text: detail });
}
};
- const destination = destinationId
- ? availableDestinations.find((c) => c.id === destinationId)
- : null;
+ const canExport = Boolean(source && activeInstance && source.id !== activeInstance.id);
return (
<Dialog open={isOpen} onOpenChange={onOpenChange}>
@@ -109,30 +127,28 @@ export const CertManagerMigrateProjectModal = ({
<DialogHeader className="gap-4">
<DialogTitle className="flex items-center gap-2">
<CheckCircle2Icon className="h-5 w-5 text-success" />
- Migration complete
+ Export complete
</DialogTitle>
<DialogDescription>
- {source?.name} was duplicated into{" "}
- <span className="font-medium text-foreground">
- {destination?.name ?? "the destination project"}
- </span>
- . The source project was not modified.
+ <span className="font-medium text-foreground">{source?.name}</span> was exported
+ into the active instance{" "}
+ <span className="font-medium text-foreground">{activeInstance?.name ?? ""}</span>.
</DialogDescription>
</DialogHeader>
<div className="flex max-h-[60vh] flex-col gap-3 overflow-y-auto pr-1 text-sm">
<div className="flex flex-col gap-2">
<SummaryRow
- label="Certificate authorities migrated"
- value={result.migratedCertificateAuthorities}
+ label="Certificate authorities exported"
+ value={result.exportedCertificateAuthorities}
/>
<SummaryRow
- label="Certificate policies migrated"
- value={result.migratedCertificatePolicies}
+ label="Certificate policies exported"
+ value={result.exportedCertificatePolicies}
/>
<SummaryRow
- label="Certificate profiles migrated"
- value={result.migratedCertificateProfiles}
+ label="Certificate profiles exported"
+ value={result.exportedCertificateProfiles}
/>
{result.skippedCertificateProfiles > 0 && (
<SummaryRow
@@ -145,6 +161,7 @@ export const CertManagerMigrateProjectModal = ({
<RenameList
title="Certificate authorities renamed (name conflicts)"
+ tooltip="A certificate authority with this name already exists in the active instance. Certificate authority names must be unique within a project, so the exported copy was assigned a new, unique name to avoid the collision."
items={result.renamedCertificateAuthorities.map((r) => ({
from: r.originalName,
to: r.newName
@@ -152,6 +169,7 @@ export const CertManagerMigrateProjectModal = ({
/>
<RenameList
title="Policies renamed (name conflicts)"
+ tooltip="A certificate policy with this name already exists in the active instance. Certificate policy names must be unique within a project, so the exported copy was assigned a new, unique name to avoid the collision."
items={result.renamedCertificatePolicies.map((r) => ({
from: r.originalName,
to: r.newName
@@ -159,6 +177,7 @@ export const CertManagerMigrateProjectModal = ({
/>
<RenameList
title="Profiles renamed (slug conflicts)"
+ tooltip="A certificate profile with this slug already exists in the active instance. Certificate profile slugs must be unique within a project, so the exported copy was assigned a new, unique slug to avoid the collision."
items={result.renamedCertificateProfiles.map((r) => ({
from: r.originalSlug,
to: r.newSlug
@@ -175,74 +194,49 @@ export const CertManagerMigrateProjectModal = ({
) : (
<>
<DialogHeader className="gap-4">
- <DialogTitle>Migrate Certificate Manager project</DialogTitle>
+ <DialogTitle>Export Certificate Manager project</DialogTitle>
<DialogDescription>
- Duplicate all internal CAs, certificate policies, and certificate profiles from{" "}
- <span className="font-medium text-foreground">
- {source?.name ?? "this project"}
- </span>{" "}
- into another Certificate Manager project. The source project is not modified.
+ {activeInstance ? (
+ <>
+ This will duplicate every internal certificate authority, certificate policy,
+ and certificate profile from{" "}
+ <span className="font-medium text-foreground">{source?.name}</span> into your
+ organization&apos;s active Certificate Manager instance,{" "}
+ <span className="font-medium text-foreground">{activeInstance.name}</span>.
+ Existing resources in{" "}
+ <span className="font-medium text-foreground">{source?.name}</span> are not
+ removed by this export, but as it is scheduled for retirement, all subsequent
+ work should be performed in the active instance.
+ </>
+ ) : (
+ <>
+ No active Certificate Manager instance is configured for this organization. An
+ organization administrator must designate an active instance before any export
+ can be performed.
+ </>
+ )}
</DialogDescription>
</DialogHeader>
<Alert variant="info">
<InfoIcon />
<AlertDescription>
- External CAs and certificates are not migrated. Profiles using an external CA are
- skipped.
+ External certificate authorities are not included in this export. Any profile bound
+ to one is skipped.
</AlertDescription>
</Alert>
- <div className="flex flex-col gap-2">
- <div className="text-xs font-medium tracking-wide text-accent uppercase">
- Destination project
- </div>
- <div className="flex max-h-[40vh] flex-col gap-1 overflow-y-auto rounded-sm border border-border bg-mineshaft-800/30 p-1">
- {availableDestinations.length === 0 ? (
- <div className="px-3 py-4 text-center text-sm text-accent">
- No other Certificate Manager projects in this organization.
- </div>
- ) : (
- availableDestinations.map((c) => {
- const isPicked = c.id === destinationId;
- return (
- <button
- key={c.id}
- type="button"
- onClick={() => setDestinationId(c.id)}
- className={cn(
- "flex w-full items-center justify-between gap-3 rounded-sm border border-transparent px-3 py-2 text-left transition-colors",
- "hover:border-product-pki/30 hover:bg-product-pki/[0.06]",
- isPicked && "border-product-pki/40 bg-product-pki/[0.08]"
- )}
- >
- <div className="min-w-0">
- <div className="truncate text-sm font-medium text-foreground">
- {c.name}
- </div>
- <div className="truncate font-mono text-xs text-accent">{c.slug}</div>
- </div>
- {isPicked && (
- <CheckCircle2Icon className="h-4 w-4 shrink-0 text-product-pki" />
- )}
- </button>
- );
- })
- )}
- </div>
- </div>
-
<DialogFooter>
<Button variant="ghost" onClick={() => onOpenChange(false)}>
Cancel
</Button>
<Button
variant="project"
- isPending={migrate.isPending}
- isDisabled={!destinationId || availableDestinations.length === 0}
- onClick={handleMigrate}
+ isPending={exportMutation.isPending}
+ isDisabled={!canExport}
+ onClick={handleExport}
>
- Migrate
+ Export
</Button>
</DialogFooter>
</>
diff --git a/frontend/src/pages/organization/SettingsPage/components/OrgCertManagerTab/OrgCertManagerTab.tsx b/frontend/src/pages/organization/SettingsPage/components/OrgCertManagerTab/OrgCertManagerTab.tsx
index c963a06dfb..f1001fc589 100644
--- a/frontend/src/pages/organization/SettingsPage/components/OrgCertManagerTab/OrgCertManagerTab.tsx
+++ b/frontend/src/pages/organization/SettingsPage/components/OrgCertManagerTab/OrgCertManagerTab.tsx
@@ -1,12 +1,12 @@
import { useEffect, useState } from "react";
import { useQueryClient } from "@tanstack/react-query";
import {
- ArrowRightLeftIcon,
BoxIcon,
MoreHorizontalIcon,
StarIcon,
Trash2Icon,
- TriangleAlertIcon
+ TriangleAlertIcon,
+ UploadIcon
} from "lucide-react";
import { createNotification } from "@app/components/notifications";
@@ -50,7 +50,7 @@ import {
} from "@app/hooks/api/certManagerInstance";
import { useDeleteWorkspace } from "@app/hooks/api/projects";
-import { CertManagerMigrateProjectModal } from "./CertManagerMigrateProjectModal";
+import { CertManagerExportProjectModal } from "./CertManagerExportProjectModal";
export const OrgCertManagerTab = () => {
const queryClient = useQueryClient();
@@ -70,7 +70,9 @@ export const OrgCertManagerTab = () => {
const [pendingActive, setPendingActive] = useState<TCertManagerLegacyInstance | null>(null);
const [pendingDelete, setPendingDelete] = useState<TCertManagerLegacyInstance | null>(null);
- const [pendingMigrate, setPendingMigrate] = useState<TCertManagerLegacyInstance | null>(null);
+ const [pendingExport, setPendingExport] = useState<TCertManagerLegacyInstance | null>(null);
+
+ const activeInstance = instances.find((i) => i.isActive) ?? null;
useEffect(() => {
if (pendingDelete && !instances.find((i) => i.id === pendingDelete.id)) {
@@ -79,10 +81,10 @@ export const OrgCertManagerTab = () => {
if (pendingActive && !instances.find((i) => i.id === pendingActive.id)) {
setPendingActive(null);
}
- if (pendingMigrate && !instances.find((i) => i.id === pendingMigrate.id)) {
- setPendingMigrate(null);
+ if (pendingExport && !instances.find((i) => i.id === pendingExport.id)) {
+ setPendingExport(null);
}
- }, [instances, pendingDelete, pendingActive, pendingMigrate]);
+ }, [instances, pendingDelete, pendingActive, pendingExport]);
if (isPending) {
return (
@@ -149,7 +151,7 @@ export const OrgCertManagerTab = () => {
rel="noopener noreferrer"
className="underline hover:text-mineshaft-200"
>
- Migration guide
+ Deprecation guide
</a>
</AlertDescription>
</Alert>
@@ -176,7 +178,7 @@ export const OrgCertManagerTab = () => {
{instance.isActive ? <Badge variant="success">Active</Badge> : null}
</TableCell>
<TableCell>
- {canManage ? (
+ {canManage && !instance.isActive ? (
<DropdownMenu>
<DropdownMenuTrigger asChild>
<IconButton variant="ghost" size="xs" aria-label={`Manage ${instance.name}`}>
@@ -184,25 +186,18 @@ export const OrgCertManagerTab = () => {
</IconButton>
</DropdownMenuTrigger>
<DropdownMenuContent className="min-w-56" align="end" sideOffset={2}>
- <DropdownMenuItem onClick={() => setPendingMigrate(instance)}>
- <ArrowRightLeftIcon />
- Migrate entities
+ <DropdownMenuItem onClick={() => setPendingExport(instance)}>
+ <UploadIcon />
+ Export to active instance
+ </DropdownMenuItem>
+ <DropdownMenuItem onClick={() => setPendingActive(instance)}>
+ <StarIcon />
+ Set as active
+ </DropdownMenuItem>
+ <DropdownMenuItem variant="danger" onClick={() => setPendingDelete(instance)}>
+ <Trash2Icon />
+ Delete project
</DropdownMenuItem>
- {!instance.isActive && (
- <DropdownMenuItem onClick={() => setPendingActive(instance)}>
- <StarIcon />
- Set as active
- </DropdownMenuItem>
- )}
- {!instance.isActive && (
- <DropdownMenuItem
- variant="danger"
- onClick={() => setPendingDelete(instance)}
- >
- <Trash2Icon />
- Delete project
- </DropdownMenuItem>
- )}
</DropdownMenuContent>
</DropdownMenu>
) : null}
@@ -260,13 +255,13 @@ export const OrgCertManagerTab = () => {
buttonText="Delete project"
/>
- <CertManagerMigrateProjectModal
- isOpen={Boolean(pendingMigrate)}
+ <CertManagerExportProjectModal
+ isOpen={Boolean(pendingExport)}
onOpenChange={(open) => {
- if (!open) setPendingMigrate(null);
+ if (!open) setPendingExport(null);
}}
- source={pendingMigrate}
- candidates={instances}
+ source={pendingExport}
+ activeInstance={activeInstance}
/>
</div>
);