mirror of https://github.com/buster-so/buster.git
- fix lower case slack
- return error response on slack bot verification - auth scope fix
This commit is contained in:
parent
c1f9ca3622
commit
35193e53ce
|
@ -2,7 +2,6 @@ export const SLACK_OAUTH_SCOPES = [
|
||||||
'app_mentions:read',
|
'app_mentions:read',
|
||||||
'channels:history',
|
'channels:history',
|
||||||
'channels:join',
|
'channels:join',
|
||||||
'channels:manage',
|
|
||||||
'channels:read',
|
'channels:read',
|
||||||
'chat:write',
|
'chat:write',
|
||||||
'chat:write.public',
|
'chat:write.public',
|
||||||
|
|
|
@ -141,12 +141,21 @@ export async function handleSlackEventsEndpoint(c: Context) {
|
||||||
const payload = c.get('slackPayload');
|
const payload = c.get('slackPayload');
|
||||||
if (!payload) {
|
if (!payload) {
|
||||||
// This shouldn't happen if middleware works correctly
|
// This shouldn't happen if middleware works correctly
|
||||||
return c.json({ success: false });
|
return c.json({ error: 'Unauthorized' }, 401);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Process the event
|
try {
|
||||||
const response = await eventsHandler(payload);
|
// Process the event
|
||||||
return c.json(response);
|
const response = await eventsHandler(payload);
|
||||||
|
return c.json(response);
|
||||||
|
} catch (error) {
|
||||||
|
// Handle authentication errors
|
||||||
|
if (error instanceof Error && error.message.includes('Unauthorized')) {
|
||||||
|
return c.json({ error: 'Unauthorized' }, 401);
|
||||||
|
}
|
||||||
|
// Re-throw other errors
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -179,8 +188,8 @@ export async function eventsHandler(payload: SlackWebhookPayload): Promise<Slack
|
||||||
teamId: payload.team_id,
|
teamId: payload.team_id,
|
||||||
reason: authResult.type === 'unauthorized' ? authResult.reason : 'Unknown',
|
reason: authResult.type === 'unauthorized' ? authResult.reason : 'Unknown',
|
||||||
});
|
});
|
||||||
// Return success to prevent Slack retries
|
// Throw unauthorized error
|
||||||
return { success: true };
|
throw new Error('Unauthorized: Slack user authentication failed');
|
||||||
}
|
}
|
||||||
|
|
||||||
const organizationId = authResult.type === 'unauthorized' ? '' : authResult.organization.id;
|
const organizationId = authResult.type === 'unauthorized' ? '' : authResult.organization.id;
|
||||||
|
|
|
@ -39,7 +39,7 @@ export const SlackIntegrations = React.memo(() => {
|
||||||
}, [isConnected]);
|
}, [isConnected]);
|
||||||
|
|
||||||
if (slackIntegrationError) {
|
if (slackIntegrationError) {
|
||||||
return <StatusCard message="Error fetching slack integration." variant={'danger'} />;
|
return <StatusCard message="Error fetching Slack integration." variant={'danger'} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isFetchedSlackIntegration) {
|
if (!isFetchedSlackIntegration) {
|
||||||
|
@ -67,7 +67,7 @@ const ConnectSlackCard = React.memo(() => {
|
||||||
<div className="flex flex-col space-y-0.5">
|
<div className="flex flex-col space-y-0.5">
|
||||||
<Text>Slack account</Text>
|
<Text>Slack account</Text>
|
||||||
<Text variant="secondary" size={'xs'}>
|
<Text variant="secondary" size={'xs'}>
|
||||||
Link your slack account to use Buster from Slack
|
Link your Slack account to use Buster from Slack
|
||||||
</Text>
|
</Text>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -166,7 +166,7 @@ const ConnectedSlackChannels = React.memo(() => {
|
||||||
<div className="flex flex-col space-y-0.5">
|
<div className="flex flex-col space-y-0.5">
|
||||||
<Text>Alerts channel</Text>
|
<Text>Alerts channel</Text>
|
||||||
<Text variant="secondary" size={'xs'}>
|
<Text variant="secondary" size={'xs'}>
|
||||||
Select which slack channel Buster should send alerts to
|
Select which Slack channel Buster should send alerts to
|
||||||
</Text>
|
</Text>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex min-w-0 flex-1 items-center justify-end space-x-2">
|
<div className="flex min-w-0 flex-1 items-center justify-end space-x-2">
|
||||||
|
@ -262,7 +262,7 @@ const SlackSharingPermissions = React.memo(() => {
|
||||||
<div className="flex flex-col space-y-0.5">
|
<div className="flex flex-col space-y-0.5">
|
||||||
<Text>Auto-share chats with other users</Text>
|
<Text>Auto-share chats with other users</Text>
|
||||||
<Text variant="secondary" size={'xs'}>
|
<Text variant="secondary" size={'xs'}>
|
||||||
Specify how chats are auto-shared when created from slack channels
|
Specify how chats are auto-shared when created from Slack channels
|
||||||
</Text>
|
</Text>
|
||||||
</div>
|
</div>
|
||||||
<Dropdown
|
<Dropdown
|
||||||
|
|
Loading…
Reference in New Issue