Skip to content

Commit

Permalink
Support whitelisting slack domain in cli
Browse files Browse the repository at this point in the history
  • Loading branch information
flvndvd committed Jan 9, 2024
1 parent 2b49c22 commit 4a93809
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions connectors/src/admin/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,47 @@ const slack = async (command: string, args: parseArgs.ParsedArgs) => {
}
break;
}

case "whitelist-domains": {
const { wId, whitelistedDomains } = args;
if (!wId) {
throw new Error("Missing --wId argument");
}
if (!whitelistedDomains) {
throw new Error("Missing --whitelistedDomains argument");
}

const connector = await Connector.findOne({
where: {
workspaceId: args.wId,
type: "slack",
},
});
if (!connector) {
throw new Error(`Could not find connector for workspace ${args.wId}`);
}

const whitelistedDomainsArray = whitelistedDomains.split(",");
// TODO(2024-01-10 flav) Add domain validation.
console.log(
`Whitelisting following domains for slack:\n- ${whitelistedDomainsArray.join(
"\n-"
)}`
);

await SlackConfiguration.update(
{
whitelistedDomains: whitelistedDomainsArray,
},
{
where: {
connectorId: connector.id,
},
}
);

break;
}
}
};

Expand Down

0 comments on commit 4a93809

Please sign in to comment.