Skip to content

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

UI improvements on PKI

Carlos Monastyrskibe5efae25655
diff --git a/backend/src/db/migrations/20260504432352_cert-manager-applications.ts b/backend/src/db/migrations/20260504432352_cert-manager-applications.ts
index fb53288412..5af05c9e0f 100644
--- a/backend/src/db/migrations/20260504432352_cert-manager-applications.ts
+++ b/backend/src/db/migrations/20260504432352_cert-manager-applications.ts
@@ -1,8 +1,90 @@
+import slugify from "@sindresorhus/slugify";
import { Knex } from "knex";
+import { alphaNumericNanoId } from "@app/lib/nanoid";
+
import { TableName } from "../schemas";
import { createOnUpdateTrigger, dropOnUpdateTrigger } from "../utils";
+const ACCESS_SCOPE_PROJECT = "project";
+const ACCESS_SCOPE_ORGANIZATION = "organization";
+const PROJECT_TYPE_CERT_MANAGER = "cert-manager";
+const PROJECT_VERSION_V3 = 3;
+const PROJECT_MEMBERSHIP_ROLE_ADMIN = "admin";
+const ORG_MEMBERSHIP_ROLE_ADMIN = "admin";
+const ORG_MEMBERSHIP_ROLE_OWNER = "owner";
+const PIT_VERSION_LIMIT_DEFAULT = 10;
+
+const BACKFILL_CHUNK_SIZE = 8;
+
+const backfillOrgCertManagerProject = async (knex: Knex, orgId: string) => {
+ await knex.transaction(async (tx) => {
+ const slug = slugify(`cert-manager-${alphaNumericNanoId(4)}`);
+
+ const [{ id: projectId }] = (await tx(TableName.Project)
+ .insert({
+ name: "Certificate Manager",
+ slug,
+ type: PROJECT_TYPE_CERT_MANAGER,
+ orgId,
+ version: PROJECT_VERSION_V3,
+ pitVersionLimit: PIT_VERSION_LIMIT_DEFAULT
+ })
+ .returning("id")) as Array<{ id: string }>;
+
+ // Promote every existing org admin / owner to project admin so they can manage the new project.
+ const orgAdminMemberships = (await tx(TableName.Membership)
+ .join(TableName.MembershipRole, `${TableName.MembershipRole}.membershipId`, `${TableName.Membership}.id`)
+ .where(`${TableName.Membership}.scope`, ACCESS_SCOPE_ORGANIZATION)
+ .where(`${TableName.Membership}.scopeOrgId`, orgId)
+ .whereNotNull(`${TableName.Membership}.actorUserId`)
+ .whereIn(`${TableName.MembershipRole}.role`, [ORG_MEMBERSHIP_ROLE_ADMIN, ORG_MEMBERSHIP_ROLE_OWNER])
+ .distinct(`${TableName.Membership}.actorUserId as actorUserId`)) as Array<{ actorUserId: string }>;
+
+ if (orgAdminMemberships.length === 0) return;
+
+ const insertedMemberships = (await tx(TableName.Membership)
+ .insert(
+ orgAdminMemberships.map((m) => ({
+ scope: ACCESS_SCOPE_PROJECT,
+ scopeOrgId: orgId,
+ scopeProjectId: projectId,
+ actorUserId: m.actorUserId,
+ isActive: true
+ }))
+ )
+ .returning("id")) as Array<{ id: string }>;
+
+ await tx(TableName.MembershipRole).insert(
+ insertedMemberships.map(({ id: membershipId }) => ({
+ membershipId,
+ role: PROJECT_MEMBERSHIP_ROLE_ADMIN
+ }))
+ );
+ });
+};
+
+const backfillCertManagerProjectsForExistingOrgs = async (knex: Knex) => {
+ const orgsMissingCertManager = (await knex(TableName.Organization)
+ .leftJoin(TableName.Project, function joinProject() {
+ this.on(`${TableName.Project}.orgId`, "=", `${TableName.Organization}.id`).andOn(
+ `${TableName.Project}.type`,
+ "=",
+ knex.raw("?", [PROJECT_TYPE_CERT_MANAGER])
+ );
+ })
+ .whereNull(`${TableName.Project}.id`)
+ .select(`${TableName.Organization}.id`)) as Array<{ id: string }>;
+
+ // Process orgs in chunks so the DB pool isn't saturated. Each chunk runs its
+ // org transactions in parallel; chunks themselves run sequentially.
+ for (let i = 0; i < orgsMissingCertManager.length; i += BACKFILL_CHUNK_SIZE) {
+ const chunk = orgsMissingCertManager.slice(i, i + BACKFILL_CHUNK_SIZE);
+ // eslint-disable-next-line no-await-in-loop
+ await Promise.all(chunk.map(({ id }) => backfillOrgCertManagerProject(knex, id)));
+ }
+};
+
export async function up(knex: Knex): Promise<void> {
if (!(await knex.schema.hasColumn(TableName.Organization, "defaultCertManagerProjectId"))) {
await knex.schema.alterTable(TableName.Organization, (t) => {
@@ -139,9 +221,47 @@ export async function up(knex: Knex): Promise<void> {
t.index("applicationId");
});
}
+
+ if (!(await knex.schema.hasColumn(TableName.CertificateInventoryView, "applicationId"))) {
+ await knex.schema.alterTable(TableName.CertificateInventoryView, (t) => {
+ t.uuid("applicationId").nullable();
+ t.foreign("applicationId").references("id").inTable(TableName.PkiApplication).onDelete("CASCADE");
+ t.index(["projectId", "applicationId"]);
+ });
+
+ await knex.raw(`DROP INDEX IF EXISTS "cert_inv_view_personal_unique"`);
+ await knex.raw(`DROP INDEX IF EXISTS "cert_inv_view_shared_unique"`);
+
+ await knex.raw(
+ `CREATE UNIQUE INDEX "cert_inv_view_personal_unique" ON "${TableName.CertificateInventoryView}" ("projectId", COALESCE("applicationId"::text, ''), "name", "createdByUserId") WHERE "isShared" = false`
+ );
+ await knex.raw(
+ `CREATE UNIQUE INDEX "cert_inv_view_shared_unique" ON "${TableName.CertificateInventoryView}" ("projectId", COALESCE("applicationId"::text, ''), "name") WHERE "isShared" = true`
+ );
+ }
+
+ await backfillCertManagerProjectsForExistingOrgs(knex);
}
export async function down(knex: Knex): Promise<void> {
+ if (await knex.schema.hasColumn(TableName.CertificateInventoryView, "applicationId")) {
+ await knex.raw(`DROP INDEX IF EXISTS "cert_inv_view_personal_unique"`);
+ await knex.raw(`DROP INDEX IF EXISTS "cert_inv_view_shared_unique"`);
+
+ await knex.schema.alterTable(TableName.CertificateInventoryView, (t) => {
+ t.dropForeign(["applicationId"]);
+ t.dropIndex(["projectId", "applicationId"]);
+ t.dropColumn("applicationId");
+ });
+
+ await knex.raw(
+ `CREATE UNIQUE INDEX "cert_inv_view_personal_unique" ON "${TableName.CertificateInventoryView}" ("projectId", "name", "createdByUserId") WHERE "isShared" = false`
+ );
+ await knex.raw(
+ `CREATE UNIQUE INDEX "cert_inv_view_shared_unique" ON "${TableName.CertificateInventoryView}" ("projectId", "name") WHERE "isShared" = true`
+ );
+ }
+
if (await knex.schema.hasColumn(TableName.PkiScepTransaction, "applicationId")) {
await knex.schema.alterTable(TableName.PkiScepTransaction, (t) => {
t.dropForeign(["applicationId"]);
diff --git a/backend/src/db/schemas/certificate-inventory-views.ts b/backend/src/db/schemas/certificate-inventory-views.ts
index d500d35bb6..e17846e5b5 100644
--- a/backend/src/db/schemas/certificate-inventory-views.ts
+++ b/backend/src/db/schemas/certificate-inventory-views.ts
@@ -16,7 +16,8 @@ export const CertificateInventoryViewsSchema = z.object({
createdByUserId: z.string().uuid().nullable().optional(),
createdAt: z.date(),
updatedAt: z.date(),
- isShared: z.boolean().default(false)
+ isShared: z.boolean().default(false),
+ applicationId: z.string().uuid().nullable().optional()
});
export type TCertificateInventoryViews = z.infer<typeof CertificateInventoryViewsSchema>;
diff --git a/backend/src/ee/routes/scep/pki-scep-router.ts b/backend/src/ee/routes/scep/pki-scep-router.ts
index 8838bc12dc..e855918608 100644
--- a/backend/src/ee/routes/scep/pki-scep-router.ts
+++ b/backend/src/ee/routes/scep/pki-scep-router.ts
@@ -159,6 +159,50 @@ export const registerPkiScepRouter = async (server: FastifyZodProvider) => {
}
});
+ server.route({
+ method: "POST",
+ url: "/applications/:applicationId/profiles/:profileId/challenge",
+ config: {
+ rateLimit: writeLimit
+ },
+ schema: {
+ params: z.object({
+ applicationId: z.string().uuid(),
+ profileId: z.string().uuid()
+ })
+ },
+ onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),
+ handler: async (req, res) => {
+ const { applicationId, profileId } = req.params;
+
+ const result = await server.services.pkiScep.generateDynamicChallenge({
+ profileId,
+ applicationId,
+ actor: req.permission.type,
+ actorId: req.permission.id,
+ actorAuthMethod: req.permission.authMethod,
+ actorOrgId: req.permission.orgId
+ });
+
+ void server.services.auditLog.createAuditLog({
+ ...req.auditLogInfo,
+ projectId: result.projectId,
+ event: {
+ type: EventType.SCEP_DYNAMIC_CHALLENGE_GENERATED,
+ metadata: {
+ profileId,
+ profileSlug: result.profileSlug,
+ expiresAt: result.expiresAt,
+ applicationId
+ }
+ }
+ });
+
+ void res.header("Content-Type", "text/plain");
+ return res.send(result.challenge);
+ }
+ });
+
server.route({
method: "GET",
url: "/applications/:applicationId/profiles/:profileId/pkiclient.exe",
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 ba9152fde8..6fe1c3de25 100644
--- a/backend/src/ee/services/audit-log/audit-log-types.ts
+++ b/backend/src/ee/services/audit-log/audit-log-types.ts
@@ -6377,6 +6377,7 @@ interface ScepDynamicChallengeGeneratedEvent {
profileId: string;
profileSlug: string;
expiresAt: string;
+ applicationId?: string;
};
}
diff --git a/backend/src/ee/services/pki-scep/pki-scep-service.ts b/backend/src/ee/services/pki-scep/pki-scep-service.ts
index 1713570429..6a10a134f6 100644
--- a/backend/src/ee/services/pki-scep/pki-scep-service.ts
+++ b/backend/src/ee/services/pki-scep/pki-scep-service.ts
@@ -2,12 +2,16 @@ import { ForbiddenError, subject } from "@casl/ability";
import * as x509 from "@peculiar/x509";
import { randomBytes } from "crypto";
-import { ActionProjectType } from "@app/db/schemas";
+import { ActionProjectType, ResourceType } from "@app/db/schemas";
import { TPermissionServiceFactory } from "@app/ee/services/permission/permission-service-types";
import {
ProjectPermissionCertificateProfileActions,
ProjectPermissionSub
} from "@app/ee/services/permission/project-permission";
+import {
+ ResourcePermissionApplicationEnrollmentActions,
+ ResourcePermissionSub
+} from "@app/ee/services/permission/resource-permission";
import { extractX509CertFromChain } from "@app/lib/certificates/extract-certificate";
import { crypto } from "@app/lib/crypto/cryptography";
import { BadRequestError, NotFoundError } from "@app/lib/errors";
@@ -76,7 +80,7 @@ type TPkiScepServiceFactoryDep = {
certificateRequestService: Pick<TCertificateRequestServiceFactory, "createCertificateRequest">;
certificateIssuanceQueue: Pick<TCertificateIssuanceQueueFactory, "queueCertificateIssuance">;
auditLogService: Pick<TAuditLogServiceFactory, "createAuditLog">;
- permissionService: Pick<TPermissionServiceFactory, "getProjectPermission">;
+ permissionService: Pick<TPermissionServiceFactory, "getProjectPermission" | "getResourcePermission">;
pkiApplicationProfileDAL?: Pick<TPkiApplicationProfileDALFactory, "findOne">;
};
@@ -909,6 +913,7 @@ export const pkiScepServiceFactory = ({
const generateDynamicChallenge = async ({
profileId,
+ applicationId,
actor,
actorId,
actorAuthMethod,
@@ -919,24 +924,57 @@ export const pkiScepServiceFactory = ({
throw new NotFoundError({ message: "SCEP profile not found" });
}
- const { permission } = await permissionService.getProjectPermission({
- actor,
- actorId,
- projectId: profile.projectId,
- actorAuthMethod,
- actorOrgId,
- actionProjectType: ActionProjectType.CertificateManager
- });
- ForbiddenError.from(permission).throwUnlessCan(
- ProjectPermissionCertificateProfileActions.Edit,
- subject(ProjectPermissionSub.CertificateProfiles, { slug: profile.slug })
- );
+ let resolvedScepConfigId: string | null = null;
+ if (applicationId) {
+ if (!pkiApplicationProfileDAL) {
+ throw new BadRequestError({ message: "Application context is not supported on this server." });
+ }
+ const junction = await pkiApplicationProfileDAL.findOne(applicationId, profileId);
+ if (!junction) {
+ throw new NotFoundError({
+ message: `Profile '${profileId}' is not attached to application '${applicationId}'.`
+ });
+ }
+ resolvedScepConfigId = junction.scepConfigId ?? null;
- if (!profile.scepConfigId) {
- throw new BadRequestError({ message: "SCEP enrollment not configured for this profile" });
+ const { permission } = await permissionService.getResourcePermission({
+ actor,
+ actorId,
+ projectId: profile.projectId,
+ resourceType: ResourceType.CertificateApplication,
+ resourceId: applicationId,
+ actorAuthMethod,
+ actorOrgId
+ });
+ ForbiddenError.from(permission).throwUnlessCan(
+ ResourcePermissionApplicationEnrollmentActions.Edit,
+ ResourcePermissionSub.ApplicationEnrollment
+ );
+ } else {
+ resolvedScepConfigId = profile.scepConfigId ?? null;
+ const { permission } = await permissionService.getProjectPermission({
+ actor,
+ actorId,
+ projectId: profile.projectId,
+ actorAuthMethod,
+ actorOrgId,
+ actionProjectType: ActionProjectType.CertificateManager
+ });
+ ForbiddenError.from(permission).throwUnlessCan(
+ ProjectPermissionCertificateProfileActions.Edit,
+ subject(ProjectPermissionSub.CertificateProfiles, { slug: profile.slug })
+ );
}
- const scepConfig = await scepEnrollmentConfigDAL.findById(profile.scepConfigId);
+ if (!resolvedScepConfigId) {
+ throw new BadRequestError({
+ message: applicationId
+ ? "SCEP enrollment is not configured for this profile on the Application."
+ : "SCEP enrollment not configured for this profile"
+ });
+ }
+
+ const scepConfig = await scepEnrollmentConfigDAL.findById(resolvedScepConfigId);
if (!scepConfig) {
throw new NotFoundError({ message: "SCEP configuration not found" });
}
diff --git a/backend/src/ee/services/pki-scep/pki-scep-types.ts b/backend/src/ee/services/pki-scep/pki-scep-types.ts
index 6c49f943e7..57897cfb69 100644
--- a/backend/src/ee/services/pki-scep/pki-scep-types.ts
+++ b/backend/src/ee/services/pki-scep/pki-scep-types.ts
@@ -71,6 +71,7 @@ export type THandlePkiOperationDTO = {
export type TGenerateDynamicChallengeDTO = {
profileId: string;
+ applicationId?: string;
actor: ActorType;
actorId: string;
actorAuthMethod: ActorAuthMethod;
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 e7f4d5d20b..8af268bbb1 100644
--- a/backend/src/server/plugins/inject-cert-manager-project-id.ts
+++ b/backend/src/server/plugins/inject-cert-manager-project-id.ts
@@ -1,6 +1,8 @@
import { FastifyPluginAsync } from "fastify";
import fp from "fastify-plugin";
+const CERT_MANAGER_PREFIXES = ["/api/v1/cert-manager/", "/api/v1/pki/", "/api/v2/pki/"];
+
export const injectCertManagerProjectId: FastifyPluginAsync = fp(async (server) => {
server.decorateRequest("certManagerProjectId", "");
@@ -8,6 +10,8 @@ export const injectCertManagerProjectId: FastifyPluginAsync = fp(async (server)
if (!req.permission?.orgId) return;
const routePath = req.routerPath ?? "";
+ if (!CERT_MANAGER_PREFIXES.some((prefix) => routePath.startsWith(prefix))) return;
+
if (routePath === "/api/v1/cert-manager/instance" || routePath.startsWith("/api/v1/cert-manager/instance/")) {
return;
}
diff --git a/backend/src/server/routes/v1/certificate-inventory-view-router.ts b/backend/src/server/routes/v1/certificate-inventory-view-router.ts
index 80b4896e39..63faa598e6 100644
--- a/backend/src/server/routes/v1/certificate-inventory-view-router.ts
+++ b/backend/src/server/routes/v1/certificate-inventory-view-router.ts
@@ -51,6 +51,9 @@ export const registerCertificateInventoryViewRouter = async (server: FastifyZodP
operationId: "listCertificateInventoryViews",
tags: [ApiDocsTags.PkiCertificates],
description: "List system and custom certificate inventory views for a project.",
+ querystring: z.object({
+ applicationId: z.string().uuid().optional()
+ }),
response: {
200: z.object({
systemViews: z.array(
@@ -85,6 +88,7 @@ export const registerCertificateInventoryViewRouter = async (server: FastifyZodP
handler: async (req) => {
return server.services.certificateInventoryView.listViews({
projectId: req.certManagerProjectId,
+ applicationId: req.query.applicationId,
actorId: req.permission.id,
actorOrgId: req.permission.orgId,
actorAuthMethod: req.permission.authMethod,
@@ -108,7 +112,8 @@ export const registerCertificateInventoryViewRouter = async (server: FastifyZodP
name: z.string().trim().min(1).max(255),
filters: InventoryViewFiltersSchema.default({}),
columns: ColumnsSchema.optional(),
- isShared: z.boolean().default(false).optional()
+ isShared: z.boolean().default(false).optional(),
+ applicationId: z.string().uuid().optional()
}),
response: {
200: z.object({
@@ -120,6 +125,7 @@ export const registerCertificateInventoryViewRouter = async (server: FastifyZodP
handler: async (req) => {
const view = await server.services.certificateInventoryView.createView({
projectId: req.certManagerProjectId,
+ applicationId: req.body.applicationId,
name: req.body.name,
filters: req.body.filters,
columns: req.body.columns,
diff --git a/backend/src/server/routes/v1/certificate-router.ts b/backend/src/server/routes/v1/certificate-router.ts
index 74913b3a41..df4e77178d 100644
--- a/backend/src/server/routes/v1/certificate-router.ts
+++ b/backend/src/server/routes/v1/certificate-router.ts
@@ -628,6 +628,11 @@ export const registerCertificateRouter = async (server: FastifyZodProvider) => {
fromDate: z.coerce.date().optional(),
toDate: z.coerce.date().optional(),
profileIds: z.array(z.string().uuid()).optional(),
+ applicationId: z
+ .string()
+ .uuid()
+ .optional()
+ .describe("Filter to certificate requests for profiles attached to a specific Application."),
sortBy: z.string().trim().optional(),
sortOrder: z.enum(["asc", "desc"]).optional(),
metadata: z
@@ -686,6 +691,7 @@ export const registerCertificateRouter = async (server: FastifyZodProvider) => {
fromDate: filters.fromDate,
toDate: filters.toDate,
profileIds: filters.profileIds,
+ applicationId: filters.applicationId,
sortBy: filters.sortBy,
sortOrder: filters.sortOrder,
metadataFilter: metadata
diff --git a/backend/src/server/routes/v1/pki-application-enrollment-router.ts b/backend/src/server/routes/v1/pki-application-enrollment-router.ts
index a7dacb4cfc..211bd79247 100644
--- a/backend/src/server/routes/v1/pki-application-enrollment-router.ts
+++ b/backend/src/server/routes/v1/pki-application-enrollment-router.ts
@@ -15,13 +15,15 @@ const ApiEnrollmentSchema = z.object({
const EstEnrollmentStateSchema = z.object({
id: z.string().uuid(),
- disableBootstrapCaValidation: z.boolean()
+ disableBootstrapCaValidation: z.boolean(),
+ estEndpointUrl: z.string()
});
const AcmeEnrollmentStateSchema = z.object({
id: z.string().uuid(),
skipDnsOwnershipVerification: z.boolean(),
- skipEabBinding: z.boolean()
+ skipEabBinding: z.boolean(),
+ directoryUrl: z.string()
});
const ScepEnrollmentStateSchema = z.object({
@@ -30,7 +32,11 @@ const ScepEnrollmentStateSchema = z.object({
includeCaCertInResponse: z.boolean(),
allowCertBasedRenewal: z.boolean(),
dynamicChallengeExpiryMinutes: z.number().int().nullable(),
- dynamicChallengeMaxPending: z.number().int().nullable()
+ dynamicChallengeMaxPending: z.number().int().nullable(),
+ scepEndpointUrl: z.string(),
+ challengeEndpointUrl: z.string().nullable(),
+ raCertificatePem: z.string(),
+ raCertExpiresAt: z.date()
});
const EnrollmentStateSchema = z.object({
diff --git a/backend/src/server/routes/v1/project-router.ts b/backend/src/server/routes/v1/project-router.ts
index 8e89d59ea6..90fb9537c5 100644
--- a/backend/src/server/routes/v1/project-router.ts
+++ b/backend/src/server/routes/v1/project-router.ts
@@ -25,7 +25,6 @@ import { loginMappingSchema, sanitizedSshHost } from "@app/ee/services/ssh-host/
import { LoginMappingSource } from "@app/ee/services/ssh-host/ssh-host-types";
import { sanitizedSshHostGroup } from "@app/ee/services/ssh-host-group/ssh-host-group-schema";
import { ApiDocsTags, PROJECTS } from "@app/lib/api-docs";
-import { BadRequestError } from "@app/lib/errors";
import { CharacterType, characterValidator } from "@app/lib/validator/validate-string";
import { re2Validator } from "@app/lib/zod";
import { projectCreationLimit, readLimit, requestAccessLimit, writeLimit } from "@app/server/config/rateLimiter";
@@ -174,13 +173,6 @@ export const registerProjectRouter = async (server: FastifyZodProvider) => {
},
onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),
handler: async (req) => {
- if (req.body.type === ProjectType.CertificateManager) {
- throw new BadRequestError({
- message:
- "Cert Manager is a single-instance product per organization and cannot be created via this endpoint. The Cert Manager project is auto-provisioned at organization creation."
- });
- }
-
const project = await server.services.project.createProject({
actorId: req.permission.id,
actor: req.permission.type,
diff --git a/backend/src/services/certificate-inventory-view/certificate-inventory-view-dal.ts b/backend/src/services/certificate-inventory-view/certificate-inventory-view-dal.ts
index be3b128301..b9ea2bd5a9 100644
--- a/backend/src/services/certificate-inventory-view/certificate-inventory-view-dal.ts
+++ b/backend/src/services/certificate-inventory-view/certificate-inventory-view-dal.ts
@@ -8,11 +8,22 @@ export type TCertificateInventoryViewDALFactory = ReturnType<typeof certificateI
export const certificateInventoryViewDALFactory = (db: TDbClient) => {
const orm = ormify(db, TableName.CertificateInventoryView);
- const findByProjectId = async (projectId: string, userId?: string): Promise<TCertificateInventoryViews[]> => {
+ const findByProjectId = async (
+ projectId: string,
+ userId?: string,
+ applicationId?: string | null
+ ): Promise<TCertificateInventoryViews[]> => {
try {
const query = db
.replicaNode()(TableName.CertificateInventoryView)
.where({ projectId })
+ .andWhere((scopeQb) => {
+ if (applicationId) {
+ void scopeQb.where({ applicationId });
+ } else {
+ void scopeQb.whereNull("applicationId");
+ }
+ })
.andWhere((qb) => {
void qb.where({ isShared: true });
if (userId) {
diff --git a/backend/src/services/certificate-inventory-view/certificate-inventory-view-service.ts b/backend/src/services/certificate-inventory-view/certificate-inventory-view-service.ts
index a131ef93df..fd373fc8f1 100644
--- a/backend/src/services/certificate-inventory-view/certificate-inventory-view-service.ts
+++ b/backend/src/services/certificate-inventory-view/certificate-inventory-view-service.ts
@@ -111,10 +111,17 @@ export const certificateInventoryViewServiceFactory = ({
return permission;
};
- const listViews = async ({ projectId, actor, actorId, actorOrgId, actorAuthMethod }: TListInventoryViewsDTO) => {
+ const listViews = async ({
+ projectId,
+ applicationId,
+ actor,
+ actorId,
+ actorOrgId,
+ actorAuthMethod
+ }: TListInventoryViewsDTO) => {
await checkProjectPermission({ projectId, actor, actorId, actorOrgId, actorAuthMethod });
- const allViews = await certificateInventoryViewDAL.findByProjectId(projectId, actorId);
+ const allViews = await certificateInventoryViewDAL.findByProjectId(projectId, actorId, applicationId);
const sharedViews = allViews.filter((v) => v.isShared);
const customViews = allViews.filter((v) => !v.isShared);
@@ -136,6 +143,7 @@ export const certificateInventoryViewServiceFactory = ({
const createView = async ({
projectId,
+ applicationId,
name,
filters,
columns,
@@ -153,6 +161,7 @@ export const certificateInventoryViewServiceFactory = ({
try {
const view = await certificateInventoryViewDAL.create({
projectId,
+ applicationId: applicationId ?? null,
name,
filters: JSON.stringify(filters),
columns: columns ? JSON.stringify(columns) : undefined,
diff --git a/backend/src/services/certificate-inventory-view/certificate-inventory-view-types.ts b/backend/src/services/certificate-inventory-view/certificate-inventory-view-types.ts
index a5b941505e..b976c83d89 100644
--- a/backend/src/services/certificate-inventory-view/certificate-inventory-view-types.ts
+++ b/backend/src/services/certificate-inventory-view/certificate-inventory-view-types.ts
@@ -16,10 +16,12 @@ export type TInventoryViewFilters = {
export type TListInventoryViewsDTO = {
projectId: string;
+ applicationId?: string;
} & Omit<TProjectPermission, "projectId">;
export type TCreateInventoryViewDTO = {
projectId: string;
+ applicationId?: string;
name: string;
filters: TInventoryViewFilters;
columns?: string[];
diff --git a/backend/src/services/certificate-request/certificate-request-dal.ts b/backend/src/services/certificate-request/certificate-request-dal.ts
index 6694e12311..d492ea2efc 100644
--- a/backend/src/services/certificate-request/certificate-request-dal.ts
+++ b/backend/src/services/certificate-request/certificate-request-dal.ts
@@ -126,13 +126,24 @@ export const certificateRequestDALFactory = (db: TDbClient) => {
fromDate?: Date;
toDate?: Date;
profileIds?: string[];
+ applicationId?: string;
metadataFilter?: Array<{ key: string; value?: string }>;
} = {},
processedRules?: ProcessedPermissionRules,
tx?: Knex
): Promise<TCertificateRequests[]> => {
try {
- const { offset = 0, limit = 20, search, status, fromDate, toDate, profileIds, metadataFilter } = options;
+ const {
+ offset = 0,
+ limit = 20,
+ search,
+ status,
+ fromDate,
+ toDate,
+ profileIds,
+ applicationId,
+ metadataFilter
+ } = options;
let query = (tx || db)(TableName.CertificateRequests)
.leftJoin(
@@ -146,6 +157,13 @@ export const certificateRequestDALFactory = (db: TDbClient) => {
query = query.whereIn(`${TableName.CertificateRequests}.profileId`, profileIds);
}
+ if (applicationId) {
+ query = query.whereIn(
+ `${TableName.CertificateRequests}.profileId`,
+ (tx || db)(TableName.PkiApplicationProfile).select("profileId").where("applicationId", applicationId)
+ );
+ }
+
if (search) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call
const sanitizedSearch = sanitizeSqlLikeString(search);
@@ -200,13 +218,14 @@ export const certificateRequestDALFactory = (db: TDbClient) => {
fromDate?: Date;
toDate?: Date;
profileIds?: string[];
+ applicationId?: string;
metadataFilter?: Array<{ key: string; value?: string }>;
} = {},
processedRules?: ProcessedPermissionRules,
tx?: Knex
): Promise<number> => {
try {
- const { search, status, fromDate, toDate, profileIds, metadataFilter } = options;
+ const { search, status, fromDate, toDate, profileIds, applicationId, metadataFilter } = options;
let query = (tx || db)(TableName.CertificateRequests)
.leftJoin(
@@ -219,6 +238,13 @@ export const certificateRequestDALFactory = (db: TDbClient) => {
query = query.whereIn(`${TableName.CertificateRequests}.profileId`, profileIds);
}
+ if (applicationId) {
+ query = query.whereIn(
+ `${TableName.CertificateRequests}.profileId`,
+ (tx || db)(TableName.PkiApplicationProfile).select("profileId").where("applicationId", applicationId)
+ );
+ }
+
if (search) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call
const sanitizedSearch = sanitizeSqlLikeString(search);
@@ -271,6 +297,7 @@ export const certificateRequestDALFactory = (db: TDbClient) => {
fromDate?: Date;
toDate?: Date;
profileIds?: string[];
+ applicationId?: string;
sortBy?: string;
sortOrder?: "asc" | "desc";
metadataFilter?: Array<{ key: string; value?: string }>;
@@ -287,6 +314,7 @@ export const certificateRequestDALFactory = (db: TDbClient) => {
fromDate,
toDate,
profileIds,
+ applicationId,
sortBy = "createdAt",
sortOrder = "desc",
metadataFilter
@@ -308,6 +336,13 @@ export const certificateRequestDALFactory = (db: TDbClient) => {
query = query.whereIn(`${TableName.CertificateRequests}.profileId`, profileIds);
}
+ if (applicationId) {
+ query = query.whereIn(
+ `${TableName.CertificateRequests}.profileId`,
+ (tx || db)(TableName.PkiApplicationProfile).select("profileId").where("applicationId", applicationId)
+ );
+ }
+
query = query
.select(selectAllTableCols(TableName.CertificateRequests))
.select(db.ref("slug").withSchema(TableName.PkiCertificateProfile).as("profileName"))
diff --git a/backend/src/services/certificate-request/certificate-request-service.ts b/backend/src/services/certificate-request/certificate-request-service.ts
index 7b8c892dd8..99ba043e9f 100644
--- a/backend/src/services/certificate-request/certificate-request-service.ts
+++ b/backend/src/services/certificate-request/certificate-request-service.ts
@@ -391,6 +391,7 @@ export const certificateRequestServiceFactory = ({
fromDate,
toDate,
profileIds,
+ applicationId,
sortBy,
sortOrder,
metadataFilter
@@ -423,6 +424,7 @@ export const certificateRequestServiceFactory = ({
fromDate,
toDate,
profileIds,
+ applicationId,
sortBy,
sortOrder,
metadataFilter
diff --git a/backend/src/services/certificate-request/certificate-request-types.ts b/backend/src/services/certificate-request/certificate-request-types.ts
index 7a87fc9967..56cede5235 100644
--- a/backend/src/services/certificate-request/certificate-request-types.ts
+++ b/backend/src/services/certificate-request/certificate-request-types.ts
@@ -66,6 +66,7 @@ export type TListCertificateRequestsDTO = TProjectPermission & {
fromDate?: Date;
toDate?: Date;
profileIds?: string[];
+ applicationId?: string;
sortBy?: string;
sortOrder?: "asc" | "desc";
metadataFilter?: Array<{ key: string; value?: string }>;
diff --git a/backend/src/services/certificate-v3/certificate-v3-service.test.ts b/backend/src/services/certificate-v3/certificate-v3-service.test.ts
index ac0797c886..703f447116 100644
--- a/backend/src/services/certificate-v3/certificate-v3-service.test.ts
+++ b/backend/src/services/certificate-v3/certificate-v3-service.test.ts
@@ -124,7 +124,7 @@ describe("CertificateV3Service", () => {
issueCertFromCa: vi.fn()
};
- const mockPermissionService: Pick<TPermissionServiceFactory, "getProjectPermission"> = {
+ const mockPermissionService: Pick<TPermissionServiceFactory, "getProjectPermission" | "getResourcePermission"> = {
getProjectPermission: vi.fn().mockResolvedValue({
permission: {
throwUnlessCan: vi.fn(),
@@ -133,6 +133,18 @@ describe("CertificateV3Service", () => {
relevantRuleFor: vi.fn(),
rules: []
}
+ }),
+ getResourcePermission: vi.fn().mockResolvedValue({
+ permission: {
+ throwUnlessCan: vi.fn(),
+ can: vi.fn().mockReturnValue(true),
+ cannot: vi.fn().mockReturnValue(false),
+ relevantRuleFor: vi.fn(),
+ rules: []
+ },
+ memberships: [],
+ hasRole: vi.fn().mockReturnValue(false),
+ isImplicitAdmin: false
})
};
diff --git a/backend/src/services/certificate-v3/certificate-v3-service.ts b/backend/src/services/certificate-v3/certificate-v3-service.ts
index 97048a8400..34f64bf405 100644
--- a/backend/src/services/certificate-v3/certificate-v3-service.ts
+++ b/backend/src/services/certificate-v3/certificate-v3-service.ts
@@ -3,13 +3,17 @@ import * as x509 from "@peculiar/x509";
import { randomUUID } from "crypto";
import RE2 from "re2";
-import { ActionProjectType, TCertificates } from "@app/db/schemas";
+import { ActionProjectType, ResourceType, TCertificates } from "@app/db/schemas";
import { TPermissionServiceFactory } from "@app/ee/services/permission/permission-service-types";
import {
ProjectPermissionCertificateActions,
ProjectPermissionCertificateProfileActions,
ProjectPermissionSub
} from "@app/ee/services/permission/project-permission";
+import {
+ ResourcePermissionCertificateActions,
+ ResourcePermissionSub
+} from "@app/ee/services/permission/resource-permission";
import { TPkiAcmeAccountDALFactory } from "@app/ee/services/pki-acme/pki-acme-account-dal";
import { BadRequestError, ForbiddenRequestError, NotFoundError } from "@app/lib/errors";
import { logger } from "@app/lib/logger";
@@ -135,7 +139,7 @@ type TCertificateV3ServiceFactoryDep = {
acmeAccountDAL: Pick<TPkiAcmeAccountDALFactory, "findById">;
certificatePolicyService: Pick<TCertificatePolicyServiceFactory, "validateCertificateRequest" | "getPolicyById">;
internalCaService: Pick<TInternalCertificateAuthorityServiceFactory, "signCertFromCa" | "issueCertFromCa">;
- permissionService: Pick<TPermissionServiceFactory, "getProjectPermission">;
+ permissionService: Pick<TPermissionServiceFactory, "getProjectPermission" | "getResourcePermission">;
certificateSyncDAL: Pick<
TCertificateSyncDALFactory,
"findPkiSyncIdsByCertificateId" | "addCertificates" | "findByPkiSyncAndCertificate" | "updateSyncMetadata"
@@ -663,12 +667,19 @@ export const certificateV3ServiceFactory = ({
const $resolveApplicationIdForProfile = async (
profile: {
id: string;
+ projectId: string;
apiConfigId?: string | null;
estConfigId?: string | null;
acmeConfigId?: string | null;
scepConfigId?: string | null;
},
- explicit: string | undefined
+ explicit: string | undefined,
+ actorContext?: {
+ actor?: ActorType;
+ actorId?: string;
+ actorAuthMethod?: ActorAuthMethod;
+ actorOrgId?: string;
+ }
): Promise<string | undefined> => {
const junctions = await pkiApplicationProfileDAL.findAllByProfileId(profile.id);
@@ -678,6 +689,32 @@ export const certificateV3ServiceFactory = ({
message: "This profile is not attached to the specified Application."
});
}
+
+ if (
+ actorContext?.actor &&
+ actorContext.actor !== ActorType.ACME_ACCOUNT &&
+ actorContext.actor !== ActorType.ACME_PROFILE &&
+ actorContext.actor !== ActorType.EST_ACCOUNT &&
+ actorContext.actor !== ActorType.SCEP_ACCOUNT &&
+ actorContext.actorId &&
+ actorContext.actorAuthMethod &&
+ actorContext.actorOrgId
+ ) {
+ const { permission } = await permissionService.getResourcePermission({
+ actor: actorContext.actor,
+ actorId: actorContext.actorId,
+ projectId: profile.projectId,
+ resourceType: ResourceType.CertificateApplication,
+ resourceId: explicit,
+ actorAuthMethod: actorContext.actorAuthMethod,
+ actorOrgId: actorContext.actorOrgId
+ });
+ ForbiddenError.from(permission).throwUnlessCan(
+ ResourcePermissionCertificateActions.Create,
+ ResourcePermissionSub.Certificates
+ );
+ }
+
return explicit;
}
@@ -754,7 +791,12 @@ export const certificateV3ServiceFactory = ({
isInternal: actor === ActorType.EST_ACCOUNT || actor === ActorType.SCEP_ACCOUNT
});
- const applicationId = await $resolveApplicationIdForProfile(profile, explicitApplicationId);
+ const applicationId = await $resolveApplicationIdForProfile(profile, explicitApplicationId, {
+ actor,
+ actorId,
+ actorAuthMethod,
+ actorOrgId
+ });
const approvalFactory = APPROVAL_POLICY_FACTORY_MAP[ApprovalPolicyType.CertRequest](ApprovalPolicyType.CertRequest);
const matchedApprovalPolicy = (await approvalFactory.matchPolicy(
@@ -1333,7 +1375,12 @@ export const certificateV3ServiceFactory = ({
requiredEnrollmentType: enrollmentType,
isInternal: actor === ActorType.EST_ACCOUNT || actor === ActorType.SCEP_ACCOUNT
});
- const applicationId = await $resolveApplicationIdForProfile(profile, explicitApplicationId);
+ const applicationId = await $resolveApplicationIdForProfile(profile, explicitApplicationId, {
+ actor,
+ actorId,
+ actorAuthMethod,
+ actorOrgId
+ });
if (!profile.caId) {
throw new BadRequestError({
@@ -1710,7 +1757,12 @@ export const certificateV3ServiceFactory = ({
requiredEnrollmentType: EnrollmentType.API,
isInternal: actor === ActorType.EST_ACCOUNT || actor === ActorType.SCEP_ACCOUNT
});
- const applicationId = await $resolveApplicationIdForProfile(profile, explicitApplicationId);
+ const applicationId = await $resolveApplicationIdForProfile(profile, explicitApplicationId, {
+ actor,
+ actorId,
+ actorAuthMethod,
+ actorOrgId
+ });
let certificateRequest: TCertificateRequest;
let extractedKeyAlgorithm: string | undefined;
diff --git a/backend/src/services/pki-application/pki-application-enrollment-service.ts b/backend/src/services/pki-application/pki-application-enrollment-service.ts
index 069735d22e..1698d9094a 100644
--- a/backend/src/services/pki-application/pki-application-enrollment-service.ts
+++ b/backend/src/services/pki-application/pki-application-enrollment-service.ts
@@ -185,6 +185,9 @@ export const pkiApplicationEnrollmentServiceFactory = ({
const estConfig = junction.estConfigId ? await estEnrollmentConfigDAL.findById(junction.estConfigId) : null;
const scepConfig = junction.scepConfigId ? await scepEnrollmentConfigDAL.findById(junction.scepConfigId) : null;
+ const siteUrl = getConfig().SITE_URL ?? "";
+ const appProfilePath = `applications/${applicationId}/profiles/${profileId}`;
+
return {
applicationId,
profileId,
@@ -198,14 +201,16 @@ export const pkiApplicationEnrollmentServiceFactory = ({
est: estConfig
? {
id: estConfig.id,
- disableBootstrapCaValidation: Boolean(estConfig.disableBootstrapCaValidation)
+ disableBootstrapCaValidation: Boolean(estConfig.disableBootstrapCaValidation),
+ estEndpointUrl: `${siteUrl}/.well-known/est/${appProfilePath}`
}
: null,
acme: acmeConfig
? {
id: acmeConfig.id,
skipDnsOwnershipVerification: Boolean(acmeConfig.skipDnsOwnershipVerification),
- skipEabBinding: Boolean(acmeConfig.skipEabBinding)
+ skipEabBinding: Boolean(acmeConfig.skipEabBinding),
+ directoryUrl: `${siteUrl}/api/v1/cert-manager/acme/${appProfilePath}/directory`
}
: null,
scep: scepConfig
@@ -215,7 +220,14 @@ export const pkiApplicationEnrollmentServiceFactory = ({
includeCaCertInResponse: Boolean(scepConfig.includeCaCertInResponse),
allowCertBasedRenewal: Boolean(scepConfig.allowCertBasedRenewal),
dynamicChallengeExpiryMinutes: scepConfig.dynamicChallengeExpiryMinutes ?? null,
- dynamicChallengeMaxPending: scepConfig.dynamicChallengeMaxPending ?? null
+ dynamicChallengeMaxPending: scepConfig.dynamicChallengeMaxPending ?? null,
+ scepEndpointUrl: `${siteUrl}/scep/${appProfilePath}/pkiclient.exe`,
+ challengeEndpointUrl:
+ scepConfig.challengeType === ScepChallengeType.DYNAMIC
+ ? `${siteUrl}/scep/${appProfilePath}/challenge`
+ : null,
+ raCertificatePem: scepConfig.raCertificate,
+ raCertExpiresAt: scepConfig.raCertExpiresAt
}
: null,
estConfigured: Boolean(junction.estConfigId),
@@ -612,12 +624,15 @@ export const pkiApplicationEnrollmentServiceFactory = ({
hashedChallengePassword = await crypto.hashing().createHash(config.challengePassword, appCfg.SALT_ROUNDS);
}
- const raCert = await generateRaCertificate(`app-${applicationId}-${profileId}`);
- const certificateManagerKmsId = await getProjectKmsCertificateKeyId({ projectId, projectDAL, kmsService });
- const kmsEncryptor = await kmsService.encryptWithKmsKey({ kmsId: certificateManagerKmsId });
- const { cipherTextBlob: encryptedRaPrivateKey } = await kmsEncryptor({
- plainText: Buffer.from(raCert.privateKeyDer)
- });
+ const isFirstCreate = !junction.scepConfigId;
+ const raCert = isFirstCreate ? await generateRaCertificate(`app-${applicationId}-${profileId}`) : null;
+ let encryptedRaPrivateKey: Buffer | null = null;
+ if (raCert) {
+ const certificateManagerKmsId = await getProjectKmsCertificateKeyId({ projectId, projectDAL, kmsService });
+ const kmsEncryptor = await kmsService.encryptWithKmsKey({ kmsId: certificateManagerKmsId });
+ const encResult = await kmsEncryptor({ plainText: Buffer.from(raCert.privateKeyDer) });
+ encryptedRaPrivateKey = encResult.cipherTextBlob;
+ }
return pkiApplicationProfileDAL.transaction(async (tx) => {
let { scepConfigId } = junction;
@@ -630,10 +645,7 @@ export const pkiApplicationEnrollmentServiceFactory = ({
await scepEnrollmentConfigDAL.updateById(
scepConfigId,
{
- encryptedRaPrivateKey,
- raCertificate: raCert.certificatePem,
- raCertExpiresAt: raCert.expiresAt,
- hashedChallengePassword,
+ ...(hashedChallengePassword !== null ? { hashedChallengePassword } : {}),
challengeType,
includeCaCertInResponse: config.includeCaCertInResponse ?? true,
allowCertBasedRenewal: config.allowCertBasedRenewal ?? true,
@@ -643,6 +655,10 @@ export const pkiApplicationEnrollmentServiceFactory = ({
tx
);
} else {
+ if (!raCert || !encryptedRaPrivateKey) {
+ // Defensive, should never hit; raCert is generated when isFirstCreate.
+ throw new BadRequestError({ message: "Failed to generate SCEP RA certificate." });
+ }
const created = await scepEnrollmentConfigDAL.create(
{
encryptedRaPrivateKey,
diff --git a/backend/src/services/pki-application/pki-application-membership-service.ts b/backend/src/services/pki-application/pki-application-membership-service.ts
index 2854ce5c51..eb213253be 100644
--- a/backend/src/services/pki-application/pki-application-membership-service.ts
+++ b/backend/src/services/pki-application/pki-application-membership-service.ts
@@ -60,8 +60,8 @@ export const pkiApplicationMembershipServiceFactory = ({
return application;
};
- const $assertActorPresentInProject = async (
- projectId: string,
+ const $assertActorPresentInOrg = async (
+ orgId: string,
actor: { userId?: string; identityId?: string; groupId?: string }
) => {
const setActors = [actor.userId, actor.identityId, actor.groupId].filter(Boolean);
@@ -72,20 +72,20 @@ export const pkiApplicationMembershipServiceFactory = ({
}
const where: Record<string, unknown> = {
- scope: AccessScope.Project,
- scopeProjectId: projectId
+ scope: AccessScope.Organization,
+ scopeOrgId: orgId
};
if (actor.userId) where.actorUserId = actor.userId;
else if (actor.identityId) where.actorIdentityId = actor.identityId;
else if (actor.groupId) where.actorGroupId = actor.groupId;
- const projectMembership = await membershipDAL.find(where);
- if (!projectMembership.length) {
+ const orgMembership = await membershipDAL.find(where);
+ if (!orgMembership.length) {
throw new BadRequestError({
- message: "The actor is not a member of this project. Add them at the project level first."
+ message: "The actor is not a member of this organization. Invite them to the organization first."
});
}
- return projectMembership[0];
+ return orgMembership[0];
};
const $loadResourcePermission = (
@@ -141,13 +141,13 @@ export const pkiApplicationMembershipServiceFactory = ({
});
}
- const projectMembership = await $assertActorPresentInProject(projectId, { userId, identityId, groupId });
+ const orgMembership = await $assertActorPresentInOrg(actorOrgId, { userId, identityId, groupId });
return membershipDAL.transaction(async (tx) => {
const newMembership = await membershipDAL.create(
{
scope: RESOURCE_SCOPE,
- scopeOrgId: projectMembership.scopeOrgId,
+ scopeOrgId: orgMembership.scopeOrgId,
scopeProjectId: projectId,
actorUserId: userId ?? null,
actorIdentityId: identityId ?? null,
diff --git a/backend/src/services/pki-application/pki-application-service.ts b/backend/src/services/pki-application/pki-application-service.ts
index 9a5126d03c..2795c79332 100644
--- a/backend/src/services/pki-application/pki-application-service.ts
+++ b/backend/src/services/pki-application/pki-application-service.ts
@@ -1,6 +1,6 @@
import { ForbiddenError } from "@casl/ability";
-import { ActionProjectType, RESOURCE_SCOPE, ResourceType } from "@app/db/schemas";
+import { ActionProjectType, ProjectMembershipRole, RESOURCE_SCOPE, ResourceType } from "@app/db/schemas";
import { TPermissionServiceFactory } from "@app/ee/services/permission/permission-service-types";
import {
ProjectPermissionApplicationActions,
@@ -10,7 +10,7 @@ import {
ResourcePermissionApplicationActions,
ResourcePermissionSub
} from "@app/ee/services/permission/resource-permission";
-import { BadRequestError, NotFoundError } from "@app/lib/errors";
+import { BadRequestError, DatabaseError, NotFoundError } from "@app/lib/errors";
import { ActorType } from "@app/services/auth/auth-type";
import { TMembershipDALFactory } from "../membership/membership-dal";
@@ -128,18 +128,25 @@ export const pkiApplicationServiceFactory = ({
}
}
- return pkiApplicationDAL.transaction(async (tx) => {
- const application = await pkiApplicationDAL.create({ projectId, name, description: description ?? null }, tx);
+ try {
+ return await pkiApplicationDAL.transaction(async (tx) => {
+ const application = await pkiApplicationDAL.create({ projectId, name, description: description ?? null }, tx);
- if (profileIds && profileIds.length > 0) {
- await pkiApplicationProfileDAL.insertMany(
- profileIds.map((profileId) => ({ applicationId: application.id, profileId })),
- tx
- );
- }
+ if (profileIds && profileIds.length > 0) {
+ await pkiApplicationProfileDAL.insertMany(
+ profileIds.map((profileId) => ({ applicationId: application.id, profileId })),
+ tx
+ );
+ }
- return application;
- });
+ return application;
+ });
+ } catch (err) {
+ if (err instanceof DatabaseError && (err.error as { code?: string })?.code === "23505") {
+ throw new BadRequestError({ message: `An application with name '${name}' already exists in this project.` });
+ }
+ throw err;
+ }
};
const getApplicationById = async ({
@@ -208,18 +215,23 @@ export const pkiApplicationServiceFactory = ({
actorAuthMethod,
actorOrgId
}: TListPkiApplicationsDTO) => {
- const { permission } = await $loadProjectPermission(projectId, { actor, actorId, actorAuthMethod, actorOrgId });
+ const { permission, hasRole } = await $loadProjectPermission(projectId, {
+ actor,
+ actorId,
+ actorAuthMethod,
+ actorOrgId
+ });
ForbiddenError.from(permission).throwUnlessCan(
ProjectPermissionApplicationActions.List,
ProjectPermissionSub.Application
);
- const isProjectAdmin = permission.can(ProjectPermissionApplicationActions.Create, ProjectPermissionSub.Application);
-
- if (isProjectAdmin) {
- const applications = await pkiApplicationDAL.findByProjectId(projectId, { search, limit, offset });
- const total = await pkiApplicationDAL.countByProjectId(projectId, search);
+ if (hasRole(ProjectMembershipRole.Admin)) {
+ const [applications, total] = await Promise.all([
+ pkiApplicationDAL.findByProjectId(projectId, { search, limit, offset }),
+ pkiApplicationDAL.countByProjectId(projectId, search)
+ ]);
return { applications, total };
}
@@ -238,13 +250,15 @@ export const pkiApplicationServiceFactory = ({
return { applications: [], total: 0 };
}
- const applications = await pkiApplicationDAL.findByProjectId(projectId, {
- search,
- limit,
- offset,
- applicationIds: allowedIds
- });
- const total = await pkiApplicationDAL.countByProjectId(projectId, search, undefined, allowedIds);
+ const [applications, total] = await Promise.all([
+ pkiApplicationDAL.findByProjectId(projectId, {
+ search,
+ limit,
+ offset,
+ applicationIds: allowedIds
+ }),
+ pkiApplicationDAL.countByProjectId(projectId, search, undefined, allowedIds)
+ ]);
return { applications, total };
};
@@ -282,10 +296,17 @@ export const pkiApplicationServiceFactory = ({
}
}
- return pkiApplicationDAL.updateById(applicationId, {
- ...(name !== undefined && { name }),
- ...(description !== undefined && { description })
- });
+ try {
+ return await pkiApplicationDAL.updateById(applicationId, {
+ ...(name !== undefined && { name }),
+ ...(description !== undefined && { description })
+ });
+ } catch (err) {
+ if (err instanceof DatabaseError && (err.error as { code?: string })?.code === "23505") {
+ throw new BadRequestError({ message: `An application with name '${name}' already exists in this project.` });
+ }
+ throw err;
+ }
};
const deleteApplication = async ({
diff --git a/frontend/src/components/approvals/PolicyApprovalSteps.tsx b/frontend/src/components/approvals/PolicyApprovalSteps.tsx
index d29247c969..870bdfd980 100644
--- a/frontend/src/components/approvals/PolicyApprovalSteps.tsx
+++ b/frontend/src/components/approvals/PolicyApprovalSteps.tsx
@@ -9,10 +9,15 @@ import { useProject } from "@app/context";
import { getMemberLabel } from "@app/helpers/members";
import { useGetWorkspaceUsers, useListWorkspaceGroups } from "@app/hooks/api";
import { ApproverType } from "@app/hooks/api/approvalPolicies";
+import { useListPkiApplicationMembers } from "@app/hooks/api/pkiApplications";
import { TFormWithApprovalSteps } from "./ApprovalStepsSchema";
-export const PolicyApprovalSteps = () => {
+type Props = {
+ applicationId?: string;
+};
+
+export const PolicyApprovalSteps = ({ applicationId }: Props = {}) => {
const { control } = useFormContext<TFormWithApprovalSteps>();
const { currentProject } = useProject();
@@ -20,6 +25,7 @@ export const PolicyApprovalSteps = () => {
const { data: members = [] } = useGetWorkspaceUsers(projectId);
const { data: groups = [] } = useListWorkspaceGroups(projectId);
+ const { data: appMembers = [] } = useListPkiApplicationMembers(applicationId ?? "");
const {
fields: stepFields,
@@ -30,24 +36,47 @@ export const PolicyApprovalSteps = () => {
name: "steps"
});
- const memberOptions = useMemo(
- () =>
- members.map((member) => ({
- id: member.user.id,
- type: ApproverType.User,
- isOrgMembershipActive: member.user.isOrgMembershipActive
- })),
- [members]
- );
+ const memberOptions = useMemo(() => {
+ if (applicationId) {
+ return appMembers
+ .filter((m) => Boolean(m.actorUserId))
+ .map((m) => ({
+ id: m.actorUserId as string,
+ type: ApproverType.User,
+ isOrgMembershipActive: true
+ }));
+ }
+ return members.map((member) => ({
+ id: member.user.id,
+ type: ApproverType.User,
+ isOrgMembershipActive: member.user.isOrgMembershipActive
+ }));
+ }, [applicationId, appMembers, members]);
- const groupOptions = useMemo(
- () =>
- groups?.map(({ group }) => ({
- id: group.id,
- type: ApproverType.Group
- })),
- [groups]
- );
+ const groupOptions = useMemo(() => {
+ if (applicationId) {
+ return appMembers
+ .filter((m) => Boolean(m.actorGroupId))
+ .map((m) => ({ id: m.actorGroupId as string, type: ApproverType.Group }));
+ }
+ return groups?.map(({ group }) => ({ id: group.id, type: ApproverType.Group })) ?? [];
+ }, [applicationId, appMembers, groups]);
+
+ const userLabel = (userId: string) => {
+ if (applicationId) {
+ const m = appMembers.find((member) => member.actorUserId === userId);
+ return m?.details?.name || m?.details?.username || m?.details?.email || userId;
+ }
+ const member = members.find((m) => m.user.id === userId);
+ return member ? getMemberLabel(member) : userId;
+ };
+ const groupLabel = (groupId: string) => {
+ if (applicationId) {
+ const m = appMembers.find((member) => member.actorGroupId === groupId);
+ return m?.details?.name || groupId;
+ }
+ return groups?.find(({ group }) => group.id === groupId)?.group.name ?? groupId;
+ };
return (
<div className="space-y-4">
@@ -167,11 +196,7 @@ export const PolicyApprovalSteps = () => {
placeholder="Select users..."
options={memberOptions}
getOptionValue={(option) => option.id}
- getOptionLabel={(option) => {
- const member = members?.find((m) => m.user.id === option.id);
- if (!member) return option.id;
- return getMemberLabel(member);
- }}
+ getOptionLabel={(option) => userLabel(option.id)}
value={userApprovers}
onChange={(selected) => {
const newApprovers = [
@@ -202,10 +227,7 @@ export const PolicyApprovalSteps = () => {
placeholder="Select groups..."
options={groupOptions}
getOptionValue={(option) => option.id}
- getOptionLabel={(option) =>
- groups?.find(({ group }) => group.id === option.id)?.group.name ??
- option.id
- }
+ getOptionLabel={(option) => groupLabel(option.id)}
value={groupApprovers}
onChange={(selected) => {
const newApprovers = [
diff --git a/frontend/src/hooks/api/certificateInventoryViews/mutations.tsx b/frontend/src/hooks/api/certificateInventoryViews/mutations.tsx
index 1a36be05bc..db9fd35bfd 100644
--- a/frontend/src/hooks/api/certificateInventoryViews/mutations.tsx
+++ b/frontend/src/hooks/api/certificateInventoryViews/mutations.tsx
@@ -14,15 +14,21 @@ export const useCreateCertificateInventoryView = () => {
const queryClient = useQueryClient();
return useMutation({
- mutationFn: async ({ name, filters, columns, isShared }: TCreateInventoryViewDTO) => {
+ mutationFn: async ({
+ name,
+ filters,
+ columns,
+ isShared,
+ applicationId
+ }: TCreateInventoryViewDTO) => {
const { data } = await apiRequest.post<{ view: TCertificateInventoryView }>(
"/api/v1/cert-manager/certificate-inventory-views",
- { name, filters, columns, isShared }
+ { name, filters, columns, isShared, ...(applicationId && { applicationId }) }
);
return data.view;
},
onSuccess: () => {
- queryClient.invalidateQueries({ queryKey: certificateInventoryViewKeys.list() });
+ queryClient.invalidateQueries({ queryKey: certificateInventoryViewKeys.all });
}
});
};
@@ -39,7 +45,7 @@ export const useUpdateCertificateInventoryView = () => {
return data.view;
},
onSuccess: () => {
- queryClient.invalidateQueries({ queryKey: certificateInventoryViewKeys.list() });
+ queryClient.invalidateQueries({ queryKey: certificateInventoryViewKeys.all });
}
});
};
@@ -55,7 +61,7 @@ export const useDeleteCertificateInventoryView = () => {
return data.view;
},
onSuccess: () => {
- queryClient.invalidateQueries({ queryKey: certificateInventoryViewKeys.list() });
+ queryClient.invalidateQueries({ queryKey: certificateInventoryViewKeys.all });
}
});
};
diff --git a/frontend/src/hooks/api/certificateInventoryViews/queries.tsx b/frontend/src/hooks/api/certificateInventoryViews/queries.tsx
index 831a6762df..5230271542 100644
--- a/frontend/src/hooks/api/certificateInventoryViews/queries.tsx
+++ b/frontend/src/hooks/api/certificateInventoryViews/queries.tsx
@@ -6,15 +6,17 @@ import { TListInventoryViewsResponse } from "./types";
export const certificateInventoryViewKeys = {
all: ["certificateInventoryViews"] as const,
- list: () => [...certificateInventoryViewKeys.all, "list"] as const
+ list: (applicationId?: string) =>
+ [...certificateInventoryViewKeys.all, "list", { applicationId: applicationId ?? null }] as const
};
-export const useListCertificateInventoryViews = () => {
+export const useListCertificateInventoryViews = (applicationId?: string) => {
return useQuery({
- queryKey: certificateInventoryViewKeys.list(),
+ queryKey: certificateInventoryViewKeys.list(applicationId),
queryFn: async () => {
const { data } = await apiRequest.get<TListInventoryViewsResponse>(
- "/api/v1/cert-manager/certificate-inventory-views"
+ "/api/v1/cert-manager/certificate-inventory-views",
+ { params: applicationId ? { applicationId } : undefined }
);
return data;
}
diff --git a/frontend/src/hooks/api/certificateInventoryViews/types.ts b/frontend/src/hooks/api/certificateInventoryViews/types.ts
index 8e40de0332..511ae29deb 100644
--- a/frontend/src/hooks/api/certificateInventoryViews/types.ts
+++ b/frontend/src/hooks/api/certificateInventoryViews/types.ts
@@ -49,6 +49,7 @@ export type TCreateInventoryViewDTO = {
filters: TInventoryViewFilters;
columns?: string[];
isShared?: boolean;
+ applicationId?: string;
};
export type TUpdateInventoryViewDTO = {
diff --git a/frontend/src/hooks/api/certificates/queries.tsx b/frontend/src/hooks/api/certificates/queries.tsx
index 3a20398a1d..2788a0201f 100644
--- a/frontend/src/hooks/api/certificates/queries.tsx
+++ b/frontend/src/hooks/api/certificates/queries.tsx
@@ -118,6 +118,7 @@ export const useListCertificateRequests = (params: TListCertificateRequestsParam
fromDate: (params.fromDate || new Date(now - daysInMs)).toISOString(),
toDate: (params.toDate || new Date(now)).toISOString(),
...(params.profileIds?.length && { profileIds: params.profileIds }),
+ ...(params.applicationId && { applicationId: params.applicationId }),
sortBy: params.sortBy,
sortOrder: params.sortOrder,
...(params.metadataFilter?.length && { metadata: params.metadataFilter })
diff --git a/frontend/src/hooks/api/certificates/types.ts b/frontend/src/hooks/api/certificates/types.ts
index a6f9271b64..6618516dd6 100644
--- a/frontend/src/hooks/api/certificates/types.ts
+++ b/frontend/src/hooks/api/certificates/types.ts
@@ -233,6 +233,7 @@ export type TListCertificateRequestsParams = {
fromDate?: Date;
toDate?: Date;
profileIds?: string[];
+ applicationId?: string;
sortBy?: string;
sortOrder?: "asc" | "desc";
metadataFilter?: Array<{ key: string; value?: string }>;
diff --git a/frontend/src/hooks/api/pkiApplications/types.ts b/frontend/src/hooks/api/pkiApplications/types.ts
index 1b2aaf5da7..4350fc15e2 100644
--- a/frontend/src/hooks/api/pkiApplications/types.ts
+++ b/frontend/src/hooks/api/pkiApplications/types.ts
@@ -53,11 +53,16 @@ export type TPkiApplicationEnrollmentState = {
applicationId: string;
profileId: string;
api: { id: string; autoRenew: boolean; renewBeforeDays: number | null } | null;
- est: { id: string; disableBootstrapCaValidation: boolean } | null;
+ est: {
+ id: string;
+ disableBootstrapCaValidation: boolean;
+ estEndpointUrl: string;
+ } | null;
acme: {
id: string;
skipDnsOwnershipVerification: boolean;
skipEabBinding: boolean;
+ directoryUrl: string;
} | null;
scep: {
id: string;
@@ -66,6 +71,10 @@ export type TPkiApplicationEnrollmentState = {
allowCertBasedRenewal: boolean;
dynamicChallengeExpiryMinutes: number | null;
dynamicChallengeMaxPending: number | null;
+ scepEndpointUrl: string;
+ challengeEndpointUrl: string | null;
+ raCertificatePem: string;
+ raCertExpiresAt: string;
} | null;
estConfigured: boolean;
acmeConfigured: boolean;
diff --git a/frontend/src/hooks/api/projects/queries.tsx b/frontend/src/hooks/api/projects/queries.tsx
index c21d6e2704..d869d46eb8 100644
--- a/frontend/src/hooks/api/projects/queries.tsx
+++ b/frontend/src/hooks/api/projects/queries.tsx
@@ -549,6 +549,7 @@ export const useListWorkspaceCertificates = ({
notAfterTo,
notBeforeFrom,
notBeforeTo,
+ applicationId,
sortBy,
sortOrder
}: {
@@ -575,6 +576,7 @@ export const useListWorkspaceCertificates = ({
notAfterTo?: Date;
notBeforeFrom?: Date;
notBeforeTo?: Date;
+ applicationId?: string;
sortBy?: string;
sortOrder?: "asc" | "desc";
}) => {
@@ -603,6 +605,7 @@ export const useListWorkspaceCertificates = ({
notAfterTo,
notBeforeFrom,
notBeforeTo,
+ applicationId,
sortBy,
sortOrder
}),
@@ -634,6 +637,7 @@ export const useListWorkspaceCertificates = ({
...(notAfterTo && { notAfterTo: notAfterTo.toISOString() }),
...(notBeforeFrom && { notBeforeFrom: notBeforeFrom.toISOString() }),
...(notBeforeTo && { notBeforeTo: notBeforeTo.toISOString() }),
+ ...(applicationId && { applicationId }),
...(sortBy && { sortBy }),
...(sortOrder && { sortOrder })
}
diff --git a/frontend/src/hooks/api/projects/query-keys.tsx b/frontend/src/hooks/api/projects/query-keys.tsx
index eaaae4027b..b6a8c2c4c3 100644
--- a/frontend/src/hooks/api/projects/query-keys.tsx
+++ b/frontend/src/hooks/api/projects/query-keys.tsx
@@ -65,6 +65,7 @@ export const projectKeys = {
notAfterTo,
notBeforeFrom,
notBeforeTo,
+ applicationId,
sortBy,
sortOrder
}: {
@@ -91,6 +92,7 @@ export const projectKeys = {
notAfterTo?: Date;
notBeforeFrom?: Date;
notBeforeTo?: Date;
+ applicationId?: string;
sortBy?: string;
sortOrder?: "asc" | "desc";
}) =>
@@ -119,6 +121,7 @@ export const projectKeys = {
notAfterTo,
notBeforeFrom,
notBeforeTo,
+ applicationId,
sortBy,
sortOrder
}
diff --git a/frontend/src/layouts/OrganizationLayout/components/OrgSidebar/ProjectNav.tsx b/frontend/src/layouts/OrganizationLayout/components/OrgSidebar/ProjectNav.tsx
index 5b2008006b..5029aa49be 100644
--- a/frontend/src/layouts/OrganizationLayout/components/OrgSidebar/ProjectNav.tsx
+++ b/frontend/src/layouts/OrganizationLayout/components/OrgSidebar/ProjectNav.tsx
@@ -57,6 +57,7 @@ export const ProjectNav = () => {
const hasApplicationContext = Boolean(
(locationSearch as { applicationName?: string })?.applicationName
);
+ const isFromRootRequests = (locationSearch as { from?: string })?.from === "root-requests";
const { submenu: smApprovalsSubmenu, pendingRequestsCount: smPendingCount } =
useApprovalSubmenu();
const projectLabel = isSubOrganization ? "Sub-Organization" : "Organization";
@@ -78,7 +79,7 @@ export const ProjectNav = () => {
const isOnCertApprovals = isCertManager && pathname.includes("/approvals");
const getInitialProjectSubmenu = (): Submenu | null => {
- if (isLegacyView || hasApplicationContext) return null;
+ if (isLegacyView || hasApplicationContext || isFromRootRequests) return null;
if (isOnAccessControl)
return currentProject.type === ProjectType.SecretManager
? SECRET_MANAGER_ACCESS_CONTROL_SUBMENU
diff --git a/frontend/src/pages/cert-manager/ApplicationDetailsByIDPage/ApplicationDetailsByIDPage.tsx b/frontend/src/pages/cert-manager/ApplicationDetailsByIDPage/ApplicationDetailsByIDPage.tsx
index d46105c5cf..8792d6b6af 100644
--- a/frontend/src/pages/cert-manager/ApplicationDetailsByIDPage/ApplicationDetailsByIDPage.tsx
+++ b/frontend/src/pages/cert-manager/ApplicationDetailsByIDPage/ApplicationDetailsByIDPage.tsx
@@ -1,8 +1,29 @@
+import { useState } from "react";
import { Helmet } from "react-helmet";
+import { faCheck, faCopy, faEllipsisVertical, faTrash } from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { useNavigate, useParams, useSearch } from "@tanstack/react-router";
-import { PageHeader, Spinner, Tab, TabList, TabPanel, Tabs } from "@app/components/v2";
+import { createNotification } from "@app/components/notifications";
import {
+ DeleteActionModal,
+ PageHeader,
+ Spinner,
+ Tab,
+ TabList,
+ TabPanel,
+ Tabs
+} from "@app/components/v2";
+import {
+ Button,
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuTrigger
+} from "@app/components/v3";
+import { useToggle } from "@app/hooks";
+import {
+ useDeletePkiApplication,
useGetPkiApplicationByName,
useListPkiApplicationMembers,
useListPkiApplicationProfiles
@@ -11,7 +32,6 @@ import { ProjectType } from "@app/hooks/api/projects/types";
import { ApplicationCertificatesTab } from "./components/ApplicationCertificatesTab";
import { ApplicationMembersTab } from "./components/ApplicationMembersTab";
-import { ApplicationOverviewTab } from "./components/ApplicationOverviewTab";
import { ApplicationRequestsTab } from "./components/ApplicationRequestsTab";
import { ApplicationSettingsTab } from "./components/ApplicationSettingsTab";
import { ApplicationSyncsTab } from "./components/ApplicationSyncsTab";
@@ -23,14 +43,40 @@ export const ApplicationDetailsByIDPage = () => {
orgId?: string;
};
const { applicationName, projectId, orgId } = params;
- const search = useSearch({ strict: false }) as { selectedTab?: string };
+ const search = useSearch({ strict: false }) as { selectedTab?: string; search?: string };
const navigate = useNavigate();
const { data: application, isPending } = useGetPkiApplicationByName(applicationName ?? "");
const { data: profiles = [] } = useListPkiApplicationProfiles(application?.id ?? "");
const { data: members = [] } = useListPkiApplicationMembers(application?.id ?? "");
+ const deleteApp = useDeletePkiApplication();
+ const [isDeleteOpen, setIsDeleteOpen] = useState(false);
+ const [isIdCopied, setIsIdCopied] = useToggle(false);
- const selectedTab = search.selectedTab ?? "overview";
+ const selectedTab = search.selectedTab ?? "certificates";
+
+ const handleCopyId = () => {
+ if (!application) return;
+ navigator.clipboard.writeText(application.id);
+ setIsIdCopied.on();
+ createNotification({ type: "info", text: "Application ID copied to clipboard" });
+ setTimeout(() => setIsIdCopied.off(), 2000);
+ };
+
+ const handleDelete = async () => {
+ if (!application) return;
+ try {
+ await deleteApp.mutateAsync({ applicationId: application.id });
+ createNotification({ type: "success", text: `Deleted ${application.name}` });
+ setIsDeleteOpen(false);
+ navigate({
+ to: `/organizations/${orgId ?? ""}/projects/cert-manager/${projectId ?? ""}/applications` as never
+ } as never);
+ } catch (err) {
+ const detail = err instanceof Error ? err.message : "Failed to delete Application.";
+ createNotification({ type: "error", text: detail });
+ }
+ };
if (isPending) {
return (
@@ -56,7 +102,26 @@ export const ApplicationDetailsByIDPage = () => {
scope={ProjectType.CertificateManager}
title={application.name}
description={application.description ?? undefined}
- />
+ >
+ <Button variant="outline" size="xs" onClick={handleCopyId}>
+ <FontAwesomeIcon icon={isIdCopied ? faCheck : faCopy} />
+ Copy ID
+ </Button>
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <Button variant="outline" size="xs">
+ <FontAwesomeIcon icon={faEllipsisVertical} />
+ Options
+ </Button>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="end" sideOffset={2}>
+ <DropdownMenuItem variant="danger" onClick={() => setIsDeleteOpen(true)}>
+ <FontAwesomeIcon icon={faTrash} />
+ Delete Application
+ </DropdownMenuItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ </PageHeader>
<Tabs
value={selectedTab}
@@ -68,14 +133,11 @@ export const ApplicationDetailsByIDPage = () => {
}
>
<TabList>
- <Tab variant="project" value="overview">
- Overview
- </Tab>
<Tab variant="project" value="certificates">
Certificates
</Tab>
<Tab variant="project" value="requests">
- Requests
+ Certificate Requests
</Tab>
<Tab variant="project" value="syncs">
Certificate Syncs
@@ -87,17 +149,10 @@ export const ApplicationDetailsByIDPage = () => {
Settings
</Tab>
</TabList>
- <TabPanel value="overview">
- <ApplicationOverviewTab
- application={application}
- members={members}
- projectId={projectId ?? ""}
- />
- </TabPanel>
<TabPanel value="certificates">
<ApplicationCertificatesTab
applicationId={application.id}
- projectId={projectId ?? ""}
+ initialSearch={search.search}
/>
</TabPanel>
<TabPanel value="requests">
@@ -123,6 +178,15 @@ export const ApplicationDetailsByIDPage = () => {
</div>
</div>
</div>
+
+ <DeleteActionModal
+ isOpen={isDeleteOpen}
+ title={`Delete ${application.name}?`}
+ subTitle="This unattaches all Profiles, app-scoped syncs/alerts, and revokes app-only memberships. Issued certificates remain in the project but lose their Application tag."
+ onChange={(open) => setIsDeleteOpen(open)}
+ deleteKey="confirm"
+ onDeleteApproved={handleDelete}
+ />
</>
);
};
diff --git a/frontend/src/pages/cert-manager/ApplicationDetailsByIDPage/components/AddApplicationMemberModal.tsx b/frontend/src/pages/cert-manager/ApplicationDetailsByIDPage/components/AddApplicationMemberModal.tsx
index 19a5c5ea24..c628545bb6 100644
--- a/frontend/src/pages/cert-manager/ApplicationDetailsByIDPage/components/AddApplicationMemberModal.tsx
+++ b/frontend/src/pages/cert-manager/ApplicationDetailsByIDPage/components/AddApplicationMemberModal.tsx
@@ -6,6 +6,7 @@ import { createNotification } from "@app/components/notifications";
import { Spinner } from "@app/components/v2";
import {
Button,
+ Checkbox,
Dialog,
DialogContent,
DialogDescription,
@@ -23,7 +24,13 @@ import {
SelectContent,
SelectItem,
SelectTrigger,
- SelectValue
+ SelectValue,
+ Table,
+ TableBody,
+ TableCell,
+ TableHead,
+ TableHeader,
+ TableRow
} from "@app/components/v3";
import { useOrganization } from "@app/context";
import {
@@ -181,7 +188,7 @@ export const AddApplicationMemberModal = ({
return (
<Dialog open={isOpen} onOpenChange={handleClose}>
- <DialogContent className="max-w-lg">
+ <DialogContent className="max-w-2xl">
<DialogHeader>
<DialogTitle>Add Member</DialogTitle>
<DialogDescription>
@@ -224,7 +231,7 @@ export const AddApplicationMemberModal = ({
/>
</InputGroup>
- <div className="max-h-72 overflow-y-auto rounded-md border border-border bg-background">
+ <div className="max-h-72 overflow-y-auto rounded-md border border-border">
{isLoading && (
<div className="flex items-center justify-center p-6">
<Spinner />
@@ -241,28 +248,45 @@ export const AddApplicationMemberModal = ({
</Empty>
)}
{!isLoading && items.length > 0 && (
- <ul>
- {items.map((item) => (
- <li key={item.id}>
- <button
- type="button"
- onClick={() => setSelectedActorId(item.id)}
- className={`flex w-full items-center justify-between gap-3 px-3 py-2 text-left text-sm transition-colors ${
- selectedActorId === item.id
- ? "bg-container-hover text-foreground"
- : "text-foreground hover:bg-container"
- }`}
- >
- <div className="min-w-0">
- <div className="truncate">{item.primary}</div>
- {item.secondary ? (
- <div className="truncate text-xs text-accent">{item.secondary}</div>
- ) : null}
- </div>
- </button>
- </li>
- ))}
- </ul>
+ <Table>
+ <TableHeader>
+ <TableRow>
+ <TableHead className="w-full">Name</TableHead>
+ <TableHead className="w-10 text-right">Selected</TableHead>
+ </TableRow>
+ </TableHeader>
+ <TableBody>
+ {items.map((item) => {
+ const isSelected = selectedActorId === item.id;
+ return (
+ <TableRow
+ key={item.id}
+ onClick={() => setSelectedActorId(isSelected ? null : item.id)}
+ className={twMerge(
+ "cursor-pointer",
+ isSelected && "bg-mineshaft-700 hover:bg-mineshaft-700"
+ )}
+ >
+ <TableCell isTruncatable>
+ <div className="min-w-0">
+ <div className="truncate">{item.primary}</div>
+ {item.secondary ? (
+ <div className="truncate text-xs text-accent">{item.secondary}</div>
+ ) : null}
+ </div>
+ </TableCell>
+ <TableCell className="text-right" onClick={(e) => e.stopPropagation()}>
+ <Checkbox
+ isChecked={isSelected}
+ onCheckedChange={() => setSelectedActorId(isSelected ? null : item.id)}
+ aria-label={`Select ${item.primary}`}
+ />
+ </TableCell>
+ </TableRow>
+ );
+ })}
+ </TableBody>
+ </Table>
)}
</div>
diff --git a/frontend/src/pages/cert-manager/ApplicationDetailsByIDPage/components/ApplicationCertificatesTab.tsx b/frontend/src/pages/cert-manager/ApplicationDetailsByIDPage/components/ApplicationCertificatesTab.tsx
index d5146239b6..e3ae38b499 100644
--- a/frontend/src/pages/cert-manager/ApplicationDetailsByIDPage/components/ApplicationCertificatesTab.tsx
+++ b/frontend/src/pages/cert-manager/ApplicationDetailsByIDPage/components/ApplicationCertificatesTab.tsx
@@ -1,121 +1,15 @@
-import { useQuery } from "@tanstack/react-query";
+import { CertificatesSection } from "../../CertificatesPage/components/CertificatesSection";
-import { Spinner } from "@app/components/v2";
-import {
- Badge,
- Card,
- CardContent,
- CardDescription,
- CardHeader,
- CardTitle,
- Empty,
- EmptyDescription,
- EmptyHeader,
- EmptyTitle,
- Table,
- TableBody,
- TableCell,
- TableHead,
- TableHeader,
- TableRow
-} from "@app/components/v3";
-import { apiRequest } from "@app/config/request";
-
-type Props = { applicationId: string; projectId: string };
-
-type ApplicationCertificate = {
- id: string;
- commonName: string;
- status: string;
- notBefore: string;
- notAfter: string;
- profileName?: string | null;
-};
-
-type SearchResponse = {
- certificates: ApplicationCertificate[];
- totalCount: number;
+type Props = {
+ applicationId: string;
+ initialSearch?: string;
};
-const statusVariant = (status: string): "success" | "danger" | "warning" | "neutral" => {
- if (status === "active") return "success";
- if (status === "revoked") return "danger";
- if (status === "expired") return "warning";
- return "neutral";
-};
-
-export const ApplicationCertificatesTab = ({ applicationId, projectId }: Props) => {
- const { data, isPending } = useQuery({
- queryKey: ["application-certs", { projectId, applicationId }] as const,
- queryFn: async () => {
- const { data: body } = await apiRequest.post<SearchResponse>(
- `/api/v1/projects/${projectId}/certificates/search`,
- { offset: 0, limit: 50, applicationId, sortBy: "notAfter", sortOrder: "desc" }
- );
- return body;
- },
- enabled: Boolean(projectId && applicationId)
- });
-
+export const ApplicationCertificatesTab = ({ applicationId, initialSearch }: Props) => {
return (
- <Card>
- <CardHeader>
- <CardTitle>Certificates</CardTitle>
- <CardDescription>
- Active and historical certificates issued through this Application&apos;s profiles.
- </CardDescription>
- </CardHeader>
- <CardContent>
- {isPending && (
- <div className="flex items-center justify-center p-8">
- <Spinner />
- </div>
- )}
- {!isPending && (!data || data.certificates.length === 0) && (
- <Empty className="border">
- <EmptyHeader>
- <EmptyTitle>No certificates yet</EmptyTitle>
- <EmptyDescription>
- Certificates issued through this Application will appear here.
- </EmptyDescription>
- </EmptyHeader>
- </Empty>
- )}
- {!isPending && data && data.certificates.length > 0 && (
- <Table>
- <TableHeader>
- <TableRow>
- <TableHead>Common Name</TableHead>
- <TableHead>Profile</TableHead>
- <TableHead>Status</TableHead>
- <TableHead>Issued</TableHead>
- <TableHead>Expires</TableHead>
- </TableRow>
- </TableHeader>
- <TableBody>
- {data.certificates.map((c) => (
- <TableRow key={c.id}>
- <TableCell isTruncatable className="font-mono">
- {c.commonName}
- </TableCell>
- <TableCell className="font-mono text-xs">{c.profileName ?? "—"}</TableCell>
- <TableCell>
- <Badge variant={statusVariant(c.status)} className="capitalize">
- {c.status}
- </Badge>
- </TableCell>
- <TableCell className="text-accent">
- {new Date(c.notBefore).toLocaleDateString()}
- </TableCell>
- <TableCell className="text-accent">
- {new Date(c.notAfter).toLocaleDateString()}
- </TableCell>
- </TableRow>
- ))}
- </TableBody>
- </Table>
- )}
- </CardContent>
- </Card>
+ <CertificatesSection
+ applicationId={applicationId}
+ externalFilter={initialSearch ? { search: initialSearch } : undefined}
+ />
);
};
diff --git a/frontend/src/pages/cert-manager/ApplicationDetailsByIDPage/components/ApplicationOverviewTab.tsx b/frontend/src/pages/cert-manager/ApplicationDetailsByIDPage/components/ApplicationOverviewTab.tsx
deleted file mode 100644
index 3b4ad2b897..0000000000
--- a/frontend/src/pages/cert-manager/ApplicationDetailsByIDPage/components/ApplicationOverviewTab.tsx
+++ /dev/null
@@ -1,155 +0,0 @@
-import { useQuery } from "@tanstack/react-query";
-import { FileCheckIcon, FileClockIcon, HourglassIcon, UsersIcon } from "lucide-react";
-
-import { Card, CardContent, Skeleton } from "@app/components/v3";
-import { apiRequest } from "@app/config/request";
-import { TPkiApplication, TPkiApplicationMember } from "@app/hooks/api/pkiApplications";
-
-type Props = {
- application: TPkiApplication;
- members: TPkiApplicationMember[];
- projectId: string;
-};
-
-type StatTone = "success" | "warning" | "danger" | "neutral";
-
-type StatCardProps = {
- label: string;
- value: number | undefined;
- isLoading: boolean;
- hint?: string;
- icon: React.ComponentType<{ className?: string }>;
- tone: StatTone;
-};
-
-const TONE_BG: Record<StatTone, string> = {
- success: "bg-success/10 border-success/20",
- warning: "bg-warning/10 border-warning/20",
- danger: "bg-danger/10 border-danger/20",
- neutral: "bg-neutral/10 border-neutral/20"
-};
-
-const TONE_ICON: Record<StatTone, string> = {
- success: "text-success",
- warning: "text-warning",
- danger: "text-danger",
- neutral: "text-neutral"
-};
-
-const StatCard = ({ label, value, isLoading, hint, icon: Icon, tone }: StatCardProps) => (
- <Card className="h-auto min-w-[180px] flex-1 gap-0 p-0">
- <CardContent className="flex h-full flex-col p-4">
- <div className="flex items-start justify-between">
- <span className="text-base font-semibold text-foreground">{label}</span>
- <div
- className={`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg border ${TONE_BG[tone]}`}
- >
- <Icon className={`h-[18px] w-[18px] ${TONE_ICON[tone]}`} />
- </div>
- </div>
- <div className="mt-auto pt-6">
- <div className="flex items-baseline gap-2">
- {isLoading ? (
- <Skeleton className="h-8 w-12" />
- ) : (
- <span className="text-3xl font-semibold text-foreground">{value ?? 0}</span>
- )}
- {hint ? <span className="text-xs text-muted">{hint}</span> : null}
- </div>
- </div>
- </CardContent>
- </Card>
-);
-
-export const ApplicationOverviewTab = ({ application, members, projectId }: Props) => {
- const { data: activeCerts, isPending: isActivePending } = useQuery({
- queryKey: [
- "application-overview-active",
- { projectId, applicationId: application.id }
- ] as const,
- queryFn: async () => {
- const { data } = await apiRequest.post<{ totalCount: number }>(
- `/api/v1/projects/${projectId}/certificates/search`,
- { offset: 0, limit: 1, applicationId: application.id, status: "active" }
- );
- return data.totalCount;
- },
- enabled: Boolean(projectId && application.id)
- });
-
- const expiringCutoff = new Date(Date.now() + 30 * 24 * 60 * 60 * 1000).toISOString();
- const { data: expiringCount, isPending: isExpiringPending } = useQuery({
- queryKey: [
- "application-overview-expiring",
- { projectId, applicationId: application.id }
- ] as const,
- queryFn: async () => {
- const { data } = await apiRequest.post<{ totalCount: number }>(
- `/api/v1/projects/${projectId}/certificates/search`,
- {
- offset: 0,
- limit: 1,
- applicationId: application.id,
- status: "active",
- notAfterTo: expiringCutoff
- }
- );
- return data.totalCount;
- },
- enabled: Boolean(projectId && application.id)
- });
-
- const { data: pendingApprovals, isPending: isPendingApprovalsPending } = useQuery({
- queryKey: [
- "application-overview-pending",
- { projectId, applicationId: application.id }
- ] as const,
- queryFn: async () => {
- const { data } = await apiRequest.get<{ requests: Array<{ status: string }> }>(
- "/api/v1/cert-request-policies/requests",
- { params: { projectId, applicationId: application.id } }
- );
- return data.requests.filter((r) => r.status === "pending").length;
- },
- enabled: Boolean(projectId && application.id)
- });
-
- return (
- <div className="space-y-4">
- <div className="grid grid-cols-2 gap-4 md:grid-cols-4">
- <StatCard
- label="Active certificates"
- value={activeCerts}
- isLoading={isActivePending}
- hint="Issued via this Application"
- icon={FileCheckIcon}
- tone="success"
- />
- <StatCard
- label="Expiring in 30d"
- value={expiringCount}
- isLoading={isExpiringPending}
- hint="Active, expiring within 30 days"
- icon={FileClockIcon}
- tone={expiringCount && expiringCount > 0 ? "warning" : "neutral"}
- />
- <StatCard
- label="Pending approvals"
- value={pendingApprovals}
- isLoading={isPendingApprovalsPending}
- hint="Gated by an Application policy"
- icon={HourglassIcon}
- tone={pendingApprovals && pendingApprovals > 0 ? "warning" : "neutral"}
- />
- <StatCard
- label="Members"
- value={members.length}
- isLoading={false}
- hint="Users, identities, and groups"
- icon={UsersIcon}
- tone="neutral"
- />
- </div>
- </div>
- );
-};
diff --git a/frontend/src/pages/cert-manager/ApplicationDetailsByIDPage/components/ApplicationRequestsTab.tsx b/frontend/src/pages/cert-manager/ApplicationDetailsByIDPage/components/ApplicationRequestsTab.tsx
index da0da36673..5cb652450c 100644
--- a/frontend/src/pages/cert-manager/ApplicationDetailsByIDPage/components/ApplicationRequestsTab.tsx
+++ b/frontend/src/pages/cert-manager/ApplicationDetailsByIDPage/components/ApplicationRequestsTab.tsx
@@ -1,264 +1,29 @@
-import { useMemo, useState } from "react";
-import { useQuery } from "@tanstack/react-query";
import { useNavigate, useParams } from "@tanstack/react-router";
-import { SearchIcon } from "lucide-react";
-import { Tab, TabList, TabPanel, Tabs } from "@app/components/v2";
-import {
- Badge,
- Card,
- CardContent,
- CardDescription,
- CardHeader,
- CardTitle,
- Empty,
- EmptyDescription,
- EmptyHeader,
- EmptyTitle,
- InputGroup,
- InputGroupAddon,
- InputGroupInput,
- Table,
- TableBody,
- TableCell,
- TableHead,
- TableHeader,
- TableRow
-} from "@app/components/v3";
-import { useDebounce } from "@app/hooks";
-import { ApprovalPolicyType } from "@app/hooks/api/approvalPolicies";
-import {
- approvalRequestQuery,
- ApprovalRequestStatus,
- CertRequestRequestData,
- TApprovalRequest
-} from "@app/hooks/api/approvalRequests";
+import { CertificateRequestsSection } from "../../CertificateRequestsPage/components/CertificateRequestsSection";
type Props = {
applicationId: string;
applicationName: string;
};
-type StatusFilter = "pending" | "approved" | "rejected" | "all";
-
-const STATUS_TABS: {
- key: StatusFilter;
- label: string;
- matches: (s: ApprovalRequestStatus) => boolean;
-}[] = [
- { key: "pending", label: "Pending", matches: (s) => s === ApprovalRequestStatus.Pending },
- { key: "approved", label: "Approved", matches: (s) => s === ApprovalRequestStatus.Approved },
- {
- key: "rejected",
- label: "Rejected",
- matches: (s) =>
- s === ApprovalRequestStatus.Rejected ||
- s === ApprovalRequestStatus.Cancelled ||
- s === ApprovalRequestStatus.Expired
- },
- { key: "all", label: "All", matches: () => true }
-];
-
-const STATUS_BADGE: Record<
- ApprovalRequestStatus,
- { label: string; variant: "warning" | "success" | "danger" | "neutral" | "info" }
-> = {
- [ApprovalRequestStatus.Pending]: { label: "Pending review", variant: "warning" },
- [ApprovalRequestStatus.Approved]: { label: "Approved", variant: "success" },
- [ApprovalRequestStatus.Rejected]: { label: "Rejected", variant: "danger" },
- [ApprovalRequestStatus.Cancelled]: { label: "Cancelled", variant: "neutral" },
- [ApprovalRequestStatus.Expired]: { label: "Expired", variant: "neutral" }
-};
-
-const formatRelative = (iso: string): string => {
- const minutes = Math.round((Date.now() - new Date(iso).getTime()) / 60000);
- if (minutes < 1) return "just now";
- if (minutes < 60) return `${minutes} minute${minutes === 1 ? "" : "s"} ago`;
- const hours = Math.round(minutes / 60);
- if (hours < 24) return `${hours} hour${hours === 1 ? "" : "s"} ago`;
- const days = Math.round(hours / 24);
- return `${days} day${days === 1 ? "" : "s"} ago`;
-};
-
-const isCertRequestData = (data: unknown): data is { requestData: CertRequestRequestData } => {
- return Boolean(
- data &&
- typeof data === "object" &&
- "requestData" in data &&
- data.requestData &&
- typeof data.requestData === "object" &&
- "profileName" in (data.requestData as object)
- );
-};
-
export const ApplicationRequestsTab = ({ applicationId, applicationName }: Props) => {
const params = useParams({ strict: false }) as { projectId?: string; orgId?: string };
const { projectId, orgId } = params;
const navigate = useNavigate();
- const [activeStatus, setActiveStatus] = useState<StatusFilter>("pending");
- const [searchInput, setSearchInput] = useState("");
- const [debouncedSearch] = useDebounce(searchInput, 300);
-
- const { data: requests = [], isPending } = useQuery(
- approvalRequestQuery.list({
- policyType: ApprovalPolicyType.CertRequest,
- projectId: projectId ?? "",
- applicationId
- })
- );
-
- const filtered = useMemo(() => {
- const tab = STATUS_TABS.find((t) => t.key === activeStatus) ?? STATUS_TABS[0];
- const norm = debouncedSearch.trim().toLowerCase();
- return (requests as TApprovalRequest[])
- .filter((r) => tab.matches(r.status as ApprovalRequestStatus))
- .filter((r) => {
- if (!norm) return true;
- const cn = isCertRequestData(r.requestData)
- ? (r.requestData.requestData.certificateRequest?.commonName ?? "")
- : "";
- const profile = isCertRequestData(r.requestData)
- ? (r.requestData.requestData.profileName ?? "")
- : "";
- return cn.toLowerCase().includes(norm) || profile.toLowerCase().includes(norm);
- });
- }, [requests, activeStatus, debouncedSearch]);
- const counts = useMemo(() => {
- const result: Record<StatusFilter, number> = {
- pending: 0,
- approved: 0,
- rejected: 0,
- all: requests.length
- };
- (requests as TApprovalRequest[]).forEach((r) => {
- const s = r.status as ApprovalRequestStatus;
- if (s === ApprovalRequestStatus.Pending) result.pending += 1;
- else if (s === ApprovalRequestStatus.Approved) result.approved += 1;
- else if (
- s === ApprovalRequestStatus.Rejected ||
- s === ApprovalRequestStatus.Cancelled ||
- s === ApprovalRequestStatus.Expired
- )
- result.rejected += 1;
- });
- return result;
- }, [requests]);
+ const handleViewCertificateFromRequest = (certificateId: string) => {
+ navigate({
+ to: `/organizations/${orgId ?? ""}/projects/cert-manager/${projectId ?? ""}/applications/${applicationName}` as never,
+ search: { selectedTab: "certificates", search: certificateId } as never
+ } as never);
+ };
return (
- <Card>
- <CardHeader>
- <CardTitle>Certificate Requests</CardTitle>
- <CardDescription>
- Issuance requests for this Application. Requests gated by an approval policy land here for
- review before issuance.
- </CardDescription>
- </CardHeader>
- <CardContent>
- <Tabs value={activeStatus} onValueChange={(v) => setActiveStatus(v as StatusFilter)}>
- <TabList>
- {STATUS_TABS.map((t) => (
- <Tab key={t.key} value={t.key} variant="project">
- {t.label} ({counts[t.key]})
- </Tab>
- ))}
- </TabList>
- {STATUS_TABS.map((t) => (
- <TabPanel key={t.key} value={t.key}>
- <div className="my-4">
- <InputGroup>
- <InputGroupAddon>
- <SearchIcon />
- </InputGroupAddon>
- <InputGroupInput
- placeholder="Search by SAN or CN…"
- value={searchInput}
- onChange={(e) => setSearchInput(e.target.value)}
- />
- </InputGroup>
- </div>
-
- {isPending && (
- <Empty>
- <EmptyHeader>
- <EmptyTitle>Loading…</EmptyTitle>
- </EmptyHeader>
- </Empty>
- )}
- {!isPending && filtered.length === 0 && (
- <Empty className="border">
- <EmptyHeader>
- <EmptyTitle>
- {activeStatus === "pending" ? "No requests pending review" : "No requests"}
- </EmptyTitle>
- <EmptyDescription>
- Cert-request approval workflows scoped to this Application will appear here.
- </EmptyDescription>
- </EmptyHeader>
- </Empty>
- )}
- {!isPending && filtered.length > 0 && (
- <Table>
- <TableHeader>
- <TableRow>
- <TableHead>Common Name / SAN</TableHead>
- <TableHead>Profile</TableHead>
- <TableHead>Requester</TableHead>
- <TableHead>Status</TableHead>
- <TableHead>Requested</TableHead>
- </TableRow>
- </TableHeader>
- <TableBody>
- {filtered.map((r) => {
- const certData = isCertRequestData(r.requestData)
- ? r.requestData.requestData
- : null;
- const cn = certData?.certificateRequest?.commonName ?? "—";
- const profile = certData?.profileName ?? "—";
- const badge = STATUS_BADGE[r.status as ApprovalRequestStatus] ?? {
- label: r.status,
- variant: "neutral" as const
- };
- return (
- <TableRow
- key={r.id}
- className="cursor-pointer"
- onClick={() =>
- navigate({
- to: `/organizations/${orgId ?? ""}/projects/cert-manager/${projectId ?? ""}/approvals/${r.id}` as never,
- search: {
- policyType: ApprovalPolicyType.CertRequest,
- applicationName
- } as never
- } as never)
- }
- >
- <TableCell isTruncatable className="font-mono">
- {cn}
- </TableCell>
- <TableCell className="font-mono text-xs">{profile}</TableCell>
- <TableCell>
- <div>{r.requesterName || "—"}</div>
- {r.requesterEmail ? (
- <div className="text-xs text-accent">{r.requesterEmail}</div>
- ) : null}
- </TableCell>
- <TableCell>
- <Badge variant={badge.variant}>{badge.label}</Badge>
- </TableCell>
- <TableCell className="text-accent">
- {formatRelative(r.createdAt)}
- </TableCell>
- </TableRow>
- );
- })}
- </TableBody>
- </Table>
- )}
- </TabPanel>
- ))}
- </Tabs>
- </CardContent>
- </Card>
+ <CertificateRequestsSection
+ applicationId={applicationId}
+ applicationName={applicationName}
+ onViewCertificateFromRequest={handleViewCertificateFromRequest}
+ />
);
};
diff --git a/frontend/src/pages/cert-manager/ApplicationDetailsByIDPage/components/ApplicationSettingsTab.tsx b/frontend/src/pages/cert-manager/ApplicationDetailsByIDPage/components/ApplicationSettingsTab.tsx
index 389d8455af..4fc1e3e46a 100644
--- a/frontend/src/pages/cert-manager/ApplicationDetailsByIDPage/components/ApplicationSettingsTab.tsx
+++ b/frontend/src/pages/cert-manager/ApplicationDetailsByIDPage/components/ApplicationSettingsTab.tsx
@@ -1,29 +1,23 @@
import { useMemo, useState } from "react";
import { faPlus } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+import { useQuery } from "@tanstack/react-query";
+import { formatDistance } from "date-fns";
import {
+ CircleStopIcon,
+ EyeIcon,
FilePlusIcon,
+ InfoIcon,
MoreHorizontalIcon,
PencilIcon,
+ PlayIcon,
PlusIcon,
SettingsIcon,
Trash2Icon
} from "lucide-react";
import { createNotification } from "@app/components/notifications";
-import {
- Button as V2Button,
- DeleteActionModal,
- FilterableSelect,
- Skeleton as V2Skeleton,
- Table as V2Table,
- TableContainer,
- TBody,
- Td,
- Th,
- THead,
- Tr
-} from "@app/components/v2";
+import { DeleteActionModal } from "@app/components/v2";
import {
Badge,
Button,
@@ -47,22 +41,36 @@ import {
EmptyDescription,
EmptyHeader,
EmptyTitle,
+ FilterableSelect,
IconButton,
+ Skeleton,
Table,
TableBody,
TableCell,
TableHead,
TableHeader,
- TableRow
+ TableRow,
+ Tooltip,
+ TooltipContent,
+ TooltipTrigger
} from "@app/components/v3";
+import { useProject } from "@app/context";
import { usePopUp } from "@app/hooks";
import {
+ approvalPolicyQuery,
ApprovalPolicyType,
+ CertRequestPolicyConditions,
TApprovalPolicy,
useDeleteApprovalPolicy
} from "@app/hooks/api/approvalPolicies";
import { useListCertificateProfiles } from "@app/hooks/api/certificateProfiles";
-import { TPkiAlertV2, useDeletePkiAlertV2, useGetPkiAlertsV2 } from "@app/hooks/api/pkiAlertsV2";
+import {
+ PkiAlertEventTypeV2,
+ TPkiAlertV2,
+ useDeletePkiAlertV2,
+ useGetPkiAlertsV2,
+ useUpdatePkiAlertV2
+} from "@app/hooks/api/pkiAlertsV2";
import {
TPkiApplication,
TPkiApplicationProfile,
@@ -70,12 +78,14 @@ import {
useDetachPkiApplicationProfile
} from "@app/hooks/api/pkiApplications";
import { PkiApplicationModal } from "@app/pages/cert-manager/ApplicationsPage/components/PkiApplicationModal";
-import { PoliciesTable } from "@app/pages/cert-manager/ApprovalsPage/components/PolicyTab/components/PoliciesTable";
import { PolicyModal } from "@app/pages/cert-manager/ApprovalsPage/components/PolicyTab/components/PolicyModal";
import { CertificateIssuanceModal } from "@app/pages/cert-manager/CertificatesPage/components/CertificateIssuanceModal";
import { CreatePkiAlertV2Modal } from "@app/views/PkiAlertsV2Page/components/CreatePkiAlertV2Modal";
-import { PkiAlertV2Row } from "@app/views/PkiAlertsV2Page/components/PkiAlertV2Row";
import { ViewPkiAlertV2Modal } from "@app/views/PkiAlertsV2Page/components/ViewPkiAlertV2Modal";
+import {
+ formatAlertBefore,
+ formatEventType
+} from "@app/views/PkiAlertsV2Page/utils/pki-alert-formatters";
import { ConfigureEnrollmentModal } from "./ConfigureEnrollmentModal";
@@ -90,6 +100,245 @@ const methodBadges = (p: TPkiApplicationProfile) => {
return methods;
};
+const getPolicyProfileNames = (policy: TApprovalPolicy): string[] => {
+ const conditions = policy.conditions.conditions as CertRequestPolicyConditions;
+ return conditions.flatMap((c: { profileNames: string[] }) => c.profileNames);
+};
+
+type ApplicationPoliciesTableProps = {
+ applicationId: string;
+ onEdit: (policy: TApprovalPolicy) => void;
+ onDelete: (policy: TApprovalPolicy) => void;
+};
+
+const ApplicationPoliciesTable = ({
+ applicationId,
+ onEdit,
+ onDelete
+}: ApplicationPoliciesTableProps) => {
+ const { currentProject } = useProject();
+ const { data: policies = [], isPending } = useQuery(
+ approvalPolicyQuery.list({
+ policyType: ApprovalPolicyType.CertRequest,
+ projectId: currentProject?.id ?? "",
+ applicationId
+ })
+ );
+
+ const sortedPolicies = useMemo(
+ () =>
+ [...policies].sort(
+ (a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime()
+ ),
+ [policies]
+ );
+
+ if (!isPending && sortedPolicies.length === 0) {
+ return (
+ <Empty className="border">
+ <EmptyHeader>
+ <EmptyTitle>No approval policies</EmptyTitle>
+ <EmptyDescription>
+ Create a policy to gate certificate operations on this Application.
+ </EmptyDescription>
+ </EmptyHeader>
+ </Empty>
+ );
+ }
+
+ return (
+ <Table>
+ <TableHeader>
+ <TableRow>
+ <TableHead>Policy Name</TableHead>
+ <TableHead>Profile Name</TableHead>
+ <TableHead>Approval Steps</TableHead>
+ <TableHead>Created</TableHead>
+ <TableHead className="w-5" />
+ </TableRow>
+ </TableHeader>
+ <TableBody>
+ {isPending &&
+ Array.from({ length: 3 }, (_, idx) => (
+ <TableRow key={`policy-skeleton-${idx + 1}`}>
+ {Array.from({ length: 5 }, (__, cellIdx) => (
+ <TableCell key={`policy-skeleton-cell-${cellIdx + 1}`}>
+ <Skeleton className="h-4 w-24" />
+ </TableCell>
+ ))}
+ </TableRow>
+ ))}
+ {!isPending &&
+ sortedPolicies.map((policy) => {
+ const profileNames = getPolicyProfileNames(policy);
+ return (
+ <TableRow key={policy.id}>
+ <TableCell isTruncatable>
+ <div className="flex items-center gap-x-2">
+ <span className="font-medium text-foreground">{policy.name}</span>
+ {!policy.applicationId ? (
+ <Badge variant="neutral" className="uppercase">
+ Legacy
+ </Badge>
+ ) : null}
+ </div>
+ </TableCell>
+ <TableCell>
+ <div className="flex flex-wrap items-center gap-1">
+ {profileNames.slice(0, 3).map((name) => (
+ <Badge key={name} variant="neutral">
+ {name}
+ </Badge>
+ ))}
+ {profileNames.length > 3 ? (
+ <span className="text-xs text-accent">+{profileNames.length - 3} more</span>
+ ) : null}
+ </div>
+ </TableCell>
+ <TableCell className="text-accent">
+ {policy.steps.length} step{policy.steps.length !== 1 ? "s" : ""}
+ </TableCell>
+ <TableCell className="text-accent">
+ {formatDistance(new Date(policy.createdAt), new Date(), { addSuffix: true })}
+ </TableCell>
+ <TableCell>
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <IconButton variant="ghost" size="xs" aria-label="Policy actions">
+ <MoreHorizontalIcon />
+ </IconButton>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent className="min-w-40" align="end" sideOffset={2}>
+ <DropdownMenuItem onClick={() => onEdit(policy)}>
+ <PencilIcon />
+ Edit Policy
+ </DropdownMenuItem>
+ <DropdownMenuItem variant="danger" onClick={() => onDelete(policy)}>
+ <Trash2Icon />
+ Delete Policy
+ </DropdownMenuItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ </TableCell>
+ </TableRow>
+ );
+ })}
+ </TableBody>
+ </Table>
+ );
+};
+
+type AlertRowProps = {
+ alert: TPkiAlertV2;
+ onView: () => void;
+ onEdit: () => void;
+ onDelete: () => void;
+};
+
+const AlertRow = ({ alert, onView, onEdit, onDelete }: AlertRowProps) => {
+ const { mutateAsync: updateAlert } = useUpdatePkiAlertV2();
+
+ const handleToggleAlert = async () => {
+ try {
+ await updateAlert({ alertId: alert.id, enabled: !alert.enabled });
+ createNotification({
+ text: `Alert ${!alert.enabled ? "enabled" : "disabled"} successfully`,
+ type: "success"
+ });
+ } catch {
+ createNotification({ text: "Failed to update alert status", type: "error" });
+ }
+ };
+
+ return (
+ <TableRow>
+ <TableCell isTruncatable>
+ <div className="flex items-center gap-2">
+ <span className="font-medium text-foreground">{alert.name}</span>
+ {alert.description ? (
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <InfoIcon className="size-3.5 shrink-0 text-accent" />
+ </TooltipTrigger>
+ <TooltipContent side="right" className="max-w-xs">
+ {alert.description}
+ </TooltipContent>
+ </Tooltip>
+ ) : null}
+ </div>
+ </TableCell>
+ <TableCell className="whitespace-nowrap text-accent">
+ {formatEventType(alert.eventType)}
+ </TableCell>
+ <TableCell className="whitespace-nowrap">
+ <Badge variant={alert.enabled ? "success" : "neutral"}>
+ {alert.enabled ? "Enabled" : "Disabled"}
+ </Badge>
+ </TableCell>
+ <TableCell className="whitespace-nowrap text-accent">
+ {alert.eventType === PkiAlertEventTypeV2.EXPIRATION ? (
+ formatAlertBefore(alert.alertBefore)
+ ) : (
+ <span className="text-mineshaft-500">—</span>
+ )}
+ </TableCell>
+ <TableCell className="whitespace-nowrap">
+ {alert.lastRun ? (
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <Badge variant={alert.lastRun.status === "success" ? "success" : "danger"}>
+ {alert.lastRun.status === "success" ? "Success" : "Failed"}
+ </Badge>
+ </TooltipTrigger>
+ <TooltipContent side="left" className="max-w-sm">
+ <div className="text-xs text-mineshaft-300">
+ {new Date(alert.lastRun.timestamp)
+ .toISOString()
+ .replace("T", " ")
+ .replace("Z", " UTC")}
+ </div>
+ {alert.lastRun.error ? (
+ <div className="mt-1 max-h-32 thin-scrollbar overflow-y-auto text-xs break-words text-red-400">
+ {alert.lastRun.error}
+ </div>
+ ) : null}
+ </TooltipContent>
+ </Tooltip>
+ ) : (
+ <span className="text-mineshaft-500">—</span>
+ )}
+ </TableCell>
+ <TableCell className="text-right">
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <IconButton variant="ghost" size="xs" aria-label="Alert actions">
+ <MoreHorizontalIcon />
+ </IconButton>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent className="min-w-44" align="end" sideOffset={2}>
+ <DropdownMenuItem onClick={onView}>
+ <EyeIcon />
+ View details
+ </DropdownMenuItem>
+ <DropdownMenuItem onClick={onEdit}>
+ <PencilIcon />
+ Edit alert
+ </DropdownMenuItem>
+ <DropdownMenuItem onClick={handleToggleAlert}>
+ {alert.enabled ? <CircleStopIcon /> : <PlayIcon />}
+ {alert.enabled ? "Disable" : "Enable"} alert
+ </DropdownMenuItem>
+ <DropdownMenuItem variant="danger" onClick={onDelete}>
+ <Trash2Icon />
+ Delete alert
+ </DropdownMenuItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ </TableCell>
+ </TableRow>
+ );
+};
+
export const ApplicationSettingsTab = ({ application, profiles }: Props) => {
const [isAttachOpen, setIsAttachOpen] = useState(false);
const [profilesToAttach, setProfilesToAttach] = useState<{ value: string; label: string }[]>([]);
@@ -215,208 +464,208 @@ export const ApplicationSettingsTab = ({ application, profiles }: Props) => {
};
return (
- <div className="space-y-4">
- <Card>
- <CardHeader>
- <CardTitle>General</CardTitle>
- <CardDescription>Edit core metadata for this Application.</CardDescription>
- <CardAction>
- <IconButton
- variant="ghost"
- size="xs"
- onClick={() => handleEditPopUpOpen("application", application)}
- aria-label="Edit application"
- >
- <PencilIcon />
- </IconButton>
- </CardAction>
- </CardHeader>
- <CardContent>
- <dl className="grid grid-cols-1 gap-3 text-sm md:grid-cols-2">
- <div>
- <dt className="text-xs text-accent">Name</dt>
- <dd className="font-mono text-foreground">{application.name}</dd>
- </div>
- {application.description?.length ? (
- <div className="col-span-full">
- <dt className="text-xs text-accent">Description</dt>
- <dd className="text-foreground">{application.description}</dd>
+ <div className="grid grid-cols-1 gap-4 lg:grid-cols-12">
+ <div className="space-y-4 lg:col-span-3">
+ <Card>
+ <CardHeader className="grid-cols-[1fr_auto]">
+ <CardTitle>General</CardTitle>
+ <CardDescription>Edit core metadata for this Application.</CardDescription>
+ <CardAction className="col-start-2 row-span-2 row-start-1 self-start justify-self-end">
+ <IconButton
+ variant="ghost"
+ size="xs"
+ onClick={() => handleEditPopUpOpen("application", application)}
+ aria-label="Edit application"
+ >
+ <PencilIcon />
+ </IconButton>
+ </CardAction>
+ </CardHeader>
+ <CardContent>
+ <dl className="grid grid-cols-1 gap-3 text-sm">
+ <div>
+ <dt className="text-xs text-accent">Name</dt>
+ <dd className="font-mono text-foreground">{application.name}</dd>
</div>
- ) : null}
- </dl>
- </CardContent>
- </Card>
-
- <Card>
- <CardHeader>
- <CardTitle>Enrollment Methods</CardTitle>
- <CardDescription>
- Profiles this Application can issue from, and the methods (API · EST · ACME · SCEP)
- configured on each.
- </CardDescription>
- <CardAction>
- <Button
- size="sm"
- variant="project"
- onClick={() => setIsAttachOpen(true)}
- isDisabled={availableProfiles.length === 0}
- >
- <PlusIcon />
- Attach Profile
- </Button>
- </CardAction>
- </CardHeader>
- <CardContent>
- {profiles.length === 0 ? (
- <Empty className="border">
- <EmptyHeader>
- <EmptyTitle>No profiles attached</EmptyTitle>
- <EmptyDescription>Attach a profile to enable issuance.</EmptyDescription>
- </EmptyHeader>
- </Empty>
- ) : (
+ {application.description?.length ? (
+ <div>
+ <dt className="text-xs text-accent">Description</dt>
+ <dd className="text-foreground">{application.description}</dd>
+ </div>
+ ) : null}
+ </dl>
+ </CardContent>
+ </Card>
+ </div>
+
+ <div className="space-y-4 lg:col-span-9">
+ <Card>
+ <CardHeader>
+ <CardTitle>Enrollment Methods</CardTitle>
+ <CardDescription>
+ Profiles this Application can issue from, and the methods (API · EST · ACME · SCEP)
+ configured on each.
+ </CardDescription>
+ <CardAction>
+ <Button
+ size="sm"
+ variant="project"
+ onClick={() => setIsAttachOpen(true)}
+ isDisabled={availableProfiles.length === 0}
+ >
+ <PlusIcon />
+ Attach Profile
+ </Button>
+ </CardAction>
+ </CardHeader>
+ <CardContent>
+ {profiles.length === 0 ? (
+ <Empty className="border">
+ <EmptyHeader>
+ <EmptyTitle>No profiles attached</EmptyTitle>
+ <EmptyDescription>Attach a profile to enable issuance.</EmptyDescription>
+ </EmptyHeader>
+ </Empty>
+ ) : (
+ <Table>
+ <TableHeader>
+ <TableRow>
+ <TableHead>Profile</TableHead>
+ <TableHead>Methods</TableHead>
+ <TableHead className="w-5" />
+ </TableRow>
+ </TableHeader>
+ <TableBody>
+ {profiles.map((p) => {
+ const methods = methodBadges(p);
+ return (
+ <TableRow key={p.profileId}>
+ <TableCell isTruncatable className="font-mono">
+ {p.profileSlug}
+ </TableCell>
+ <TableCell>
+ {methods.length === 0 ? (
+ <span className="text-xs text-accent">None</span>
+ ) : (
+ <div className="flex flex-wrap gap-1.5">
+ {methods.map((m) => (
+ <Badge key={m} variant="neutral">
+ {m}
+ </Badge>
+ ))}
+ </div>
+ )}
+ </TableCell>
+ <TableCell>
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <IconButton variant="ghost" size="xs">
+ <MoreHorizontalIcon />
+ </IconButton>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent className="min-w-44" align="end" sideOffset={2}>
+ <DropdownMenuItem onClick={() => setProfileToConfigure(p)}>
+ <SettingsIcon />
+ Configure method
+ </DropdownMenuItem>
+ {p.apiConfigId ? (
+ <DropdownMenuItem
+ onClick={() => {
+ setProfileToIssue(p);
+ handleIssuePopUpOpen("issueCertificate");
+ }}
+ >
+ <FilePlusIcon />
+ Request Certificate
+ </DropdownMenuItem>
+ ) : null}
+ <DropdownMenuItem
+ variant="danger"
+ onClick={() => setProfileToDetach(p)}
+ >
+ <Trash2Icon />
+ Detach Profile
+ </DropdownMenuItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ </TableCell>
+ </TableRow>
+ );
+ })}
+ </TableBody>
+ </Table>
+ )}
+ </CardContent>
+ </Card>
+
+ <Card>
+ <CardHeader>
+ <CardTitle>Approval Policies</CardTitle>
+ <CardDescription>
+ Approval workflows that gate certificate operations against this Application.
+ </CardDescription>
+ <CardAction>
+ <Button variant="outline" onClick={() => handlePopUpOpen("policy")}>
+ <FontAwesomeIcon icon={faPlus} />
+ Create Policy
+ </Button>
+ </CardAction>
+ </CardHeader>
+ <CardContent>
+ <ApplicationPoliciesTable
+ applicationId={application.id}
+ onEdit={(policy) => handlePopUpOpen("policy", { policyId: policy.id, policy })}
+ onDelete={(policy) => handlePopUpOpen("deletePolicy", { policyId: policy.id })}
+ />
+ </CardContent>
+ </Card>
+
+ <Card>
+ <CardHeader>
+ <CardTitle>Alerting</CardTitle>
+ <CardDescription>
+ Alert rules for certificate events scoped to {application.name}.
+ </CardDescription>
+ <CardAction>
+ <Button variant="outline" onClick={() => setAlertModal({ isOpen: true })}>
+ <FontAwesomeIcon icon={faPlus} />
+ Create Alert
+ </Button>
+ </CardAction>
+ </CardHeader>
+ <CardContent>
<Table>
<TableHeader>
<TableRow>
- <TableHead>Profile</TableHead>
- <TableHead>Methods</TableHead>
- <TableHead className="w-5" />
+ <TableHead className="w-full">Name</TableHead>
+ <TableHead className="whitespace-nowrap">Event Type</TableHead>
+ <TableHead className="whitespace-nowrap">Status</TableHead>
+ <TableHead className="whitespace-nowrap">Alert Before</TableHead>
+ <TableHead className="whitespace-nowrap">Last Run</TableHead>
+ <TableHead className="w-5 text-right">Actions</TableHead>
</TableRow>
</TableHeader>
<TableBody>
- {profiles.map((p) => {
- const methods = methodBadges(p);
- return (
- <TableRow key={p.profileId}>
- <TableCell isTruncatable className="font-mono">
- {p.profileSlug}
- </TableCell>
- <TableCell>
- {methods.length === 0 ? (
- <span className="text-xs text-accent">None</span>
- ) : (
- <div className="flex flex-wrap gap-1.5">
- {methods.map((m) => (
- <Badge key={m} variant="neutral">
- {m}
- </Badge>
- ))}
- </div>
- )}
- </TableCell>
- <TableCell>
- <DropdownMenu>
- <DropdownMenuTrigger asChild>
- <IconButton variant="ghost" size="xs">
- <MoreHorizontalIcon />
- </IconButton>
- </DropdownMenuTrigger>
- <DropdownMenuContent className="min-w-44" align="end" sideOffset={2}>
- <DropdownMenuItem onClick={() => setProfileToConfigure(p)}>
- <SettingsIcon />
- Configure method
- </DropdownMenuItem>
- {p.apiConfigId ? (
- <DropdownMenuItem
- onClick={() => {
- setProfileToIssue(p);
- handleIssuePopUpOpen("issueCertificate");
- }}
- >
- <FilePlusIcon />
- Request Certificate
- </DropdownMenuItem>
- ) : null}
- <DropdownMenuItem
- variant="danger"
- onClick={() => setProfileToDetach(p)}
- >
- <Trash2Icon />
- Detach Profile
- </DropdownMenuItem>
- </DropdownMenuContent>
- </DropdownMenu>
- </TableCell>
- </TableRow>
- );
- })}
- </TableBody>
- </Table>
- )}
- </CardContent>
- </Card>
-
- <Card>
- <CardHeader>
- <CardTitle>Approval Policies</CardTitle>
- <CardDescription>
- Approval workflows that gate certificate operations against this Application.
- </CardDescription>
- <CardAction>
- <V2Button
- variant="outline_bg"
- leftIcon={<FontAwesomeIcon icon={faPlus} />}
- onClick={() => handlePopUpOpen("policy")}
- >
- Create Policy
- </V2Button>
- </CardAction>
- </CardHeader>
- <CardContent>
- <PoliciesTable handlePopUpOpen={handlePopUpOpen} applicationId={application.id} />
- </CardContent>
- </Card>
-
- <Card>
- <CardHeader>
- <CardTitle>Alerting</CardTitle>
- <CardDescription>
- Alert rules for certificate events scoped to {application.name}.
- </CardDescription>
- <CardAction>
- <V2Button
- variant="outline_bg"
- leftIcon={<FontAwesomeIcon icon={faPlus} />}
- onClick={() => setAlertModal({ isOpen: true })}
- >
- Create Alert
- </V2Button>
- </CardAction>
- </CardHeader>
- <CardContent>
- <TableContainer>
- <V2Table>
- <THead>
- <Tr>
- <Th>Name</Th>
- <Th>Event Type</Th>
- <Th>Status</Th>
- <Th>Alert Before</Th>
- <Th>Last Run</Th>
- <Th className="text-right">Actions</Th>
- </Tr>
- </THead>
- <TBody>
{isAlertsLoading &&
Array.from({ length: 3 }, (_, idx) => (
- <Tr key={`alert-skeleton-${idx + 1}`}>
+ <TableRow key={`alert-skeleton-${idx + 1}`}>
{Array.from({ length: 6 }, (__, cellIdx) => (
- <Td key={`alert-skeleton-cell-${cellIdx + 1}`}>
- <V2Skeleton className="h-4 w-24" />
- </Td>
+ <TableCell key={`alert-skeleton-cell-${cellIdx + 1}`}>
+ <Skeleton className="h-4 w-24" />
+ </TableCell>
))}
- </Tr>
+ </TableRow>
))}
{!isAlertsLoading && alerts.length === 0 && (
- <Tr>
- <Td colSpan={6} className="py-8 text-center text-mineshaft-400">
+ <TableRow>
+ <TableCell colSpan={6} className="py-8 text-center text-accent">
No PKI alerts configured yet.
- </Td>
- </Tr>
+ </TableCell>
+ </TableRow>
)}
{!isAlertsLoading &&
alerts.map((a: TPkiAlertV2) => (
- <PkiAlertV2Row
+ <AlertRow
key={a.id}
alert={a}
onView={() => setViewAlertModal({ isOpen: true, alertId: a.id })}
@@ -426,11 +675,11 @@ export const ApplicationSettingsTab = ({ application, profiles }: Props) => {
}
/>
))}
- </TBody>
- </V2Table>
- </TableContainer>
- </CardContent>
- </Card>
+ </TableBody>
+ </Table>
+ </CardContent>
+ </Card>
+ </div>
<PolicyModal
popUp={popUp}
diff --git a/frontend/src/pages/cert-manager/ApplicationDetailsByIDPage/components/ConfigureEnrollmentModal.tsx b/frontend/src/pages/cert-manager/ApplicationDetailsByIDPage/components/ConfigureEnrollmentModal.tsx
index e31418400c..443f3b1fd1 100644
--- a/frontend/src/pages/cert-manager/ApplicationDetailsByIDPage/components/ConfigureEnrollmentModal.tsx
+++ b/frontend/src/pages/cert-manager/ApplicationDetailsByIDPage/components/ConfigureEnrollmentModal.tsx
@@ -1,22 +1,10 @@
import { useEffect, useState } from "react";
import { Controller, useForm } from "react-hook-form";
-import { faCheck, faCopy } from "@fortawesome/free-solid-svg-icons";
+import { faCheck, faCopy, faDownload } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { createNotification } from "@app/components/notifications";
-import {
- FormControl,
- FormLabel,
- IconButton,
- Input,
- Spinner,
- Switch,
- Tab,
- TabList,
- TabPanel,
- Tabs,
- TextArea
-} from "@app/components/v2";
+import { Spinner, Tab, TabList, TabPanel, Tabs } from "@app/components/v2";
import {
Badge,
Button,
@@ -25,12 +13,22 @@ import {
DialogDescription,
DialogHeader,
DialogTitle,
+ Field,
+ FieldContent,
+ FieldDescription,
+ FieldError,
+ FieldLabel,
+ IconButton,
+ Input,
Select,
SelectContent,
SelectItem,
SelectTrigger,
- SelectValue
+ SelectValue,
+ Switch,
+ TextArea
} from "@app/components/v3";
+import { downloadFile } from "@app/helpers/download";
import { useToggle } from "@app/hooks";
import { useGetPkiApplicationEnrollment } from "@app/hooks/api/pkiApplications";
import {
@@ -59,17 +57,24 @@ type Props = {
const errorText = (err: unknown, fallback: string) =>
err instanceof Error ? err.message : fallback;
-const CopyableField = ({ label, value }: { label: string; value: string }) => {
+const CopyableField = ({
+ label,
+ value,
+ helper
+}: {
+ label: string;
+ value: string;
+ helper?: string;
+}) => {
const [copied, setCopied] = useToggle(false);
return (
<div>
- <FormLabel label={label} />
+ <FieldLabel>{label}</FieldLabel>
<div className="flex gap-2">
<Input value={value} disabled />
<IconButton
- ariaLabel={`copy ${label}`}
- variant="outline_bg"
- colorSchema="secondary"
+ aria-label={`copy ${label}`}
+ variant="outline"
className="w-10"
onClick={() => {
navigator.clipboard.writeText(value);
@@ -80,6 +85,7 @@ const CopyableField = ({ label, value }: { label: string; value: string }) => {
<FontAwesomeIcon icon={copied ? faCheck : faCopy} />
</IconButton>
</div>
+ {helper ? <p className="mt-1 text-xs text-mineshaft-400">{helper}</p> : null}
</div>
);
};
@@ -153,12 +159,12 @@ const ApiPanel = ({
render={({ field }) => (
<div className="flex items-start justify-between gap-4">
<div>
- <FormLabel label="Auto-renew" />
+ <FieldLabel>Auto-renew</FieldLabel>
<p className="text-xs text-mineshaft-400">
Automatically renew certificates issued via this profile before they expire.
</p>
</div>
- <Switch id="api-auto-renew" isChecked={field.value} onCheckedChange={field.onChange} />
+ <Switch id="api-auto-renew" checked={field.value} onCheckedChange={field.onChange} />
</div>
)}
/>
@@ -168,23 +174,24 @@ const ApiPanel = ({
name="renewBeforeDays"
rules={{ min: 1, max: 365 }}
render={({ field, fieldState: { error } }) => (
- <FormControl
- label="Renew before (days)"
- isError={Boolean(error)}
- errorText="Must be between 1 and 365"
- helperText="How many days before expiry to trigger renewal."
- >
- <Input
- type="number"
- min={1}
- max={365}
- value={field.value ?? ""}
- onChange={(e) =>
- field.onChange(e.target.value === "" ? undefined : Number(e.target.value))
- }
- placeholder="30"
- />
- </FormControl>
+ <Field>
+ <FieldLabel>Renew before (days)</FieldLabel>
+ <FieldContent>
+ <Input
+ type="number"
+ min={1}
+ max={365}
+ value={field.value ?? ""}
+ onChange={(e) =>
+ field.onChange(e.target.value === "" ? undefined : Number(e.target.value))
+ }
+ placeholder="30"
+ isError={Boolean(error)}
+ />
+ </FieldContent>
+ {error ? <FieldError>Must be between 1 and 365</FieldError> : null}
+ <FieldDescription>How many days before expiry to trigger renewal.</FieldDescription>
+ </Field>
)}
/>
)}
@@ -213,7 +220,7 @@ const EstPanel = ({
applicationId: string;
profileId: string;
enabled: boolean;
- initial: { disableBootstrapCaValidation: boolean } | null;
+ initial: { disableBootstrapCaValidation: boolean; estEndpointUrl: string } | null;
}) => {
const setMutation = useSetPkiApplicationEstEnrollment();
const clearMutation = useClearPkiApplicationEstEnrollment();
@@ -265,30 +272,42 @@ const EstPanel = ({
<p className="text-sm text-mineshaft-300">
EST clients will authenticate to this profile with the passphrase below.
</p>
+ {enabled && initial?.estEndpointUrl ? (
+ <div className="space-y-3 rounded-md border border-mineshaft-600 bg-mineshaft-800 p-3">
+ <CopyableField
+ label="EST endpoint base URL"
+ value={initial.estEndpointUrl}
+ helper="Append /simpleenroll, /simplereenroll, or /cacerts depending on the operation."
+ />
+ </div>
+ ) : null}
<Controller
control={control}
name="passphrase"
rules={{ required: !enabled, minLength: 8 }}
render={({ field, fieldState: { error } }) => (
- <FormControl
- label={enabled ? "New passphrase (leave blank to keep current)" : "Passphrase"}
- isError={Boolean(error)}
- errorText="Minimum 8 characters"
- >
- <Input type="password" {...field} placeholder="••••••••" />
- </FormControl>
+ <Field>
+ <FieldLabel>
+ {enabled ? "New passphrase (leave blank to keep current)" : "Passphrase"}
+ </FieldLabel>
+ <FieldContent>
+ <Input type="password" {...field} placeholder="••••••••" isError={Boolean(error)} />
+ </FieldContent>
+ {error ? <FieldError>Minimum 8 characters</FieldError> : null}
+ </Field>
)}
/>
<Controller
control={control}
name="caChain"
render={({ field }) => (
- <FormControl
- label="CA chain (optional)"
- helperText="PEM-encoded chain returned by the EST endpoint."
- >
- <TextArea {...field} rows={3} placeholder="-----BEGIN CERTIFICATE-----..." />
- </FormControl>
+ <Field>
+ <FieldLabel>CA chain (optional)</FieldLabel>
+ <FieldContent>
+ <TextArea {...field} rows={3} placeholder="-----BEGIN CERTIFICATE-----..." />
+ </FieldContent>
+ <FieldDescription>PEM-encoded chain returned by the EST endpoint.</FieldDescription>
+ </Field>
)}
/>
<Controller
@@ -297,14 +316,14 @@ const EstPanel = ({
render={({ field }) => (
<div className="flex items-start justify-between gap-4">
<div>
- <FormLabel label="Disable bootstrap CA validation" />
+ <FieldLabel>Disable bootstrap CA validation</FieldLabel>
<p className="text-xs text-mineshaft-400">
Allow EST clients to skip server certificate validation during enrollment.
</p>
</div>
<Switch
id="est-disable-bootstrap"
- isChecked={field.value}
+ checked={field.value}
onCheckedChange={field.onChange}
/>
</div>
@@ -335,7 +354,11 @@ const AcmePanel = ({
applicationId: string;
profileId: string;
enabled: boolean;
- initial: { skipDnsOwnershipVerification: boolean; skipEabBinding: boolean } | null;
+ initial: {
+ skipDnsOwnershipVerification: boolean;
+ skipEabBinding: boolean;
+ directoryUrl: string;
+ } | null;
}) => {
const setMutation = useSetPkiApplicationAcmeEnrollment();
const clearMutation = useClearPkiApplicationAcmeEnrollment();
@@ -415,6 +438,11 @@ const AcmePanel = ({
<p className="text-sm text-mineshaft-300">
ACME clients use the EAB credentials below to register an account against this profile.
</p>
+ {enabled && initial?.directoryUrl ? (
+ <div className="space-y-3 rounded-md border border-mineshaft-600 bg-mineshaft-800 p-3">
+ <CopyableField label="ACME directory URL" value={initial.directoryUrl} />
+ </div>
+ ) : null}
<p className="text-xs text-mineshaft-400">
Pick at most one of the two options below — they are mutually exclusive.
</p>
@@ -424,19 +452,19 @@ const AcmePanel = ({
render={({ field }) => (
<div className="flex items-start justify-between gap-4">
<div>
- <FormLabel label="Skip DNS ownership verification" />
+ <FieldLabel>Skip DNS ownership verification</FieldLabel>
<p className="text-xs text-mineshaft-400">
Skip DNS-01 / HTTP-01 challenge enforcement. Use only inside trusted networks.
</p>
</div>
<Switch
id="acme-skip-dns"
- isChecked={field.value}
+ checked={field.value}
onCheckedChange={(v) => {
field.onChange(v);
if (v) setValue("skipEabBinding", false);
}}
- isDisabled={skipEab}
+ disabled={skipEab}
/>
</div>
)}
@@ -447,19 +475,19 @@ const AcmePanel = ({
render={({ field }) => (
<div className="flex items-start justify-between gap-4">
<div>
- <FormLabel label="Skip EAB binding" />
+ <FieldLabel>Skip EAB binding</FieldLabel>
<p className="text-xs text-mineshaft-400">
Allow accounts to register without an EAB key. Recommended off in production.
</p>
</div>
<Switch
id="acme-skip-eab"
- isChecked={field.value}
+ checked={field.value}
onCheckedChange={(v) => {
field.onChange(v);
if (v) setValue("skipDnsOwnershipVerification", false);
}}
- isDisabled={skipDns}
+ disabled={skipDns}
/>
</div>
)}
@@ -497,11 +525,13 @@ const AcmePanel = ({
const ScepPanel = ({
applicationId,
profileId,
+ profileSlug,
enabled,
initial
}: {
applicationId: string;
profileId: string;
+ profileSlug: string;
enabled: boolean;
initial: {
challengeType: ScepChallengeType;
@@ -509,6 +539,10 @@ const ScepPanel = ({
allowCertBasedRenewal: boolean;
dynamicChallengeExpiryMinutes: number | null;
dynamicChallengeMaxPending: number | null;
+ scepEndpointUrl: string;
+ challengeEndpointUrl: string | null;
+ raCertificatePem: string;
+ raCertExpiresAt: string;
} | null;
}) => {
const setMutation = useSetPkiApplicationScepEnrollment();
@@ -572,27 +606,79 @@ const ScepPanel = ({
}
};
+ const raCertExpiresAtLabel = initial?.raCertExpiresAt
+ ? new Date(initial.raCertExpiresAt).toLocaleDateString("en-US", {
+ year: "numeric",
+ month: "long",
+ day: "numeric"
+ })
+ : null;
+
return (
<div className="space-y-4">
<p className="text-sm text-mineshaft-300">
SCEP clients enroll by presenting a challenge password. Use static for shared passwords,
dynamic for one-time per-client challenges.
</p>
+ {enabled && initial ? (
+ <div className="space-y-3 rounded-md border border-mineshaft-600 bg-mineshaft-800 p-3">
+ <CopyableField
+ label="SCEP endpoint URL"
+ value={initial.scepEndpointUrl}
+ helper="Configure your MDM or SCEP client to point at this URL."
+ />
+ {initial.challengeType === "dynamic" && initial.challengeEndpointUrl ? (
+ <CopyableField
+ label="Challenge endpoint URL"
+ value={initial.challengeEndpointUrl}
+ helper="Authenticated POST endpoint to mint a one-time challenge (e.g., the JAMF SCEPChallenge webhook)."
+ />
+ ) : null}
+ {initial.raCertificatePem ? (
+ <div>
+ <FieldLabel>RA certificate</FieldLabel>
+ <div className="flex items-center justify-between rounded-md border border-mineshaft-600 bg-mineshaft-900 px-4 py-3">
+ <p className="text-xs text-mineshaft-400">
+ Expires: {raCertExpiresAtLabel ?? "Unknown"}
+ </p>
+ <IconButton
+ aria-label="download RA certificate"
+ variant="outline"
+ onClick={() =>
+ downloadFile(
+ initial.raCertificatePem,
+ `${profileSlug}-ra-cert.pem`,
+ "application/x-pem-file"
+ )
+ }
+ className="flex w-auto items-center gap-2 px-3"
+ >
+ <FontAwesomeIcon icon={faDownload} />
+ <span className="text-sm">Download PEM</span>
+ </IconButton>
+ </div>
+ </div>
+ ) : null}
+ </div>
+ ) : null}
<Controller
control={control}
name="challengeType"
render={({ field }) => (
- <FormControl label="Challenge type">
- <Select value={field.value} onValueChange={field.onChange}>
- <SelectTrigger className="w-full">
- <SelectValue />
- </SelectTrigger>
- <SelectContent>
- <SelectItem value="static">Static password</SelectItem>
- <SelectItem value="dynamic">Dynamic (per-client)</SelectItem>
- </SelectContent>
- </Select>
- </FormControl>
+ <Field>
+ <FieldLabel>Challenge type</FieldLabel>
+ <FieldContent>
+ <Select value={field.value} onValueChange={field.onChange}>
+ <SelectTrigger className="w-full">
+ <SelectValue />
+ </SelectTrigger>
+ <SelectContent>
+ <SelectItem value="static">Static password</SelectItem>
+ <SelectItem value="dynamic">Dynamic (per-client)</SelectItem>
+ </SelectContent>
+ </Select>
+ </FieldContent>
+ </Field>
)}
/>
{challengeType === "static" && (
@@ -601,17 +687,17 @@ const ScepPanel = ({
name="challengePassword"
rules={{ required: !enabled }}
render={({ field, fieldState: { error } }) => (
- <FormControl
- label={
- enabled
+ <Field>
+ <FieldLabel>
+ {enabled
? "New challenge password (leave blank to keep current)"
- : "Challenge password"
- }
- isError={Boolean(error)}
- errorText="Required"
- >
- <Input type="password" {...field} placeholder="••••••••" />
- </FormControl>
+ : "Challenge password"}
+ </FieldLabel>
+ <FieldContent>
+ <Input type="password" {...field} placeholder="••••••••" isError={Boolean(error)} />
+ </FieldContent>
+ {error ? <FieldError>Required</FieldError> : null}
+ </Field>
)}
/>
)}
@@ -621,34 +707,40 @@ const ScepPanel = ({
control={control}
name="dynamicChallengeExpiryMinutes"
render={({ field }) => (
- <FormControl label="Challenge expiry (minutes)">
- <Input
- type="number"
- min={5}
- max={1440}
- value={field.value ?? ""}
- onChange={(e) =>
- field.onChange(e.target.value === "" ? undefined : Number(e.target.value))
- }
- />
- </FormControl>
+ <Field>
+ <FieldLabel>Challenge expiry (minutes)</FieldLabel>
+ <FieldContent>
+ <Input
+ type="number"
+ min={5}
+ max={1440}
+ value={field.value ?? ""}
+ onChange={(e) =>
+ field.onChange(e.target.value === "" ? undefined : Number(e.target.value))
+ }
+ />
+ </FieldContent>
+ </Field>
)}
/>
<Controller
control={control}
name="dynamicChallengeMaxPending"
render={({ field }) => (
- <FormControl label="Max pending challenges">
- <Input
- type="number"
- min={1}
- max={1000}
- value={field.value ?? ""}
- onChange={(e) =>
- field.onChange(e.target.value === "" ? undefined : Number(e.target.value))
- }
- />
- </FormControl>
+ <Field>
+ <FieldLabel>Max pending challenges</FieldLabel>
+ <FieldContent>
+ <Input
+ type="number"
+ min={1}
+ max={1000}
+ value={field.value ?? ""}
+ onChange={(e) =>
+ field.onChange(e.target.value === "" ? undefined : Number(e.target.value))
+ }
+ />
+ </FieldContent>
+ </Field>
)}
/>
</div>
@@ -659,12 +751,12 @@ const ScepPanel = ({
render={({ field }) => (
<div className="flex items-start justify-between gap-4">
<div>
- <FormLabel label="Include CA cert in response" />
+ <FieldLabel>Include CA cert in response</FieldLabel>
<p className="text-xs text-mineshaft-400">
Return the issuing CA certificate inline alongside the issued cert.
</p>
</div>
- <Switch id="scep-include-ca" isChecked={field.value} onCheckedChange={field.onChange} />
+ <Switch id="scep-include-ca" checked={field.value} onCheckedChange={field.onChange} />
</div>
)}
/>
@@ -674,16 +766,12 @@ const ScepPanel = ({
render={({ field }) => (
<div className="flex items-start justify-between gap-4">
<div>
- <FormLabel label="Allow cert-based renewal" />
+ <FieldLabel>Allow cert-based renewal</FieldLabel>
<p className="text-xs text-mineshaft-400">
Let clients renew using their existing certificate as authentication.
</p>
</div>
- <Switch
- id="scep-cert-renewal"
- isChecked={field.value}
- onCheckedChange={field.onChange}
- />
+ <Switch id="scep-cert-renewal" checked={field.value} onCheckedChange={field.onChange} />
</div>
)}
/>
@@ -715,7 +803,7 @@ export const ConfigureEnrollmentModal = ({
<DialogContent className="max-w-2xl overflow-visible">
<DialogHeader>
<DialogTitle>
- Configure issuance · <span className="font-mono">{profile?.profileSlug ?? ""}</span>
+ Configure enrollment: <span className="font-mono">{profile?.profileSlug ?? ""}</span>
</DialogTitle>
<DialogDescription>
Enable an enrollment method to allow clients to request certificates from this Profile
@@ -733,25 +821,25 @@ export const ConfigureEnrollmentModal = ({
<Tab value="api">
<span className="inline-flex items-center gap-2">
API
- {data?.api ? <Badge variant="success">on</Badge> : null}
+ {data?.api ? <Badge variant="success">active</Badge> : null}
</span>
</Tab>
<Tab value="est">
<span className="inline-flex items-center gap-2">
EST
- {data?.estConfigured ? <Badge variant="success">on</Badge> : null}
+ {data?.estConfigured ? <Badge variant="success">active</Badge> : null}
</span>
</Tab>
<Tab value="acme">
<span className="inline-flex items-center gap-2">
ACME
- {data?.acmeConfigured ? <Badge variant="success">on</Badge> : null}
+ {data?.acmeConfigured ? <Badge variant="success">active</Badge> : null}
</span>
</Tab>
<Tab value="scep">
<span className="inline-flex items-center gap-2">
SCEP
- {data?.scepConfigured ? <Badge variant="success">on</Badge> : null}
+ {data?.scepConfigured ? <Badge variant="success">active</Badge> : null}
</span>
</Tab>
</TabList>
@@ -783,6 +871,7 @@ export const ConfigureEnrollmentModal = ({
<ScepPanel
applicationId={applicationId}
profileId={profileId}
+ profileSlug={profile?.profileSlug ?? ""}
enabled={Boolean(data?.scepConfigured)}
initial={data?.scep ?? null}
/>
diff --git a/frontend/src/pages/cert-manager/ApplicationDetailsByIDPage/route.tsx b/frontend/src/pages/cert-manager/ApplicationDetailsByIDPage/route.tsx
index 8bae1eb854..5c75793918 100644
--- a/frontend/src/pages/cert-manager/ApplicationDetailsByIDPage/route.tsx
+++ b/frontend/src/pages/cert-manager/ApplicationDetailsByIDPage/route.tsx
@@ -4,17 +4,11 @@ import { z } from "zod";
import { ApplicationDetailsByIDPage } from "./ApplicationDetailsByIDPage";
-const ApplicationTabSchema = z.enum([
- "overview",
- "certificates",
- "requests",
- "syncs",
- "members",
- "settings"
-]);
+const ApplicationTabSchema = z.enum(["certificates", "requests", "syncs", "members", "settings"]);
const SearchSchema = z.object({
- selectedTab: ApplicationTabSchema.optional()
+ selectedTab: ApplicationTabSchema.optional(),
+ search: z.string().optional()
});
export const Route = createFileRoute(
@@ -22,7 +16,7 @@ export const Route = createFileRoute(
)({
component: ApplicationDetailsByIDPage,
validateSearch: zodValidator(SearchSchema),
- search: { middlewares: [stripSearchParams({ selectedTab: "overview" })] },
+ search: { middlewares: [stripSearchParams({ selectedTab: "certificates" })] },
beforeLoad: ({ context }) => ({
breadcrumbs: [...context.breadcrumbs, { label: "Applications" }, { label: "Application" }]
})
diff --git a/frontend/src/pages/cert-manager/ApplicationsPage/ApplicationsPage.tsx b/frontend/src/pages/cert-manager/ApplicationsPage/ApplicationsPage.tsx
index cfe227b56d..4c2a70b818 100644
--- a/frontend/src/pages/cert-manager/ApplicationsPage/ApplicationsPage.tsx
+++ b/frontend/src/pages/cert-manager/ApplicationsPage/ApplicationsPage.tsx
@@ -1,6 +1,13 @@
import { Helmet } from "react-helmet";
import { useNavigate, useParams } from "@tanstack/react-router";
-import { Hexagon, MoreHorizontalIcon, PencilIcon, PlusIcon, Trash2Icon } from "lucide-react";
+import {
+ Hexagon,
+ InfoIcon,
+ MoreHorizontalIcon,
+ PencilIcon,
+ PlusIcon,
+ Trash2Icon
+} from "lucide-react";
import { createNotification } from "@app/components/notifications";
import { DeleteActionModal, PageHeader, Spinner } from "@app/components/v2";
@@ -25,7 +32,10 @@ import {
TableCell,
TableHead,
TableHeader,
- TableRow
+ TableRow,
+ Tooltip,
+ TooltipContent,
+ TooltipTrigger
} from "@app/components/v3";
import {
TPkiApplication,
@@ -72,12 +82,11 @@ export const ApplicationsPage = () => {
<Table>
<TableHeader>
<TableRow>
- <TableHead>Name</TableHead>
- <TableHead>Description</TableHead>
- <TableHead>Profiles</TableHead>
- <TableHead>Members</TableHead>
- <TableHead>Certificates</TableHead>
- <TableHead>Created</TableHead>
+ <TableHead className="w-full">Name</TableHead>
+ <TableHead className="whitespace-nowrap">Profiles</TableHead>
+ <TableHead className="whitespace-nowrap">Members</TableHead>
+ <TableHead className="whitespace-nowrap">Certificates</TableHead>
+ <TableHead className="whitespace-nowrap">Created</TableHead>
<TableHead className="w-5" />
</TableRow>
</TableHeader>
@@ -92,19 +101,26 @@ export const ApplicationsPage = () => {
} as never)
}
>
- <TableCell isTruncatable>
+ <TableCell className="w-full">
<div className="flex items-center gap-x-2 font-mono">
- <Hexagon className="size-5 shrink-0 text-primary" strokeWidth={1.75} />
+ <Hexagon className="size-4 shrink-0 text-primary" strokeWidth={1.75} />
<span>{app.name}</span>
+ {app.description?.length ? (
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <InfoIcon className="size-3.5 shrink-0 text-accent" />
+ </TooltipTrigger>
+ <TooltipContent side="right" className="max-w-xs">
+ {app.description}
+ </TooltipContent>
+ </Tooltip>
+ ) : null}
</div>
</TableCell>
- <TableCell isTruncatable className="text-accent">
- {app.description?.length ? app.description : "—"}
- </TableCell>
- <TableCell>{app.profileCount}</TableCell>
- <TableCell>{app.memberCount}</TableCell>
- <TableCell>{app.certificateCount}</TableCell>
- <TableCell className="text-accent">
+ <TableCell className="whitespace-nowrap">{app.profileCount}</TableCell>
+ <TableCell className="whitespace-nowrap">{app.memberCount}</TableCell>
+ <TableCell className="whitespace-nowrap">{app.certificateCount}</TableCell>
+ <TableCell className="whitespace-nowrap text-accent">
{new Date(app.createdAt).toLocaleDateString()}
</TableCell>
<TableCell>
diff --git a/frontend/src/pages/cert-manager/ApprovalsPage/components/PolicyTab/components/PolicyModal.tsx b/frontend/src/pages/cert-manager/ApprovalsPage/components/PolicyTab/components/PolicyModal.tsx
index bea58ae83c..815f0afcb7 100644
--- a/frontend/src/pages/cert-manager/ApprovalsPage/components/PolicyTab/components/PolicyModal.tsx
+++ b/frontend/src/pages/cert-manager/ApprovalsPage/components/PolicyTab/components/PolicyModal.tsx
@@ -219,7 +219,7 @@ export const PolicyModal = ({ popUp, handlePopUpToggle, applicationId }: Props)
<PolicyDetailsStep applicationId={applicationId} />
</Tab.Panel>
<Tab.Panel>
- <PolicyApprovalSteps />
+ <PolicyApprovalSteps applicationId={applicationId} />
</Tab.Panel>
<Tab.Panel>
<PolicyReviewStep />
diff --git a/frontend/src/pages/cert-manager/CertificateRequestsPage/components/CertificateRequestRow.tsx b/frontend/src/pages/cert-manager/CertificateRequestsPage/components/CertificateRequestRow.tsx
index ccff9a2cd0..3a113bf3ee 100644
--- a/frontend/src/pages/cert-manager/CertificateRequestsPage/components/CertificateRequestRow.tsx
+++ b/frontend/src/pages/cert-manager/CertificateRequestsPage/components/CertificateRequestRow.tsx
@@ -28,9 +28,10 @@ import {
type Props = {
request: TCertificateRequestListItem;
onViewCertificates?: (certificateId: string) => void;
+ applicationName?: string;
};
-export const CertificateRequestRow = ({ request, onViewCertificates }: Props) => {
+export const CertificateRequestRow = ({ request, onViewCertificates, applicationName }: Props) => {
const { currentOrg } = useOrganization();
const { currentProject } = useProject();
const { mutateAsync: triggerValidation, isPending: isTriggering } =
@@ -96,6 +97,7 @@ export const CertificateRequestRow = ({ request, onViewCertificates }: Props) =>
projectId: currentProject.id,
approvalRequestId
}}
+ search={applicationName ? { applicationName } : undefined}
>
Pending Approval
<ExternalLinkIcon />
diff --git a/frontend/src/pages/cert-manager/CertificateRequestsPage/components/CertificateRequestsSection.tsx b/frontend/src/pages/cert-manager/CertificateRequestsPage/components/CertificateRequestsSection.tsx
index 84aa73d3c0..c6125cde59 100644
--- a/frontend/src/pages/cert-manager/CertificateRequestsPage/components/CertificateRequestsSection.tsx
+++ b/frontend/src/pages/cert-manager/CertificateRequestsPage/components/CertificateRequestsSection.tsx
@@ -50,9 +50,15 @@ type CertificateRequestFilters = {
type Props = {
onViewCertificateFromRequest?: (certificateId: string) => void;
+ applicationId?: string;
+ applicationName?: string;
};
-export const CertificateRequestsSection = ({ onViewCertificateFromRequest }: Props) => {
+export const CertificateRequestsSection = ({
+ onViewCertificateFromRequest,
+ applicationId,
+ applicationName
+}: Props) => {
const [pendingSearch, setPendingSearch] = useState("");
const [pendingProfileIds, setPendingProfileIds] = useState<string[]>([]);
const [pendingFilters, setPendingFilters] = useState<CertificateRequestFilters>({});
@@ -97,6 +103,7 @@ export const CertificateRequestsSection = ({ onViewCertificateFromRequest }: Pro
...(debouncedSearch && { search: debouncedSearch }),
...(appliedFilters.status && { status: appliedFilters.status }),
...(profileIds && { profileIds }),
+ ...(applicationId && { applicationId }),
...(activeMetadataFilters && { metadataFilter: activeMetadataFilters })
}),
[
@@ -105,6 +112,7 @@ export const CertificateRequestsSection = ({ onViewCertificateFromRequest }: Pro
debouncedSearch,
appliedFilters.status,
profileIds,
+ applicationId,
activeMetadataFilters
]
);
@@ -379,6 +387,7 @@ export const CertificateRequestsSection = ({ onViewCertificateFromRequest }: Pro
key={request.id}
request={request}
onViewCertificates={handleViewCertificates}
+ applicationName={applicationName}
/>
))}
</TBody>
diff --git a/frontend/src/pages/cert-manager/CertificatesPage/components/CertificatesSection.tsx b/frontend/src/pages/cert-manager/CertificatesPage/components/CertificatesSection.tsx
index 0784f1a203..582108d58a 100644
--- a/frontend/src/pages/cert-manager/CertificatesPage/components/CertificatesSection.tsx
+++ b/frontend/src/pages/cert-manager/CertificatesPage/components/CertificatesSection.tsx
@@ -37,12 +37,14 @@ type CertificatesSectionProps = {
};
dashboardFilters?: FilterRule[];
dashboardViewId?: string;
+ applicationId?: string;
};
export const CertificatesSection = ({
externalFilter,
dashboardFilters,
- dashboardViewId
+ dashboardViewId,
+ applicationId
}: CertificatesSectionProps) => {
const { currentProject } = useProject();
const { mutateAsync: deleteCert } = useDeleteCert();
@@ -153,6 +155,7 @@ export const CertificatesSection = ({
externalFilter={externalFilter}
dashboardFilters={dashboardFilters}
dashboardViewId={dashboardViewId}
+ applicationId={applicationId}
/>
<CertificateImportModal popUp={popUp} handlePopUpToggle={handlePopUpToggle} />
<CertificateCertModal popUp={popUp} handlePopUpToggle={handlePopUpToggle} />
diff --git a/frontend/src/pages/cert-manager/CertificatesPage/components/CertificatesTable.tsx b/frontend/src/pages/cert-manager/CertificatesPage/components/CertificatesTable.tsx
index 7024a07351..f0a327e4a0 100644
--- a/frontend/src/pages/cert-manager/CertificatesPage/components/CertificatesTable.tsx
+++ b/frontend/src/pages/cert-manager/CertificatesPage/components/CertificatesTable.tsx
@@ -128,10 +128,13 @@ type Props = {
};
dashboardFilters?: FilterRule[];
dashboardViewId?: string;
+ applicationId?: string;
};
const PER_PAGE_INIT = 25;
-const VIEW_STORAGE_KEY = "cert-inventory-active-view";
+const VIEW_STORAGE_KEY_BASE = "cert-inventory-active-view";
+const getViewStorageKey = (applicationId?: string) =>
+ applicationId ? `${VIEW_STORAGE_KEY_BASE}:${applicationId}` : VIEW_STORAGE_KEY_BASE;
const MS_PER_DAY = 86_400_000;
const SEARCH_DEBOUNCE_MS = 500;
@@ -161,7 +164,8 @@ export const CertificatesTable = ({
handlePopUpOpen,
externalFilter,
dashboardFilters,
- dashboardViewId
+ dashboardViewId,
+ applicationId
}: Props) => {
const [page, setPage] = useState(1);
const [perPage, setPerPage] = useState(PER_PAGE_INIT);
@@ -201,7 +205,7 @@ export const CertificatesTable = ({
if (dashboardViewId) return dashboardViewId;
if (hasDashboardFilters) return null;
try {
- return localStorage.getItem(VIEW_STORAGE_KEY) || "system-all";
+ return localStorage.getItem(getViewStorageKey(applicationId)) || "system-all";
} catch {
return "system-all";
}
@@ -254,7 +258,7 @@ export const CertificatesTable = ({
});
const { data: caData } = useListCasByProjectId();
- const { data: viewsData } = useListCertificateInventoryViews();
+ const { data: viewsData } = useListCertificateInventoryViews(applicationId);
const { mutateAsync: deleteView } = useDeleteCertificateInventoryView();
const { mutateAsync: updateView } = useUpdateCertificateInventoryView();
const { mutateAsync: updateRenewalConfig } = useUpdateRenewalConfig();
@@ -310,6 +314,7 @@ export const CertificatesTable = ({
? new Date(filterSearchParams.notBeforeTo)
: undefined,
source: filterSearchParams.source,
+ applicationId,
sortBy,
sortOrder
});
@@ -356,10 +361,11 @@ export const CertificatesTable = ({
const persistViewId = (viewId: string | null) => {
try {
+ const storageKey = getViewStorageKey(applicationId);
if (viewId) {
- localStorage.setItem(VIEW_STORAGE_KEY, viewId);
+ localStorage.setItem(storageKey, viewId);
} else {
- localStorage.removeItem(VIEW_STORAGE_KEY);
+ localStorage.removeItem(storageKey);
}
} catch {
// localStorage may be unavailable
@@ -1306,6 +1312,7 @@ export const CertificatesTable = ({
onViewCreated={(viewId, viewFilters) => {
handleSelectView(viewId, viewFilters);
}}
+ applicationId={applicationId}
/>
</div>
);
diff --git a/frontend/src/pages/cert-manager/CertificatesPage/components/SaveViewModal.tsx b/frontend/src/pages/cert-manager/CertificatesPage/components/SaveViewModal.tsx
index 61db8ebee5..bc0d619132 100644
--- a/frontend/src/pages/cert-manager/CertificatesPage/components/SaveViewModal.tsx
+++ b/frontend/src/pages/cert-manager/CertificatesPage/components/SaveViewModal.tsx
@@ -22,9 +22,16 @@ type Props = {
onOpenChange: (isOpen: boolean) => void;
filters: FilterRule[];
onViewCreated?: (viewId: string, filters: TInventoryViewFilters) => void;
+ applicationId?: string;
};
-export const SaveViewModal = ({ isOpen, onOpenChange, filters, onViewCreated }: Props) => {
+export const SaveViewModal = ({
+ isOpen,
+ onOpenChange,
+ filters,
+ onViewCreated,
+ applicationId
+}: Props) => {
const [name, setName] = useState("");
const [isShared, setIsShared] = useState(false);
const { mutateAsync: createView, isPending } = useCreateCertificateInventoryView();
@@ -36,7 +43,8 @@ export const SaveViewModal = ({ isOpen, onOpenChange, filters, onViewCreated }:
const result = await createView({
name: name.trim(),
filters: apiFilters,
- isShared
+ isShared,
+ applicationId
});
createNotification({
text: `View "${name}" saved successfully`,
diff --git a/frontend/src/pages/cert-manager/SettingsPage/components/CertificateCleanupTab.tsx b/frontend/src/pages/cert-manager/SettingsPage/components/CertificateCleanupTab.tsx
index 8f12111d8a..93041540bb 100644
--- a/frontend/src/pages/cert-manager/SettingsPage/components/CertificateCleanupTab.tsx
+++ b/frontend/src/pages/cert-manager/SettingsPage/components/CertificateCleanupTab.tsx
@@ -88,7 +88,7 @@ export const CertificateCleanupTab = () => {
<div>
<h2 className="text-xl font-medium text-mineshaft-100">Certificate Cleanup</h2>
<p className="mt-1 text-sm text-gray-400">
- Automatically remove expired certificates to keep your project organized
+ Automatically remove expired certificates to keep your inventory organized
</p>
</div>
<Controller
diff --git a/frontend/src/pages/organization/SettingsPage/components/OrgCertManagerTab/OrgCertManagerTab.tsx b/frontend/src/pages/organization/SettingsPage/components/OrgCertManagerTab/OrgCertManagerTab.tsx
index 7deb47805d..774c8407ce 100644
--- a/frontend/src/pages/organization/SettingsPage/components/OrgCertManagerTab/OrgCertManagerTab.tsx
+++ b/frontend/src/pages/organization/SettingsPage/components/OrgCertManagerTab/OrgCertManagerTab.tsx
@@ -78,24 +78,28 @@ export const OrgCertManagerTab = () => {
<Table>
<TableHeader>
<TableRow>
- <TableHead>Name</TableHead>
- <TableHead className="text-right">Certificates</TableHead>
- <TableHead className="text-right">Syncs</TableHead>
- <TableHead className="text-right">Alerts</TableHead>
- <TableHead className="text-right">Action</TableHead>
+ <TableHead className="w-full">Name</TableHead>
+ <TableHead className="text-right whitespace-nowrap">Certificates</TableHead>
+ <TableHead className="text-right whitespace-nowrap">Syncs</TableHead>
+ <TableHead className="text-right whitespace-nowrap">Alerts</TableHead>
+ <TableHead className="text-right whitespace-nowrap">Action</TableHead>
</TableRow>
</TableHeader>
<TableBody>
{data.instances.map((i) => (
<TableRow key={i.id}>
- <TableCell isTruncatable>
- <div className="font-medium text-foreground">{i.name}</div>
- <div className="font-mono text-xs text-accent">{i.slug}</div>
+ <TableCell className="w-full">
+ <div className="flex flex-wrap items-baseline gap-x-2 gap-y-0.5">
+ <span className="font-medium text-foreground">{i.name}</span>
+ <span className="font-mono text-xs text-accent">{i.slug}</span>
+ </div>
</TableCell>
- <TableCell className="text-right">{i.certificateCount}</TableCell>
- <TableCell className="text-right">{i.syncCount}</TableCell>
- <TableCell className="text-right">{i.alertCount}</TableCell>
- <TableCell className="text-right">
+ <TableCell className="text-right whitespace-nowrap">
+ {i.certificateCount}
+ </TableCell>
+ <TableCell className="text-right whitespace-nowrap">{i.syncCount}</TableCell>
+ <TableCell className="text-right whitespace-nowrap">{i.alertCount}</TableCell>
+ <TableCell className="text-right whitespace-nowrap">
{i.isActive ? (
<Badge variant="success">Active</Badge>
) : (
diff --git a/frontend/src/pages/project/AccessControlPage/components/GroupsTab/components/GroupsSection/GroupsSection.tsx b/frontend/src/pages/project/AccessControlPage/components/GroupsTab/components/GroupsSection/GroupsSection.tsx
index 94140c1d68..e4238d9a06 100644
--- a/frontend/src/pages/project/AccessControlPage/components/GroupsTab/components/GroupsSection/GroupsSection.tsx
+++ b/frontend/src/pages/project/AccessControlPage/components/GroupsTab/components/GroupsSection/GroupsSection.tsx
@@ -88,7 +88,7 @@ export const GroupsSection = () => {
isDisabled={!isAllowed}
>
<PlusIcon />
- {`Add Group to ${productLabel}`}
+ {isCertManager ? "Add Group" : `Add Group to ${productLabel}`}
</Button>
)}
</ProjectPermissionCan>
diff --git a/frontend/src/pages/project/AccessControlPage/components/IdentityTab/IdentityTab.tsx b/frontend/src/pages/project/AccessControlPage/components/IdentityTab/IdentityTab.tsx
index 1e0d5d9c3c..11578fee7b 100644
--- a/frontend/src/pages/project/AccessControlPage/components/IdentityTab/IdentityTab.tsx
+++ b/frontend/src/pages/project/AccessControlPage/components/IdentityTab/IdentityTab.tsx
@@ -245,7 +245,9 @@ export const IdentityTab = withProjectPermission(
isDisabled={!isAllowed}
>
<PlusIcon />
- {`Add Machine Identity to ${productLabel}`}
+ {isCertManager
+ ? "Add Machine Identity"
+ : `Add Machine Identity to ${productLabel}`}
</Button>
)}
</ProjectPermissionCan>
diff --git a/frontend/src/pages/project/AccessControlPage/components/MembersTab/components/MembersSection.tsx b/frontend/src/pages/project/AccessControlPage/components/MembersTab/components/MembersSection.tsx
index 5af78b42ef..3cf3765f9e 100644
--- a/frontend/src/pages/project/AccessControlPage/components/MembersTab/components/MembersSection.tsx
+++ b/frontend/src/pages/project/AccessControlPage/components/MembersTab/components/MembersSection.tsx
@@ -78,7 +78,7 @@ export const MembersSection = () => {
isDisabled={!isAllowed}
>
<UserPlusIcon />
- {`Add Users to ${productLabel}`}
+ {isCertManager ? "Add Users" : `Add Users to ${productLabel}`}
</Button>
)}
</ProjectPermissionCan>
diff --git a/frontend/src/pages/project/AuditLogsPage/AuditLogsPage.tsx b/frontend/src/pages/project/AuditLogsPage/AuditLogsPage.tsx
index 9c71bec421..e8fe188467 100644
--- a/frontend/src/pages/project/AuditLogsPage/AuditLogsPage.tsx
+++ b/frontend/src/pages/project/AuditLogsPage/AuditLogsPage.tsx
@@ -4,22 +4,24 @@ import { InfoIcon } from "lucide-react";
import { PageHeader } from "@app/components/v2";
import { useOrganization, useProject } from "@app/context";
+import { ProjectType } from "@app/hooks/api/projects/types";
import { LogsSection } from "@app/pages/organization/AuditLogsPage/components";
export const AuditLogsPage = () => {
const { currentProject } = useProject();
const { isSubOrganization } = useOrganization();
+ const isCertManager = currentProject.type === ProjectType.CertificateManager;
return (
<div className="mx-auto flex flex-col justify-between bg-bunker-800 text-white">
<Helmet>
- <title>Project Audit Logs</title>
+ <title>{isCertManager ? "Audit Logs" : "Project Audit Logs"}</title>
<link rel="icon" href="/infisical.ico" />
</Helmet>
<div className="flex h-full w-full justify-center bg-bunker-800 text-white">
<div className="w-full max-w-8xl">
<PageHeader
scope={currentProject.type}
- title="Project Audit logs"
+ title={isCertManager ? "Audit logs" : "Project Audit logs"}
description="Audit logs for security and compliance teams to monitor information access."
>
<Link
diff --git a/frontend/src/pages/project/GroupDetailsByIDPage/GroupDetailsByIDPage.tsx b/frontend/src/pages/project/GroupDetailsByIDPage/GroupDetailsByIDPage.tsx
index 06be2021d9..54fbac14ae 100644
--- a/frontend/src/pages/project/GroupDetailsByIDPage/GroupDetailsByIDPage.tsx
+++ b/frontend/src/pages/project/GroupDetailsByIDPage/GroupDetailsByIDPage.tsx
@@ -23,6 +23,7 @@ import { getProjectBaseURL } from "@app/helpers/project";
import { usePopUp } from "@app/hooks";
import { useDeleteGroupFromWorkspace } from "@app/hooks/api";
import { useGetWorkspaceGroupMembershipDetails } from "@app/hooks/api/projects/queries";
+import { ProjectType } from "@app/hooks/api/projects/types";
import { ProjectAccessControlTabs } from "@app/types/project";
import { GroupDetailsSection } from "./components/GroupDetailsSection";
@@ -80,6 +81,8 @@ const Page = () => {
</div>
);
+ const isCertManager = currentProject?.type === ProjectType.CertificateManager;
+
return (
<div className="mx-auto flex max-w-8xl flex-col">
{groupMembership ? (
@@ -96,12 +99,16 @@ const Page = () => {
className="mb-4 flex w-fit items-center gap-x-1 text-sm text-mineshaft-400 transition duration-100 hover:text-mineshaft-400/80"
>
<ChevronLeftIcon size={16} />
- Project Groups
+ {isCertManager ? "Cert Manager Groups" : "Project Groups"}
</Link>
<PageHeader
scope={currentProject.type}
title={groupMembership.group.name}
- description="Configure and manage project access control"
+ description={
+ isCertManager
+ ? "Configure and manage cert manager access control"
+ : "Configure and manage project access control"
+ }
>
<DropdownMenu>
<DropdownMenuTrigger asChild>
diff --git a/frontend/src/pages/project/GroupDetailsByIDPage/components/GroupDetailsSection.tsx b/frontend/src/pages/project/GroupDetailsByIDPage/components/GroupDetailsSection.tsx
index 819a1b1b16..c5d2e100be 100644
--- a/frontend/src/pages/project/GroupDetailsByIDPage/components/GroupDetailsSection.tsx
+++ b/frontend/src/pages/project/GroupDetailsByIDPage/components/GroupDetailsSection.tsx
@@ -15,9 +15,10 @@ import {
DetailValue,
IconButton
} from "@app/components/v3";
-import { ProjectPermissionActions, ProjectPermissionSub } from "@app/context";
+import { ProjectPermissionActions, ProjectPermissionSub, useProject } from "@app/context";
import { useTimedReset } from "@app/hooks";
import { TGroupMembership } from "@app/hooks/api/groups/types";
+import { ProjectType } from "@app/hooks/api/projects/types";
import { GroupRoles } from "@app/pages/project/AccessControlPage/components/GroupsTab/components/GroupsSection/GroupRoles";
type Props = {
@@ -26,6 +27,8 @@ type Props = {
export const GroupDetailsSection = ({ groupMembership }: Props) => {
const { group } = groupMembership;
+ const { currentProject } = useProject();
+ const isCertManager = currentProject?.type === ProjectType.CertificateManager;
// eslint-disable-next-line @typescript-eslint/naming-convention,@typescript-eslint/no-unused-vars
const [_, isCopyingId, setCopyTextId] = useTimedReset<string>({
@@ -64,7 +67,7 @@ export const GroupDetailsSection = ({ groupMembership }: Props) => {
</DetailValue>
</Detail>
<Detail>
- <DetailLabel>Project Role</DetailLabel>
+ <DetailLabel>{isCertManager ? "Cert Manager Role" : "Project Role"}</DetailLabel>
<DetailValue>
<ProjectPermissionCan
I={ProjectPermissionActions.Edit}
@@ -82,7 +85,7 @@ export const GroupDetailsSection = ({ groupMembership }: Props) => {
</DetailValue>
</Detail>
<Detail>
- <DetailLabel>Joined project</DetailLabel>
+ <DetailLabel>{isCertManager ? "Joined cert manager" : "Joined project"}</DetailLabel>
<DetailValue>{format(groupMembership.createdAt, "PPpp")}</DetailValue>
</Detail>
</DetailGroup>
diff --git a/frontend/src/pages/project/IdentityDetailsByIDPage/IdentityDetailsByIDPage.tsx b/frontend/src/pages/project/IdentityDetailsByIDPage/IdentityDetailsByIDPage.tsx
index 86d3db80a8..24be278813 100644
--- a/frontend/src/pages/project/IdentityDetailsByIDPage/IdentityDetailsByIDPage.tsx
+++ b/frontend/src/pages/project/IdentityDetailsByIDPage/IdentityDetailsByIDPage.tsx
@@ -50,6 +50,7 @@ import {
} from "@app/hooks/api";
import { ActorType } from "@app/hooks/api/auditLogs/enums";
import { projectIdentityQuery, useDeleteProjectIdentity } from "@app/hooks/api/projectIdentity";
+import { ProjectType } from "@app/hooks/api/projects/types";
import { ProjectIdentityAuthenticationSection } from "@app/pages/project/IdentityDetailsByIDPage/components/ProjectIdentityAuthSection";
import { ProjectIdentityDetailsSection } from "@app/pages/project/IdentityDetailsByIDPage/components/ProjectIdentityDetailsSection";
import { ProjectAccessControlTabs } from "@app/types/project";
@@ -72,6 +73,7 @@ const Page = () => {
const { mutateAsync: removeIdentityMutateAsync } = useDeleteProjectIdentityMembership();
const isProjectIdentity = Boolean(identityMembershipDetails?.identity.projectId);
+ const isCertManager = currentProject?.type === ProjectType.CertificateManager;
const {
data: identity,
@@ -187,11 +189,15 @@ const Page = () => {
className="mb-4 flex w-fit items-center gap-x-1 text-sm text-mineshaft-400 transition duration-100 hover:text-mineshaft-400/80"
>
<ChevronLeftIcon size={16} />
- Project Machine Identities
+ {isCertManager ? "Cert Manager Machine Identities" : "Project Machine Identities"}
</Link>
<PageHeader
scope={currentProject.type}
- description={`Configure and manage${isProjectIdentity ? " machine identity and " : " "}project access control`}
+ description={
+ isCertManager
+ ? `Configure and manage${isProjectIdentity ? " machine identity and " : " "}cert manager access control`
+ : `Configure and manage${isProjectIdentity ? " machine identity and " : " "}project access control`
+ }
title={identityMembershipDetails.identity.name}
>
<DropdownMenu>
diff --git a/frontend/src/pages/project/IdentityDetailsByIDPage/components/IdentityProjectAdditionalPrivilegeSection/IdentityProjectAdditionalPrivilegeSection.tsx b/frontend/src/pages/project/IdentityDetailsByIDPage/components/IdentityProjectAdditionalPrivilegeSection/IdentityProjectAdditionalPrivilegeSection.tsx
index c6149b455d..d00a676f44 100644
--- a/frontend/src/pages/project/IdentityDetailsByIDPage/components/IdentityProjectAdditionalPrivilegeSection/IdentityProjectAdditionalPrivilegeSection.tsx
+++ b/frontend/src/pages/project/IdentityDetailsByIDPage/components/IdentityProjectAdditionalPrivilegeSection/IdentityProjectAdditionalPrivilegeSection.tsx
@@ -52,6 +52,7 @@ import { usePopUp } from "@app/hooks";
import { useDeleteIdentityProjectAdditionalPrivilege } from "@app/hooks/api";
import { IdentityProjectMembershipV1 } from "@app/hooks/api/identities/types";
import { useListIdentityProjectPrivileges } from "@app/hooks/api/identityProjectAdditionalPrivilege/queries";
+import { ProjectType } from "@app/hooks/api/projects/types";
import {
canModifyByGrantConditions,
getIdentityAssignPrivilegesConditions
@@ -71,7 +72,8 @@ export const IdentityProjectAdditionalPrivilegeSection = ({ identityMembershipDe
] as const);
const { permission } = useProjectPermission();
const identityId = identityMembershipDetails?.identity?.id;
- const { projectId } = useProject();
+ const { projectId, currentProject } = useProject();
+ const isCertManager = currentProject?.type === ProjectType.CertificateManager;
const { mutateAsync: deletePrivilege } = useDeleteIdentityProjectAdditionalPrivilege();
@@ -114,7 +116,7 @@ export const IdentityProjectAdditionalPrivilegeSection = ({ identityMembershipDe
<Card>
<CardHeader>
<CardTitle>
- Project Additional Privileges
+ {isCertManager ? "Cert Manager Additional Privileges" : "Project Additional Privileges"}
<DocumentationLinkBadge href="https://infisical.com/docs/documentation/platform/access-controls/additional-privileges#api" />
</CardTitle>
<CardDescription>Assign one-off policies to this machine identity</CardDescription>
diff --git a/frontend/src/pages/project/IdentityDetailsByIDPage/components/IdentityRoleDetailsSection/IdentityRoleDetailsSection.tsx b/frontend/src/pages/project/IdentityDetailsByIDPage/components/IdentityRoleDetailsSection/IdentityRoleDetailsSection.tsx
index eba35e0476..b57015f588 100644
--- a/frontend/src/pages/project/IdentityDetailsByIDPage/components/IdentityRoleDetailsSection/IdentityRoleDetailsSection.tsx
+++ b/frontend/src/pages/project/IdentityDetailsByIDPage/components/IdentityRoleDetailsSection/IdentityRoleDetailsSection.tsx
@@ -47,6 +47,7 @@ import { formatProjectRoleName } from "@app/helpers/roles";
import { usePopUp } from "@app/hooks";
import { useUpdateProjectIdentityMembership } from "@app/hooks/api";
import { IdentityProjectMembershipV1 } from "@app/hooks/api/identities/types";
+import { ProjectType } from "@app/hooks/api/projects/types";
import { TProjectRole } from "@app/hooks/api/roles/types";
import {
canModifyByGrantConditions,
@@ -125,12 +126,13 @@ export const IdentityRoleDetailsSection = ({
};
const hasRoles = Boolean(identityMembershipDetails?.roles.length);
+ const isCertManager = currentProject?.type === ProjectType.CertificateManager;
return (
<>
<Card>
<CardHeader>
- <CardTitle>Project Roles</CardTitle>
+ <CardTitle>{isCertManager ? "Cert Manager Roles" : "Project Roles"}</CardTitle>
<CardDescription>Manage roles assigned to this machine identity</CardDescription>
{hasRoles && (
<CardAction>
diff --git a/frontend/src/pages/project/IdentityDetailsByIDPage/components/ProjectIdentityDetailsSection.tsx b/frontend/src/pages/project/IdentityDetailsByIDPage/components/ProjectIdentityDetailsSection.tsx
index d037bdf72d..b360ae6725 100644
--- a/frontend/src/pages/project/IdentityDetailsByIDPage/components/ProjectIdentityDetailsSection.tsx
+++ b/frontend/src/pages/project/IdentityDetailsByIDPage/components/ProjectIdentityDetailsSection.tsx
@@ -22,10 +22,11 @@ import {
ProjectIcon,
SubOrgIcon
} from "@app/components/v3";
-import { ProjectPermissionIdentityActions, ProjectPermissionSub } from "@app/context";
+import { ProjectPermissionIdentityActions, ProjectPermissionSub, useProject } from "@app/context";
import { usePopUp, useTimedReset } from "@app/hooks";
import { identityAuthToNameMap, TProjectIdentity } from "@app/hooks/api";
import { IdentityProjectMembershipV1 } from "@app/hooks/api/identities/types";
+import { ProjectType } from "@app/hooks/api/projects/types";
import { ProjectIdentityModal } from "@app/pages/project/AccessControlPage/components/IdentityTab/components/ProjectIdentityModal";
type Props = {
@@ -41,6 +42,9 @@ export const ProjectIdentityDetailsSection = ({
isSubOrgIdentity,
membership
}: Props) => {
+ const { currentProject } = useProject();
+ const isCertManager = currentProject?.type === ProjectType.CertificateManager;
+
// eslint-disable-next-line @typescript-eslint/naming-convention,@typescript-eslint/no-unused-vars
const [_, isCopyingId, setCopyTextId] = useTimedReset<string>({
initialState: "Copy ID to clipboard"
@@ -139,7 +143,14 @@ export const ProjectIdentityDetailsSection = ({
</DetailValue>
</Detail>
<Detail>
- <DetailLabel>{isOrgIdentity ? "Joined project" : "Created"}</DetailLabel>
+ <DetailLabel>
+ {/* eslint-disable-next-line no-nested-ternary */}
+ {isOrgIdentity
+ ? isCertManager
+ ? "Joined cert manager"
+ : "Joined project"
+ : "Created"}
+ </DetailLabel>
<DetailValue>{format(membership.createdAt, "PPpp")}</DetailValue>
</Detail>
{!isOrgIdentity && (
diff --git a/frontend/src/pages/project/MemberDetailsByIDPage/MemberDetailsByIDPage.tsx b/frontend/src/pages/project/MemberDetailsByIDPage/MemberDetailsByIDPage.tsx
index 0a2ce37c78..25c5005578 100644
--- a/frontend/src/pages/project/MemberDetailsByIDPage/MemberDetailsByIDPage.tsx
+++ b/frontend/src/pages/project/MemberDetailsByIDPage/MemberDetailsByIDPage.tsx
@@ -40,6 +40,7 @@ import {
useGetWorkspaceUserDetails
} from "@app/hooks/api";
import { ActorType } from "@app/hooks/api/auditLogs/enums";
+import { ProjectType } from "@app/hooks/api/projects/types";
import { ProjectAccessControlTabs } from "@app/types/project";
import { MemberProjectAdditionalPrivilegeSection } from "./components/MemberProjectAdditionalPrivilegeSection";
@@ -126,6 +127,7 @@ export const Page = () => {
}
const isOwnProjectMembershipDetails = currentUserId === membershipDetails?.user?.id;
+ const isCertManager = currentProject?.type === ProjectType.CertificateManager;
return (
<div className="mx-auto flex max-w-8xl flex-col">
@@ -143,7 +145,7 @@ export const Page = () => {
className="mb-4 flex w-fit items-center gap-x-1 text-sm text-mineshaft-400 transition duration-100 hover:text-mineshaft-400/80"
>
<FontAwesomeIcon icon={faChevronLeft} />
- Project Users
+ {isCertManager ? "Cert Manager Users" : "Project Users"}
</Link>
<PageHeader
scope={currentProject.type}
@@ -155,7 +157,11 @@ export const Page = () => {
membershipDetails.inviteEmail ||
"Unnamed User"
}
- description="Configure and manage project access control"
+ description={
+ isCertManager
+ ? "Configure and manage cert manager access control"
+ : "Configure and manage project access control"
+ }
>
{isOwnProjectMembershipDetails ? (
<Tooltip
diff --git a/frontend/src/pages/project/MemberDetailsByIDPage/components/MemberProjectAdditionalPrivilegeSection/MemberProjectAdditionalPrivilegeSection.tsx b/frontend/src/pages/project/MemberDetailsByIDPage/components/MemberProjectAdditionalPrivilegeSection/MemberProjectAdditionalPrivilegeSection.tsx
index 1ceea1b40a..7ccc47687a 100644
--- a/frontend/src/pages/project/MemberDetailsByIDPage/components/MemberProjectAdditionalPrivilegeSection/MemberProjectAdditionalPrivilegeSection.tsx
+++ b/frontend/src/pages/project/MemberDetailsByIDPage/components/MemberProjectAdditionalPrivilegeSection/MemberProjectAdditionalPrivilegeSection.tsx
@@ -56,6 +56,7 @@ import {
useListProjectUserPrivileges,
useRevokeAccessRequest
} from "@app/hooks/api";
+import { ProjectType } from "@app/hooks/api/projects/types";
import { projectUserPrivilegeKeys } from "@app/hooks/api/projectUserAdditionalPrivilege/queries";
import { TWorkspaceUser } from "@app/hooks/api/types";
import {
@@ -134,13 +135,14 @@ export const MemberProjectAdditionalPrivilegeSection = ({ membershipDetails }: P
};
const hasAdditionalPrivileges = Boolean(userProjectPrivileges?.length);
+ const isCertManager = currentProject?.type === ProjectType.CertificateManager;
return (
<>
<Card>
<CardHeader>
<CardTitle>
- Project Additional Privileges
+ {isCertManager ? "Cert Manager Additional Privileges" : "Project Additional Privileges"}
<DocumentationLinkBadge href="https://infisical.com/docs/documentation/platform/access-controls/additional-privileges#api" />
</CardTitle>
<CardDescription>Assign one-off policies to this user</CardDescription>
diff --git a/frontend/src/pages/project/MemberDetailsByIDPage/components/MemberRoleDetailsSection/MemberRoleDetailsSection.tsx b/frontend/src/pages/project/MemberDetailsByIDPage/components/MemberRoleDetailsSection/MemberRoleDetailsSection.tsx
index e0d1407cda..693d1d82b9 100644
--- a/frontend/src/pages/project/MemberDetailsByIDPage/components/MemberRoleDetailsSection/MemberRoleDetailsSection.tsx
+++ b/frontend/src/pages/project/MemberDetailsByIDPage/components/MemberRoleDetailsSection/MemberRoleDetailsSection.tsx
@@ -47,6 +47,7 @@ import { getProjectBaseURL } from "@app/helpers/project";
import { formatProjectRoleName } from "@app/helpers/roles";
import { usePopUp } from "@app/hooks";
import { useUpdateUserWorkspaceRole } from "@app/hooks/api";
+import { ProjectType } from "@app/hooks/api/projects/types";
import { TProjectRole } from "@app/hooks/api/roles/types";
import { TWorkspaceUser } from "@app/hooks/api/types";
import { canModifyByGrantConditions, getMemberAssignRoleConditions } from "@app/lib/fn/permission";
@@ -132,12 +133,13 @@ export const MemberRoleDetailsSection = ({
};
const hasRoles = Boolean(membershipDetails?.roles.length);
+ const isCertManager = currentProject?.type === ProjectType.CertificateManager;
return (
<>
<Card>
<CardHeader>
- <CardTitle>Project Roles</CardTitle>
+ <CardTitle>{isCertManager ? "Cert Manager Roles" : "Project Roles"}</CardTitle>
<CardDescription>Manage roles assigned to this user</CardDescription>
{!isOwnProjectMembershipDetails && hasRoles && (
<CardAction>
diff --git a/frontend/src/pages/project/MemberDetailsByIDPage/components/ProjectMemberDetailsSection.tsx b/frontend/src/pages/project/MemberDetailsByIDPage/components/ProjectMemberDetailsSection.tsx
index 3adbebcd01..bf0fe9e82d 100644
--- a/frontend/src/pages/project/MemberDetailsByIDPage/components/ProjectMemberDetailsSection.tsx
+++ b/frontend/src/pages/project/MemberDetailsByIDPage/components/ProjectMemberDetailsSection.tsx
@@ -14,7 +14,9 @@ import {
DetailValue,
IconButton
} from "@app/components/v3";
+import { useProject } from "@app/context";
import { useTimedReset } from "@app/hooks";
+import { ProjectType } from "@app/hooks/api/projects/types";
import { TWorkspaceUser } from "@app/hooks/api/types";
type Props = {
@@ -22,6 +24,9 @@ type Props = {
};
export const ProjectMemberDetailsSection = ({ membership }: Props) => {
+ const { currentProject } = useProject();
+ const isCertManager = currentProject?.type === ProjectType.CertificateManager;
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/naming-convention
const [_copyId, isCopyingId, setCopyTextId] = useTimedReset<string>({
initialState: "Copy ID to clipboard"
@@ -95,7 +100,7 @@ export const ProjectMemberDetailsSection = ({ membership }: Props) => {
</Detail>
)}
<Detail>
- <DetailLabel>Joined project</DetailLabel>
+ <DetailLabel>{isCertManager ? "Joined cert manager" : "Joined project"}</DetailLabel>
<DetailValue>{format(membership.createdAt, "PPpp")}</DetailValue>
</Detail>
</DetailGroup>
diff --git a/frontend/src/views/PkiAlertsV2Page/components/CreatePkiAlertV2Modal.tsx b/frontend/src/views/PkiAlertsV2Page/components/CreatePkiAlertV2Modal.tsx
index 50bca37173..917d03bdbc 100644
--- a/frontend/src/views/PkiAlertsV2Page/components/CreatePkiAlertV2Modal.tsx
+++ b/frontend/src/views/PkiAlertsV2Page/components/CreatePkiAlertV2Modal.tsx
@@ -349,7 +349,7 @@ export const CreatePkiAlertV2Modal = ({
<div className="flex-1 overflow-y-auto">
<FormProvider {...formMethods}>
<Tab.Group selectedIndex={selectedTabIndex} onChange={setSelectedTabIndex}>
- <Tab.List className="-pb-1 mb-6 flex w-full justify-center border-b-2 border-mineshaft-600">
+ <Tab.List className="-pb-1 mb-6 flex w-full justify-start border-b-2 border-mineshaft-600">
{formTabs.map((tab, index) => (
<Tab
onClick={async (e) => {