Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
Add list cert, ca + logical filters to docs
Tuan Dang2348df7a4d48
diff --git a/backend/src/server/routes/v2/project-router.ts b/backend/src/server/routes/v2/project-router.tsindex e1c7c2e696..76286c8337 100644--- a/backend/src/server/routes/v2/project-router.ts+++ b/backend/src/server/routes/v2/project-router.ts@@ -320,7 +320,11 @@ export const registerProjectRouter = async (server: FastifyZodProvider) => {slug: slugSchema.describe("The slug of the project to list CAs.")}),querystring: z.object({- status: z.enum([CaStatus.ACTIVE, CaStatus.PENDING_CERTIFICATE]).optional()+ status: z.enum([CaStatus.ACTIVE, CaStatus.PENDING_CERTIFICATE]).optional(),+ friendlyName: z.string().optional(),+ commonName: z.string().optional(),+ offset: z.coerce.number().min(0).max(100).default(0),+ limit: z.coerce.number().min(1).max(100).default(25)}),response: {200: z.object({@@ -336,11 +340,11 @@ export const registerProjectRouter = async (server: FastifyZodProvider) => {orgId: req.permission.orgId,type: ProjectFilterType.SLUG},- status: req.query.status,actorId: req.permission.id,actorOrgId: req.permission.orgId,actorAuthMethod: req.permission.authMethod,- actor: req.permission.type+ actor: req.permission.type,+ ...req.query});return { cas };}@@ -357,6 +361,8 @@ export const registerProjectRouter = async (server: FastifyZodProvider) => {slug: slugSchema.describe("The slug of the project to list certificates.")}),querystring: z.object({+ friendlyName: z.string().optional(),+ commonName: z.string().optional(),offset: z.coerce.number().min(0).max(100).default(0),limit: z.coerce.number().min(1).max(100).default(25)}),diff --git a/backend/src/services/certificate/certificate-dal.ts b/backend/src/services/certificate/certificate-dal.tsindex 67dca3aca7..71c70838c8 100644--- a/backend/src/services/certificate/certificate-dal.ts+++ b/backend/src/services/certificate/certificate-dal.ts@@ -8,19 +8,35 @@ export type TCertificateDALFactory = ReturnType<typeof certificateDALFactory>;export const certificateDALFactory = (db: TDbClient) => {const certificateOrm = ormify(db, TableName.Certificate);- const countCertificatesInProject = async (projectId: string) => {+ const countCertificatesInProject = async ({+ projectId,+ friendlyName,+ commonName+ }: {+ projectId: string;+ friendlyName?: string;+ commonName?: string;+ }) => {try {interface CountResult {count: string;}- const count = await db+ let query = db.replicaNode()(TableName.Certificate).join(TableName.CertificateAuthority, `${TableName.Certificate}.caId`, `${TableName.CertificateAuthority}.id`).join(TableName.Project, `${TableName.CertificateAuthority}.projectId`, `${TableName.Project}.id`)- .where(`${TableName.Project}.id`, projectId)- .count("*")- .first();+ .where(`${TableName.Project}.id`, projectId);++ if (friendlyName) {+ query = query.andWhere(`${TableName.Certificate}.friendlyName`, friendlyName);+ }++ if (commonName) {+ query = query.andWhere(`${TableName.Certificate}.commonName`, commonName);+ }++ const count = await query.count("*").first();return parseInt((count as unknown as CountResult).count || "0", 10);} catch (error) {diff --git a/backend/src/services/project/project-service.ts b/backend/src/services/project/project-service.tsindex 981f90bb6c..2cd9ed94cc 100644--- a/backend/src/services/project/project-service.ts+++ b/backend/src/services/project/project-service.ts@@ -575,6 +575,10 @@ export const projectServiceFactory = ({*/const listProjectCas = async ({status,+ friendlyName,+ commonName,+ limit = 20,+ offset = 0,actorId,actorOrgId,actorAuthMethod,@@ -596,10 +600,15 @@ export const projectServiceFactory = ({ProjectPermissionSub.CertificateAuthorities);- const cas = await certificateAuthorityDAL.find({- projectId: project.id,- ...(status && { status })- });+ const cas = await certificateAuthorityDAL.find(+ {+ projectId: project.id,+ ...(status && { status }),+ ...(friendlyName && { friendlyName }),+ ...(commonName && { commonName })+ },+ { offset, limit, sort: [["updatedAt", "desc"]] }+ );return cas;};@@ -608,8 +617,10 @@ export const projectServiceFactory = ({* Return list of certificates for project*/const listProjectCertificates = async ({- offset,- limit,+ offset = 20,+ limit = 0,+ friendlyName,+ commonName,actorId,actorOrgId,actorAuthMethod,@@ -634,12 +645,18 @@ export const projectServiceFactory = ({{$in: {caId: cas.map((ca) => ca.id)- }+ },+ ...(friendlyName && { friendlyName }),+ ...(commonName && { commonName })},{ offset, limit, sort: [["updatedAt", "desc"]] });- const count = await certificateDAL.countCertificatesInProject(project.id);+ const count = await certificateDAL.countCertificatesInProject({+ projectId: project.id,+ friendlyName,+ commonName+ });return {certificates,diff --git a/backend/src/services/project/project-types.ts b/backend/src/services/project/project-types.tsindex eb08fba982..c49e511432 100644--- a/backend/src/services/project/project-types.ts+++ b/backend/src/services/project/project-types.ts@@ -89,6 +89,10 @@ export type AddUserToWsDTO = {export type TListProjectCasDTO = {status?: CaStatus;+ friendlyName?: string;+ offset?: number;+ limit?: number;+ commonName?: string;filter: Filter;} & Omit<TProjectPermission, "projectId">;@@ -96,4 +100,6 @@ export type TListProjectCertsDTO = {filter: Filter;offset: number;limit: number;+ friendlyName?: string;+ commonName?: string;} & Omit<TProjectPermission, "projectId">;diff --git a/docs/api-reference/endpoints/certificate-authorities/list.mdx b/docs/api-reference/endpoints/certificate-authorities/list.mdxnew file mode 100644index 0000000000..ba4a433489--- /dev/null+++ b/docs/api-reference/endpoints/certificate-authorities/list.mdx@@ -0,0 +1,4 @@+---+title: "List"+openapi: "GET /api/v2/workspace/{slug}/cas"+---diff --git a/docs/api-reference/endpoints/certificates/list.mdx b/docs/api-reference/endpoints/certificates/list.mdxnew file mode 100644index 0000000000..67a4623a4c--- /dev/null+++ b/docs/api-reference/endpoints/certificates/list.mdx@@ -0,0 +1,4 @@+---+title: "List"+openapi: "GET /api/v2/workspace/{slug}/certificates"+---diff --git a/docs/mint.json b/docs/mint.jsonindex 2898d949b0..6628316f89 100644--- a/docs/mint.json+++ b/docs/mint.json@@ -654,6 +654,7 @@{"group": "Certificate Authorities","pages": [+ "api-reference/endpoints/certificate-authorities/list","api-reference/endpoints/certificate-authorities/create","api-reference/endpoints/certificate-authorities/read","api-reference/endpoints/certificate-authorities/update",@@ -669,6 +670,7 @@{"group": "Certificates","pages": [+ "api-reference/endpoints/certificates/list","api-reference/endpoints/certificates/read","api-reference/endpoints/certificates/revoke","api-reference/endpoints/certificates/delete",