mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-15 22:46:24 +00:00
Rename pki alerting structures
This commit is contained in:
@@ -73,8 +73,6 @@ import { TKeyStoreFactory } from "@app/keystore/keystore";
|
||||
import { getConfig } from "@app/lib/config/env";
|
||||
import { TQueueServiceFactory } from "@app/queue";
|
||||
import { readLimit } from "@app/server/config/rateLimiter";
|
||||
import { alertDALFactory } from "@app/services/alert/alert-dal";
|
||||
import { alertServiceFactory } from "@app/services/alert/alert-service";
|
||||
import { apiKeyDALFactory } from "@app/services/api-key/api-key-dal";
|
||||
import { apiKeyServiceFactory } from "@app/services/api-key/api-key-service";
|
||||
import { authDALFactory } from "@app/services/auth/auth-dal";
|
||||
@@ -133,7 +131,10 @@ import { orgRoleServiceFactory } from "@app/services/org/org-role-service";
|
||||
import { orgServiceFactory } from "@app/services/org/org-service";
|
||||
import { orgAdminServiceFactory } from "@app/services/org-admin/org-admin-service";
|
||||
import { orgMembershipDALFactory } from "@app/services/org-membership/org-membership-dal";
|
||||
import { pkiAlertDALFactory } from "@app/services/pki-alert/pki-alert-dal";
|
||||
import { pkiAlertServiceFactory } from "@app/services/pki-alert/pki-alert-service";
|
||||
import { pkiCollectionDALFactory } from "@app/services/pki-collection/pki-collection-dal";
|
||||
import { pkiCollectionItemDALFactory } from "@app/services/pki-collection/pki-collection-item-dal";
|
||||
import { pkiCollectionServiceFactory } from "@app/services/pki-collection/pki-collection-service";
|
||||
import { projectDALFactory } from "@app/services/project/project-dal";
|
||||
import { projectQueueFactory } from "@app/services/project/project-queue";
|
||||
@@ -220,7 +221,6 @@ export const registerRoutes = async (
|
||||
const superAdminDAL = superAdminDALFactory(db);
|
||||
const rateLimitDAL = rateLimitDALFactory(db);
|
||||
const apiKeyDAL = apiKeyDALFactory(db);
|
||||
const alertDAL = alertDALFactory(db);
|
||||
|
||||
const projectDAL = projectDALFactory(db);
|
||||
const projectMembershipDAL = projectMembershipDALFactory(db);
|
||||
@@ -588,7 +588,9 @@ export const registerRoutes = async (
|
||||
const certificateDAL = certificateDALFactory(db);
|
||||
const certificateBodyDAL = certificateBodyDALFactory(db);
|
||||
|
||||
const pkiAlertDAL = pkiAlertDALFactory(db);
|
||||
const pkiCollectionDAL = pkiCollectionDALFactory(db);
|
||||
const pkiCollectionItemDAL = pkiCollectionItemDALFactory(db);
|
||||
|
||||
const certificateService = certificateServiceFactory({
|
||||
certificateDAL,
|
||||
@@ -634,14 +636,17 @@ export const registerRoutes = async (
|
||||
licenseService
|
||||
});
|
||||
|
||||
const alertService = alertServiceFactory({
|
||||
alertDAL,
|
||||
const pkiAlertService = pkiAlertServiceFactory({
|
||||
pkiAlertDAL,
|
||||
pkiCollectionDAL,
|
||||
permissionService
|
||||
});
|
||||
|
||||
const pkiCollectionService = pkiCollectionServiceFactory({
|
||||
pkiCollectionDAL,
|
||||
pkiCollectionItemDAL,
|
||||
certificateAuthorityDAL,
|
||||
certificateDAL,
|
||||
permissionService
|
||||
});
|
||||
|
||||
@@ -661,7 +666,7 @@ export const registerRoutes = async (
|
||||
licenseService,
|
||||
certificateAuthorityDAL,
|
||||
certificateDAL,
|
||||
alertDAL,
|
||||
pkiAlertDAL,
|
||||
pkiCollectionDAL,
|
||||
projectUserMembershipRoleDAL,
|
||||
identityProjectMembershipRoleDAL,
|
||||
@@ -1091,7 +1096,6 @@ export const registerRoutes = async (
|
||||
orgRole: orgRoleService,
|
||||
oidc: oidcService,
|
||||
apiKey: apiKeyService,
|
||||
alert: alertService,
|
||||
authToken: tokenService,
|
||||
superAdmin: superAdminService,
|
||||
project: projectService,
|
||||
@@ -1135,6 +1139,7 @@ export const registerRoutes = async (
|
||||
certificate: certificateService,
|
||||
certificateAuthority: certificateAuthorityService,
|
||||
certificateAuthorityCrl: certificateAuthorityCrlService,
|
||||
pkiAlert: pkiAlertService,
|
||||
pkiCollection: pkiCollectionService,
|
||||
secretScanning: secretScanningService,
|
||||
license: licenseService,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { z } from "zod";
|
||||
|
||||
import { AlertsSchema } from "@app/db/schemas";
|
||||
import { PkiAlertsSchema } from "@app/db/schemas";
|
||||
import { readLimit, writeLimit } from "@app/server/config/rateLimiter";
|
||||
import { verifyAuth } from "@app/server/plugins/auth/verify-auth";
|
||||
import { AuthMode } from "@app/services/auth/auth-type";
|
||||
@@ -23,11 +23,11 @@ export const registerPkiAlertRouter = async (server: FastifyZodProvider) => {
|
||||
emails: z.array(z.string())
|
||||
}),
|
||||
response: {
|
||||
200: AlertsSchema
|
||||
200: PkiAlertsSchema
|
||||
}
|
||||
},
|
||||
handler: async (req) => {
|
||||
const alert = await server.services.alert.createPkiAlert({
|
||||
const alert = await server.services.pkiAlert.createPkiAlert({
|
||||
actor: req.permission.type,
|
||||
actorId: req.permission.id,
|
||||
actorAuthMethod: req.permission.authMethod,
|
||||
@@ -67,11 +67,11 @@ export const registerPkiAlertRouter = async (server: FastifyZodProvider) => {
|
||||
alertId: z.string().trim()
|
||||
}),
|
||||
response: {
|
||||
200: AlertsSchema
|
||||
200: PkiAlertsSchema
|
||||
}
|
||||
},
|
||||
handler: async (req) => {
|
||||
const alert = await server.services.alert.getPkiAlertById({
|
||||
const alert = await server.services.pkiAlert.getPkiAlertById({
|
||||
alertId: req.params.alertId,
|
||||
actor: req.permission.type,
|
||||
actorId: req.permission.id,
|
||||
@@ -116,11 +116,11 @@ export const registerPkiAlertRouter = async (server: FastifyZodProvider) => {
|
||||
emails: z.array(z.string()).optional()
|
||||
}),
|
||||
response: {
|
||||
200: AlertsSchema
|
||||
200: PkiAlertsSchema
|
||||
}
|
||||
},
|
||||
handler: async (req) => {
|
||||
const alert = await server.services.alert.updatePkiAlert({
|
||||
const alert = await server.services.pkiAlert.updatePkiAlert({
|
||||
alertId: req.params.alertId,
|
||||
actor: req.permission.type,
|
||||
actorId: req.permission.id,
|
||||
@@ -160,11 +160,11 @@ export const registerPkiAlertRouter = async (server: FastifyZodProvider) => {
|
||||
alertId: z.string().trim()
|
||||
}),
|
||||
response: {
|
||||
200: AlertsSchema
|
||||
200: PkiAlertsSchema
|
||||
}
|
||||
},
|
||||
handler: async (req) => {
|
||||
const alert = await server.services.alert.deletePkiAlert({
|
||||
const alert = await server.services.pkiAlert.deletePkiAlert({
|
||||
alertId: req.params.alertId,
|
||||
actor: req.permission.type,
|
||||
actorId: req.permission.id,
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import { z } from "zod";
|
||||
|
||||
import { PkiCollectionsSchema } from "@app/db/schemas";
|
||||
import { PkiCollectionItemsSchema, PkiCollectionsSchema } from "@app/db/schemas";
|
||||
import { readLimit, writeLimit } from "@app/server/config/rateLimiter";
|
||||
import { verifyAuth } from "@app/server/plugins/auth/verify-auth";
|
||||
import { AuthMode } from "@app/services/auth/auth-type";
|
||||
import { PkiItemType } from "@app/services/pki-collection/pki-collection-types";
|
||||
|
||||
export const registerPkiCollectionRouter = async (server: FastifyZodProvider) => {
|
||||
server.route({
|
||||
@@ -184,4 +185,165 @@ export const registerPkiCollectionRouter = async (server: FastifyZodProvider) =>
|
||||
return pkiCollection;
|
||||
}
|
||||
});
|
||||
|
||||
server.route({
|
||||
method: "GET",
|
||||
url: "/:collectionId/items",
|
||||
config: {
|
||||
rateLimit: writeLimit
|
||||
},
|
||||
onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),
|
||||
schema: {
|
||||
description: "Get items in PKI collection",
|
||||
params: z.object({
|
||||
collectionId: z.string().trim()
|
||||
}),
|
||||
querystring: z.object({
|
||||
offset: z.coerce.number().min(0).max(100).default(0),
|
||||
limit: z.coerce.number().min(1).max(100).default(25)
|
||||
}),
|
||||
response: {
|
||||
200: z.object({
|
||||
collectionItems: z.array(
|
||||
PkiCollectionItemsSchema.omit({ caId: true, certId: true }).extend({
|
||||
type: z.nativeEnum(PkiItemType),
|
||||
itemId: z.string().trim()
|
||||
})
|
||||
),
|
||||
totalCount: z.number()
|
||||
})
|
||||
}
|
||||
},
|
||||
handler: async (req) => {
|
||||
const { pkiCollectionItems, totalCount } = await server.services.pkiCollection.getPkiCollectionItems({
|
||||
collectionId: req.params.collectionId,
|
||||
actor: req.permission.type,
|
||||
actorId: req.permission.id,
|
||||
actorAuthMethod: req.permission.authMethod,
|
||||
actorOrgId: req.permission.orgId,
|
||||
...req.query
|
||||
});
|
||||
|
||||
// TODO: audit logging
|
||||
|
||||
// await server.services.auditLog.createAuditLog({
|
||||
// ...req.auditLogInfo,
|
||||
// projectId: ca.projectId,
|
||||
// event: {
|
||||
// type: EventType.REVOKE_CERT,
|
||||
// metadata: {
|
||||
// certId: cert.id,
|
||||
// cn: cert.commonName,
|
||||
// serialNumber: cert.serialNumber
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
|
||||
return {
|
||||
collectionItems: pkiCollectionItems,
|
||||
totalCount
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
server.route({
|
||||
method: "POST",
|
||||
url: "/:collectionId/items",
|
||||
config: {
|
||||
rateLimit: writeLimit
|
||||
},
|
||||
onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),
|
||||
schema: {
|
||||
description: "Add item to PKI collection",
|
||||
params: z.object({
|
||||
collectionId: z.string().trim()
|
||||
}),
|
||||
body: z.object({
|
||||
type: z.nativeEnum(PkiItemType),
|
||||
itemId: z.string().trim()
|
||||
}),
|
||||
response: {
|
||||
200: PkiCollectionItemsSchema.omit({ caId: true, certId: true }).extend({
|
||||
type: z.nativeEnum(PkiItemType),
|
||||
itemId: z.string().trim()
|
||||
})
|
||||
}
|
||||
},
|
||||
handler: async (req) => {
|
||||
const pkiCollectionItem = await server.services.pkiCollection.addItemToPkiCollection({
|
||||
collectionId: req.params.collectionId,
|
||||
actor: req.permission.type,
|
||||
actorId: req.permission.id,
|
||||
actorAuthMethod: req.permission.authMethod,
|
||||
actorOrgId: req.permission.orgId,
|
||||
...req.body
|
||||
});
|
||||
|
||||
// TODO: audit logging
|
||||
|
||||
// await server.services.auditLog.createAuditLog({
|
||||
// ...req.auditLogInfo,
|
||||
// projectId: ca.projectId,
|
||||
// event: {
|
||||
// type: EventType.REVOKE_CERT,
|
||||
// metadata: {
|
||||
// certId: cert.id,
|
||||
// cn: cert.commonName,
|
||||
// serialNumber: cert.serialNumber
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
|
||||
return pkiCollectionItem;
|
||||
}
|
||||
});
|
||||
|
||||
server.route({
|
||||
method: "DELETE",
|
||||
url: "/:collectionId/items/:itemId",
|
||||
config: {
|
||||
rateLimit: writeLimit
|
||||
},
|
||||
onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),
|
||||
schema: {
|
||||
description: "Remove item from PKI collection",
|
||||
params: z.object({
|
||||
collectionId: z.string().trim(),
|
||||
itemId: z.string().trim()
|
||||
}),
|
||||
response: {
|
||||
200: PkiCollectionItemsSchema.omit({ caId: true, certId: true }).extend({
|
||||
type: z.nativeEnum(PkiItemType),
|
||||
itemId: z.string().trim()
|
||||
})
|
||||
}
|
||||
},
|
||||
handler: async (req) => {
|
||||
const pkiCollectionItem = await server.services.pkiCollection.removeItemFromPkiCollection({
|
||||
collectionId: req.params.collectionId,
|
||||
itemId: req.params.itemId,
|
||||
actor: req.permission.type,
|
||||
actorId: req.permission.id,
|
||||
actorAuthMethod: req.permission.authMethod,
|
||||
actorOrgId: req.permission.orgId
|
||||
});
|
||||
|
||||
// TODO: audit logging
|
||||
|
||||
// await server.services.auditLog.createAuditLog({
|
||||
// ...req.auditLogInfo,
|
||||
// projectId: ca.projectId,
|
||||
// event: {
|
||||
// type: EventType.DELETE_CERT,
|
||||
// metadata: {
|
||||
// certId: deletedCert.id,
|
||||
// cn: deletedCert.commonName,
|
||||
// serialNumber: deletedCert.serialNumber
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
|
||||
return pkiCollectionItem;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -2,9 +2,9 @@ import slugify from "@sindresorhus/slugify";
|
||||
import { z } from "zod";
|
||||
|
||||
import {
|
||||
AlertsSchema,
|
||||
CertificateAuthoritiesSchema,
|
||||
CertificatesSchema,
|
||||
PkiAlertsSchema,
|
||||
PkiCollectionsSchema,
|
||||
ProjectKeysSchema
|
||||
} from "@app/db/schemas";
|
||||
@@ -411,7 +411,7 @@ export const registerProjectRouter = async (server: FastifyZodProvider) => {
|
||||
}),
|
||||
response: {
|
||||
200: z.object({
|
||||
alerts: z.array(AlertsSchema)
|
||||
alerts: z.array(PkiAlertsSchema)
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user