Skip to content

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

feat: add support for MS teams webhook

adilsonbc0d6d3a210e
diff --git a/backend/src/services/webhook/webhook-fns.ts b/backend/src/services/webhook/webhook-fns.ts
index 9ab7c34b47..8f0a7453b1 100644
--- a/backend/src/services/webhook/webhook-fns.ts
+++ b/backend/src/services/webhook/webhook-fns.ts
@@ -101,6 +101,40 @@ export const getWebhookPayload = (event: TWebhookPayloads) => {
}
]
};
+ case WebhookType.MICROSOFT_TEAMS:
+ return {
+ type: "message",
+ attachments: [
+ {
+ contentType: "application/vnd.microsoft.card.adaptive",
+ content: {
+ type: "AdaptiveCard",
+ version: "1.2",
+ body: [
+ {
+ type: "TextBlock",
+ size: "Medium",
+ weight: "Bolder",
+ text: "A secret value has been added or modified."
+ },
+ {
+ type: "FactSet",
+ facts: [
+ { title: "Project", value: projectName || "" },
+ { title: "Environment", value: environment },
+ { title: "Secret Path", value: secretPath || "" },
+ { title: "Modified By", value: changedBy || "" },
+ {
+ title: "Modified By Actor Type",
+ value: changedByActorType?.toString() || "Unknown Actor Type"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ ]
+ };
case WebhookType.GENERAL:
default:
return {
@@ -164,6 +198,39 @@ export const getWebhookPayload = (event: TWebhookPayloads) => {
}
]
};
+ case WebhookType.MICROSOFT_TEAMS:
+ return {
+ type: "message",
+ attachments: [
+ {
+ contentType: "application/vnd.microsoft.card.adaptive",
+ contentUrl: null,
+ content: {
+ type: "AdaptiveCard",
+ version: "1.2",
+ body: [
+ {
+ type: "TextBlock",
+ size: "Medium",
+ weight: "Bolder",
+ text: "A secret rotation has failed."
+ },
+ {
+ type: "FactSet",
+ facts: [
+ { title: "Rotation Name", value: rotationName || "" },
+ { title: "Project", value: projectName || "" },
+ { title: "Environment", value: environment },
+ { title: "Secret Path", value: secretPath || "" },
+ { title: "Error Message", value: errorMessage || "" },
+ { title: "Triggered Manually", value: triggeredManually ? "Yes" : "No" }
+ ]
+ }
+ ]
+ }
+ }
+ ]
+ };
case WebhookType.GENERAL:
default:
return {
@@ -220,6 +287,38 @@ export const getWebhookPayload = (event: TWebhookPayloads) => {
}
]
};
+ case WebhookType.MICROSOFT_TEAMS:
+ return {
+ type: "message",
+ attachments: [
+ {
+ contentType: "application/vnd.microsoft.card.adaptive",
+ contentUrl: null,
+ content: {
+ type: "AdaptiveCard",
+ version: "1.2",
+ body: [
+ {
+ type: "TextBlock",
+ size: "Medium",
+ weight: "Bolder",
+ text: "You have a secret reminder"
+ },
+ {
+ type: "FactSet",
+ facts: [
+ { title: "Project", value: projectName || "" },
+ { title: "Environment", value: environment },
+ { title: "Secret Path", value: secretPath || "" },
+ { title: "Secret Name", value: secretName },
+ { title: "Reminder Note", value: reminderNote || "" }
+ ]
+ }
+ ]
+ }
+ }
+ ]
+ };
case WebhookType.GENERAL:
default:
return {
@@ -281,6 +380,7 @@ export const fnTriggerWebhook = async ({
type: event.type,
payload: { ...event.payload, type: hook.type, projectName }
} as TWebhookPayloads;
+
return triggerWebhookRequest(hook, secretManagerDecryptor, getWebhookPayload(formattedEvent));
})
);
diff --git a/backend/src/services/webhook/webhook-types.ts b/backend/src/services/webhook/webhook-types.ts
index 6fac8efb71..7de8473c9c 100644
--- a/backend/src/services/webhook/webhook-types.ts
+++ b/backend/src/services/webhook/webhook-types.ts
@@ -30,7 +30,8 @@ export type TListWebhookDTO = {
export enum WebhookType {
GENERAL = "general",
- SLACK = "slack"
+ SLACK = "slack",
+ MICROSOFT_TEAMS = "microsoft-teams"
}
export enum WebhookEvents {
diff --git a/frontend/src/hooks/api/webhooks/types.ts b/frontend/src/hooks/api/webhooks/types.ts
index 7e2758ff89..c1c98b4e3f 100644
--- a/frontend/src/hooks/api/webhooks/types.ts
+++ b/frontend/src/hooks/api/webhooks/types.ts
@@ -1,6 +1,7 @@
export enum WebhookType {
GENERAL = "general",
- SLACK = "slack"
+ SLACK = "slack",
+ MICROSOFT_TEAMS = "microsoft-teams"
}
export type TWebhook = {
diff --git a/frontend/src/pages/secret-manager/SettingsPage/components/WebhooksTab/AddWebhookForm.tsx b/frontend/src/pages/secret-manager/SettingsPage/components/WebhooksTab/AddWebhookForm.tsx
index 6e4af22444..a1ef392264 100644
--- a/frontend/src/pages/secret-manager/SettingsPage/components/WebhooksTab/AddWebhookForm.tsx
+++ b/frontend/src/pages/secret-manager/SettingsPage/components/WebhooksTab/AddWebhookForm.tsx
@@ -98,6 +98,31 @@ export const AddWebhookForm = ({
</FormControl>
);
+ const microsoftTeamsFormFields = (
+ <FormControl
+ label="Incoming Webhook URL"
+ isRequired
+ isError={Boolean(errors?.webhookUrl)}
+ errorText={errors?.webhookUrl?.message}
+ >
+ <Input
+ placeholder="https://<tenant>.webhook.office.com/webhookb2/..."
+ {...register("webhookUrl")}
+ />
+ </FormControl>
+ );
+
+ const renderFormFields = () => {
+ switch (selectedWebhookType) {
+ case WebhookType.SLACK:
+ return slackFormFields;
+ case WebhookType.MICROSOFT_TEAMS:
+ return microsoftTeamsFormFields;
+ default:
+ return generalFormFields;
+ }
+ };
+
useEffect(() => {
if (!isOpen) {
reset();
@@ -131,6 +156,12 @@ export const AddWebhookForm = ({
<SelectItem value={WebhookType.SLACK} key={WebhookType.SLACK}>
Slack
</SelectItem>
+ <SelectItem
+ value={WebhookType.MICROSOFT_TEAMS}
+ key={WebhookType.MICROSOFT_TEAMS}
+ >
+ Microsoft Teams
+ </SelectItem>
</Select>
</FormControl>
)}
@@ -176,7 +207,7 @@ export const AddWebhookForm = ({
</FormControl>
)}
/>
- {selectedWebhookType === WebhookType.SLACK ? slackFormFields : generalFormFields}
+ {renderFormFields()}
</div>
<div className="mt-8 flex items-center">
<Button