misc: addressed comments

This commit is contained in:
Sheen Capadngan
2024-09-11 13:29:43 +08:00
parent aa42aa05aa
commit d23a7e41f3
24 changed files with 125 additions and 98 deletions

View File

@@ -73,5 +73,5 @@ PLAIN_WISH_LABEL_IDS=
SSL_CLIENT_CERTIFICATE_HEADER_KEY=
SLACK_CLIENT_ID=
SLACK_CLIENT_SECRET=
WORKFLOW_SLACK_CLIENT_ID=
WORKFLOW_SLACK_CLIENT_SECRET=

View File

@@ -147,8 +147,8 @@ const envSchema = z
PLAIN_WISH_LABEL_IDS: zpStr(z.string().optional()),
DISABLE_AUDIT_LOG_GENERATION: zodStrBool.default("false"),
SSL_CLIENT_CERTIFICATE_HEADER_KEY: zpStr(z.string().optional()).default("x-ssl-client-cert"),
SLACK_CLIENT_ID: zpStr(z.string()).optional(),
SLACK_CLIENT_SECRET: zpStr(z.string()).optional()
WORKFLOW_SLACK_CLIENT_ID: zpStr(z.string()).optional(),
WORKFLOW_SLACK_CLIENT_SECRET: zpStr(z.string()).optional()
})
.transform((data) => ({
...data,

View File

@@ -1,3 +1,4 @@
import slugify from "@sindresorhus/slugify";
import { z } from "zod";
import { SlackIntegrationsSchema, WorkflowIntegrationsSchema } from "@app/db/schemas";
@@ -34,7 +35,12 @@ export const registerSlackRouter = async (server: FastifyZodProvider) => {
}
],
querystring: z.object({
slug: z.string(),
slug: z
.string()
.trim()
.refine((v) => slugify(v) === v, {
message: "Slug must be a valid slug"
}),
description: z.string().optional()
}),
response: {
@@ -282,7 +288,13 @@ export const registerSlackRouter = async (server: FastifyZodProvider) => {
id: z.string()
}),
body: z.object({
slug: z.string().optional(),
slug: z
.string()
.trim()
.refine((v) => slugify(v) === v, {
message: "Slug must be a valid slug"
})
.optional(),
description: z.string().optional()
}),
response: {

View File

@@ -138,8 +138,8 @@ export const slackServiceFactory = ({
const appCfg = getConfig();
const serverCfg = await getServerCfg();
let slackClientId = appCfg.SLACK_CLIENT_ID as string;
let slackClientSecret = appCfg.SLACK_CLIENT_SECRET as string;
let slackClientId = appCfg.WORKFLOW_SLACK_CLIENT_ID as string;
let slackClientSecret = appCfg.WORKFLOW_SLACK_CLIENT_SECRET as string;
const decrypt = await kmsService.decryptWithRootKey();
@@ -244,7 +244,7 @@ export const slackServiceFactory = ({
const installer = await getSlackInstaller();
const url = await installer.generateInstallUrl({
scopes: ["chat:write.public", "chat:write", "channels:read", "groups:read", "im:read", "mpim:read"],
scopes: ["chat:write.public", "chat:write", "channels:read", "groups:read"],
metadata: JSON.stringify({
slug,
description,
@@ -278,7 +278,7 @@ export const slackServiceFactory = ({
const installer = await getSlackInstaller();
const url = await installer.generateInstallUrl({
scopes: ["chat:write.public", "chat:write", "channels:read", "groups:read", "im:read", "mpim:read"],
scopes: ["chat:write.public", "chat:write", "channels:read", "groups:read"],
metadata: JSON.stringify({
id,
orgId: slackIntegration.orgId

View File

@@ -0,0 +1,88 @@
---
title: "Slack integration"
description: "Learn how to setup Slack integration"
---
This guide will provide step by step instructions on how to configure Slack integration for your Infisical projects.
<Tabs>
<Tab title="Self-hosted setup">
## Configure admin settings
Note that this step only has to be done once for the entire instance.
<Steps>
<Step title="Navigate to the Integrations tab in the Admin settings">
Before anything else, you need to setup the Slack app to be used by
your Infisical instance. Because you're self-hosting, you will need to
create this Slack application as demonstrated in the preceding step.
![admin-settings-slack-overview](/images/platform/workflow-integrations/slack-integration/admin-slack-integration-overview.png)
</Step>
<Step title="Create Slack app">
Click the "Create Slack app" button. This will open up a new window with the
custom app creation flow on Slack.
![admin-slack-create-app](/images/platform/workflow-integrations/slack-integration/admin-slack-integration-create-app.png)
Select the Slack workspace you want to integrate with Infisical.
![admin-slack-app-workspace-select](/images/platform/workflow-integrations/slack-integration/admin-slack-integration-app-workspace-select.png)
The configuration values of your custom Slack app will be pre-filled for you. You can view or edit the app manifest by clicking **Edit Configurations**.
![admin-slack-app-summary](/images/platform/workflow-integrations/slack-integration/admin-slack-integration-app-summary.png)
Once everything's confirmed, press Create.
</Step>
<Step title="Input app credentials from Slack">
Copy the Client ID and Client Secret values from your newly created custom Slack app and add them to Infisical.
![admin-slack-app-credentials](/images/platform/workflow-integrations/slack-integration/admin-slack-integration-app-credentials.png)
![admin-slack-app-credentials-form](/images/platform/workflow-integrations/slack-integration/admin-slack-integration-app-credential-form.png)
Complete the admin setup by pressing Save.
</Step>
</Steps>
## Create Slack workflow integration
<Steps>
<Step title="Navigate to the Workflow Integrations tab in your organization settings">
In order to use Slack integration in your projects, you will first have to
configure a Slack workflow integration in your organization.
![org-slack-overview](/images/platform/workflow-integrations/slack-integration/org-slack-integration-overview.png)
</Step>
<Step title="Install Slack app to workspace">
Press "Add" and select "Slack" as the platform.
![org-slack-initial-add](/images/platform/workflow-integrations/slack-integration/org-slack-integration-initial-add.png)
Give your Slack integration a descriptive alias. You will use this to select the Slack integration for your project.
![org-slack-add-form](/images/platform/workflow-integrations/slack-integration/org-slack-integration-add-form.png)
Press **Connect Slack**. This opens up the Slack app installation flow. Select the Slack workspace you want to install the custom Slack app to and press **Allow**.
![org-slack-authenticate](/images/platform/workflow-integrations/slack-integration/org-slack-integration-authenticate.png)
Your Slack bot will then be added to your selected Slack workspace. This completes the workflow integration creation flow. Your projects in the organization can now use this Slack integration to send real-time updates to your Slack workspace.
![org-slack-workspace](/images/platform/workflow-integrations/slack-integration/org-slack-integration-workspace.png)
![org-slack-created](/images/platform/workflow-integrations/slack-integration/org-slack-integration-created.png)
</Step>
</Steps>
## Configure project to use Slack workflow integration
<Steps>
<Step title="Navigate to the Workflow Integrations tab in the project settings">
![project-slack-overview](/images/platform/workflow-integrations/slack-integration/project-slack-integration-overview.png)
</Step>
<Step title="Select the Slack integration to use for the project">
Your project will send notifications to the connected Slack workspace of the
selected Slack integration when the configured events are triggered.
![project-slack-select](/images/platform/workflow-integrations/slack-integration/project-slack-integration-select.png)
</Step>
<Step title="Configure the Slack notification settings for the project and click Save.">
![project-slack-select](/images/platform/workflow-integrations/slack-integration/project-slack-integration-config.png)
You now have a working native integration with Slack!
</Step>
</Steps>
</Tab>
</Tabs>

View File

@@ -169,6 +169,12 @@
"documentation/platform/kms/aws-hsm"
]
},
{
"group": "Workflow Integrations",
"pages": [
"documentation/platform/workflow-integrations/slack-integration"
]
},
"documentation/platform/secret-sharing"
]
},
@@ -250,10 +256,6 @@
"self-hosting/guides/custom-certificates"
]
},
{
"group": "Workflow Integrations",
"pages": ["self-hosting/guides/slack-integration"]
},
{
"group": "Reference architectures",
"pages": ["self-hosting/reference-architectures/aws-ecs"]

View File

@@ -1,82 +0,0 @@
---
title: "Slack integration"
description: "Learn how to setup Slack integration in your self-hosted instance."
---
This guide will provide step by step instructions on how to configure Slack integration for your Infisical projects.
## Configure admin settings
Note that this step only has to be done once for the entire instance.
<Steps>
<Step title="Navigate to the Integrations tab in the Admin settings">
Before anything else, you need to setup the Slack app to be used by
your Infisical instance. Because you're self-hosting, you will need to
create this Slack application as demonstrated in the preceding step.
![admin-settings-slack-overview](/images/self-hosting/guides/slack-integration/admin-slack-integration-overview.png)
</Step>
<Step title="Create Slack app">
Click the "Create Slack app" button. This will open up a new window with the
custom app creation flow on Slack.
![admin-slack-create-app](/images/self-hosting/guides/slack-integration/admin-slack-integration-create-app.png)
Select the Slack workspace you want to integrate with Infisical.
![admin-slack-app-workspace-select](/images/self-hosting/guides/slack-integration/admin-slack-integration-app-workspace-select.png)
The configuration values of your custom Slack app will be pre-filled for you. You can view or edit the app manifest by clicking **Edit Configurations**.
![admin-slack-app-summary](/images/self-hosting/guides/slack-integration/admin-slack-integration-app-summary.png)
Once everything's confirmed, press Create.
</Step>
<Step title="Input app credentials from Slack">
Copy the Client ID and Client Secret values from your newly created custom Slack app and add them to Infisical.
![admin-slack-app-credentials](/images/self-hosting/guides/slack-integration/admin-slack-integration-app-credentials.png)
![admin-slack-app-credentials-form](/images/self-hosting/guides/slack-integration/admin-slack-integration-app-credential-form.png)
Complete the admin setup by pressing Save.
</Step>
</Steps>
## Create Slack workflow integration
<Steps>
<Step title="Navigate to the Workflow Integrations tab in your organization settings">
In order to use Slack integration in your projects, you will first have to
configure a Slack workflow integration in your organization.
![org-slack-overview](/images/self-hosting/guides/slack-integration/org-slack-integration-overview.png)
</Step>
<Step title="Install Slack app to workspace">
Press "Add" and select "Slack" as the platform.
![org-slack-initial-add](/images/self-hosting/guides/slack-integration/org-slack-integration-initial-add.png)
Give your Slack integration a descriptive alias. You will use this to select the Slack integration for your project.
![org-slack-add-form](/images/self-hosting/guides/slack-integration/org-slack-integration-add-form.png)
Press **Connect Slack**. This opens up the Slack app installation flow. Select the Slack workspace you want to install the custom Slack app to and press **Allow**.
![org-slack-authenticate](/images/self-hosting/guides/slack-integration/org-slack-integration-authenticate.png)
Your Slack bot will then be added to your selected Slack workspace. This completes the workflow integration creation flow. Your projects in the organization can now use this Slack integration to send real-time updates to your Slack workspace.
![org-slack-workspace](/images/self-hosting/guides/slack-integration/org-slack-integration-workspace.png)
![org-slack-created](/images/self-hosting/guides/slack-integration/org-slack-integration-created.png)
</Step>
</Steps>
## Configure project to use Slack workflow integration
<Steps>
<Step title="Navigate to the Workflow Integrations tab in the project settings">
![project-slack-overview](/images/self-hosting/guides/slack-integration/project-slack-integration-overview.png)
</Step>
<Step title="Select the Slack integration to use for the project">
Your project will send notifications to the connected Slack workspace of the
selected Slack integration when the configured events are triggered.
![project-slack-select](/images/self-hosting/guides/slack-integration/project-slack-integration-select.png)
</Step>
<Step title="Configure the Slack notification settings for the project and click Save.">
![project-slack-select](/images/self-hosting/guides/slack-integration/project-slack-integration-config.png)
You now have a working native integration with Slack!
</Step>
</Steps>

View File

@@ -2,6 +2,7 @@ import { useEffect } from "react";
import { Controller, useForm } from "react-hook-form";
import { useRouter } from "next/router";
import { zodResolver } from "@hookform/resolvers/zod";
import slugify from "@sindresorhus/slugify";
import axios from "axios";
import { z } from "zod";
@@ -21,7 +22,13 @@ type Props = {
};
const slackFormSchema = z.object({
slug: z.string(),
slug: z
.string()
.trim()
.min(1)
.refine((v) => slugify(v) === v, {
message: "Alias must be a valid slug"
}),
description: z.string().optional()
});

View File

@@ -42,7 +42,7 @@ const getCustomSlackAppCreationUrl = () =>
oauth_config: {
redirect_urls: [`${window.origin}/api/v1/workflow-integrations/slack/oauth_redirect`],
scopes: {
bot: ["chat:write.public", "chat:write"]
bot: ["chat:write.public", "chat:write", "channels:read", "groups:read"]
}
},
settings: {