mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-07 09:28:06 +00:00
feat: backward compatiable enc key in webhook
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
import { Request, Response } from "express";
|
import { Request, Response } from "express";
|
||||||
import { Types } from "mongoose";
|
import { Types } from "mongoose";
|
||||||
import { client, getRootEncryptionKey } from "../../config";
|
import { client, getEncryptionKey, getRootEncryptionKey } from "../../config";
|
||||||
import { Webhook } from "../../models";
|
import { Webhook } from "../../models";
|
||||||
import { getWebhookPayload, triggerWebhookRequest } from "../../services/WebhookService";
|
import { getWebhookPayload, triggerWebhookRequest } from "../../services/WebhookService";
|
||||||
import { BadRequestError, ResourceNotFoundError } from "../../utils/errors";
|
import { BadRequestError, ResourceNotFoundError } from "../../utils/errors";
|
||||||
@@ -37,8 +37,11 @@ export const createWebhook = async (req: Request, res: Response) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (webhookSecretKey) {
|
if (webhookSecretKey) {
|
||||||
const rootEncryptionKey = await getRootEncryptionKey();
|
let encryptionKey = await getRootEncryptionKey();
|
||||||
const { ciphertext, iv, tag } = client.encryptSymmetric(webhookSecretKey, rootEncryptionKey);
|
if (!encryptionKey) {
|
||||||
|
encryptionKey = await getEncryptionKey();
|
||||||
|
}
|
||||||
|
const { ciphertext, iv, tag } = client.encryptSymmetric(webhookSecretKey, encryptionKey);
|
||||||
webhook.iv = iv;
|
webhook.iv = iv;
|
||||||
webhook.tag = tag;
|
webhook.tag = tag;
|
||||||
webhook.encryptedSecretKey = ciphertext;
|
webhook.encryptedSecretKey = ciphertext;
|
||||||
|
|||||||
Reference in New Issue
Block a user