fix: harden Discord native command auth (#70711) (thanks @vincentkoc)

This commit is contained in:
Peter Steinberger
2026-04-23 19:06:51 +01:00
parent 6590bc9037
commit bfcae63373

View File

@@ -291,6 +291,27 @@ describe("Discord native slash commands with commands.allowFrom", () => {
expectUnauthorizedReply(interaction);
});
it("rejects guild slash commands when owner restrictions are configured and the sender is not allowlisted", async () => {
const { dispatchSpy, interaction } = await runGuildSlashCommand({
userId: "999999999999999999",
mutateConfig: (cfg) => {
cfg.commands = {
...cfg.commands,
allowFrom: undefined,
};
cfg.channels = {
...cfg.channels,
discord: {
...cfg.channels?.discord,
allowFrom: ["user:123456789012345678"],
},
};
},
});
expect(dispatchSpy).not.toHaveBeenCalled();
expectUnauthorizedReply(interaction);
});
it("rejects guild slash commands outside the Discord allowlist when commands.useAccessGroups is false and commands.allowFrom is not configured", async () => {
const { dispatchSpy, interaction } = await runGuildSlashCommand({
mutateConfig: (cfg) => {