mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-20 20:07:53 +00:00
feat(infisical-pg): resolved missing integration auth api
This commit is contained in:
@@ -59,6 +59,44 @@ export const registerIntegrationAuthRouter = async (server: FastifyZodProvider)
|
||||
}
|
||||
});
|
||||
|
||||
server.route({
|
||||
url: "/",
|
||||
method: "DELETE",
|
||||
onRequest: verifyAuth([AuthMode.JWT]),
|
||||
schema: {
|
||||
querystring: z.object({
|
||||
integration: z.string().trim(),
|
||||
projectId: z.string().trim()
|
||||
}),
|
||||
response: {
|
||||
200: z.object({
|
||||
integrationAuth: integrationAuthPubSchema.array()
|
||||
})
|
||||
}
|
||||
},
|
||||
handler: async (req) => {
|
||||
const integrationAuth = await server.services.integrationAuth.deleteIntegrationAuths({
|
||||
actorId: req.permission.id,
|
||||
actor: req.permission.type,
|
||||
integration: req.query.integration,
|
||||
projectId: req.query.projectId
|
||||
});
|
||||
|
||||
await server.services.auditLog.createAuditLog({
|
||||
...req.auditLogInfo,
|
||||
projectId: req.query.projectId,
|
||||
event: {
|
||||
type: EventType.UNAUTHORIZE_INTEGRATION,
|
||||
metadata: {
|
||||
integration: req.query.integration
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return { integrationAuth };
|
||||
}
|
||||
});
|
||||
|
||||
server.route({
|
||||
url: "/:integrationAuthId",
|
||||
method: "DELETE",
|
||||
@@ -74,7 +112,7 @@ export const registerIntegrationAuthRouter = async (server: FastifyZodProvider)
|
||||
}
|
||||
},
|
||||
handler: async (req) => {
|
||||
const integrationAuth = await server.services.integrationAuth.deleteIntegrationAuth({
|
||||
const integrationAuth = await server.services.integrationAuth.deleteIntegrationAuthById({
|
||||
actorId: req.permission.id,
|
||||
actor: req.permission.type,
|
||||
id: req.params.integrationAuthId
|
||||
|
||||
@@ -155,7 +155,7 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => {
|
||||
event: {
|
||||
type: EventType.GET_SECRET,
|
||||
metadata: {
|
||||
environment: req.query.environment,
|
||||
environment,
|
||||
secretPath: req.query.secretPath,
|
||||
secretId: secret.id,
|
||||
secretKey: req.params.secretName,
|
||||
|
||||
@@ -27,7 +27,8 @@ import { TIntegrationAuthDalFactory } from "./integration-auth-dal";
|
||||
import {
|
||||
TBitbucketWorkspace,
|
||||
TChecklyGroups,
|
||||
TDeleteIntegrationAuthDTO,
|
||||
TDeleteIntegrationAuthByIdDTO,
|
||||
TDeleteIntegrationAuthsDTO,
|
||||
TGetIntegrationAuthDTO,
|
||||
TGetIntegrationAuthTeamCityBuildConfigDTO,
|
||||
TIntegrationAuthAppsDTO,
|
||||
@@ -966,7 +967,27 @@ export const integrationAuthServiceFactory = ({
|
||||
return [];
|
||||
};
|
||||
|
||||
const deleteIntegrationAuth = async ({ id, actorId, actor }: TDeleteIntegrationAuthDTO) => {
|
||||
const deleteIntegrationAuths = async ({
|
||||
projectId,
|
||||
integration,
|
||||
actor,
|
||||
actorId
|
||||
}: TDeleteIntegrationAuthsDTO) => {
|
||||
const { permission } = await permissionService.getProjectPermission(actor, actorId, projectId);
|
||||
ForbiddenError.from(permission).throwUnlessCan(
|
||||
ProjectPermissionActions.Delete,
|
||||
ProjectPermissionSub.Integrations
|
||||
);
|
||||
|
||||
const integrations = await integrationAuthDal.delete({ integration, projectId });
|
||||
return integrations;
|
||||
};
|
||||
|
||||
const deleteIntegrationAuthById = async ({
|
||||
id,
|
||||
actorId,
|
||||
actor
|
||||
}: TDeleteIntegrationAuthByIdDTO) => {
|
||||
const integrationAuth = await integrationAuthDal.findById(id);
|
||||
if (!integrationAuth) throw new BadRequestError({ message: "Failed to find integration" });
|
||||
|
||||
@@ -996,7 +1017,8 @@ export const integrationAuthServiceFactory = ({
|
||||
getIntegrationAuth,
|
||||
oauthExchange,
|
||||
saveIntegrationToken,
|
||||
deleteIntegrationAuth,
|
||||
deleteIntegrationAuthById,
|
||||
deleteIntegrationAuths,
|
||||
getIntegrationAuthTeams,
|
||||
getIntegrationApps,
|
||||
getVercelBranches,
|
||||
|
||||
@@ -19,6 +19,11 @@ export type TSaveIntegrationAccessTokenDTO = {
|
||||
refreshToken?: string;
|
||||
} & TProjectPermission;
|
||||
|
||||
export type TDeleteIntegrationAuthsDTO = TProjectPermission & {
|
||||
integration: string;
|
||||
projectId: string;
|
||||
};
|
||||
|
||||
export type TIntegrationAuthAppsDTO = {
|
||||
id: string;
|
||||
teamId?: string;
|
||||
@@ -76,7 +81,7 @@ export type TIntegrationAuthNorthflankSecretGroupDTO = {
|
||||
appId: string;
|
||||
} & Omit<TProjectPermission, "projectId">;
|
||||
|
||||
export type TDeleteIntegrationAuthDTO = {
|
||||
export type TDeleteIntegrationAuthByIdDTO = {
|
||||
id: string;
|
||||
} & Omit<TProjectPermission, "projectId">;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user