Skip to content

Commit

Permalink
Revert "- disabled slack api body validation (#317)" (#318)
Browse files Browse the repository at this point in the history
This reverts commit c6cd5f5.
  • Loading branch information
mlhaufe authored Aug 10, 2024
1 parent c6cd5f5 commit c6c3671
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 115 deletions.
18 changes: 0 additions & 18 deletions .github/workflows/azure-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,6 @@ jobs:
postgresPassword=${{ secrets.POSTGRES_PASSWORD }}
postgresPort=${{ secrets.POSTGRES_PORT }}
postgresUser=${{ secrets.POSTGRES_USER }}
nodeEnv=production
nuxtOrigin=${{ secrets.NUXT_ORIGIN }}
nuxtSessionPassword=${{ secrets.NUXT_SESSION_PASSWORD }}
nuxtAuthClientId=${{ secrets.NUXT_AUTH_CLIENT_ID }}
nuxtAuthClientSecret=${{ secrets.NUXT_AUTH_CLIENT_SECRET }}
nuxtAuthTenantName=${{ secrets.NUXT_AUTH_TENANT_NAME }}
nuxtAuthTenantId=${{ secrets.NUXT_AUTH_TENANT_ID }}
nuxtAuthAuthorityDomain=${{ secrets.NUXT_AUTH_AUTHORITY_DOMAIN }}
nuxtAuthPrimaryUserFlow=${{ secrets.NUXT_AUTH_PRIMARY_USER_FLOW }}
slackAdminMemberId=${{ secrets.SLACK_ADMIN_MEMBER_ID }}
slackBotToken=${{ secrets.SLACK_BOT_TOKEN }}
slackSigningSecret=${{ secrets.SLACK_SIGNING_SECRET }}
Expand Down Expand Up @@ -140,15 +131,6 @@ jobs:
postgresPassword=${{ secrets.POSTGRES_PASSWORD }}
postgresPort=${{ secrets.POSTGRES_PORT }}
postgresUser=${{ secrets.POSTGRES_USER }}
nodeEnv=production
nuxtOrigin=${{ secrets.NUXT_ORIGIN }}
nuxtSessionPassword=${{ secrets.NUXT_SESSION_PASSWORD }}
nuxtAuthClientId=${{ secrets.NUXT_AUTH_CLIENT_ID }}
nuxtAuthClientSecret=${{ secrets.NUXT_AUTH_CLIENT_SECRET }}
nuxtAuthTenantName=${{ secrets.NUXT_AUTH_TENANT_NAME }}
nuxtAuthTenantId=${{ secrets.NUXT_AUTH_TENANT_ID }}
nuxtAuthAuthorityDomain=${{ secrets.NUXT_AUTH_AUTHORITY_DOMAIN }}
nuxtAuthPrimaryUserFlow=${{ secrets.NUXT_AUTH_PRIMARY_USER_FLOW }}
slackAdminMemberId=${{ secrets.SLACK_ADMIN_MEMBER_ID }}
slackBotToken=${{ secrets.SLACK_BOT_TOKEN }}
slackSigningSecret=${{ secrets.SLACK_SIGNING_SECRET }}
Expand Down
27 changes: 0 additions & 27 deletions azure/bicep/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,6 @@ param postgresPort string
@secure()
param postgresUser string
@secure()
param nodeEnv string
@secure()
param nuxtOrigin string
@secure()
param nuxtSessionPassword string
@secure()
param nuxtAuthClientId string
@secure()
param nuxtAuthClientSecret string
@secure()
param nuxtAuthTenantName string
@secure()
param nuxtAuthTenantId string
@secure()
param nuxtAuthAuthorityDomain string
@secure()
param nuxtAuthPrimaryUserFlow string
@secure()
param slackAdminMemberId string
@secure()
param slackBotToken string
Expand Down Expand Up @@ -81,15 +63,6 @@ module appService './modules/appService.bicep' = {
postgresPassword: postgresPassword
postgresPort: postgresPort
postgresUser: postgresUser
nodeEnv: nodeEnv
nuxtOrigin: nuxtOrigin
nuxtSessionPassword: nuxtSessionPassword
nuxtAuthClientId: nuxtAuthClientId
nuxtAuthClientSecret: nuxtAuthClientSecret
nuxtAuthTenantName: nuxtAuthTenantName
nuxtAuthTenantId: nuxtAuthTenantId
nuxtAuthAuthorityDomain: nuxtAuthAuthorityDomain
nuxtAuthPrimaryUserFlow: nuxtAuthPrimaryUserFlow
slackAdminMemberId: slackAdminMemberId
slackBotToken: slackBotToken
slackSigningSecret: slackSigningSecret
Expand Down
54 changes: 0 additions & 54 deletions azure/bicep/modules/appService.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,6 @@ param postgresPort string
@secure()
param postgresUser string
@secure()
param nodeEnv string
@secure()
param nuxtOrigin string
@secure()
param nuxtSessionPassword string
@secure()
param nuxtAuthClientId string
@secure()
param nuxtAuthClientSecret string
@secure()
param nuxtAuthTenantName string
@secure()
param nuxtAuthTenantId string
@secure()
param nuxtAuthAuthorityDomain string
@secure()
param nuxtAuthPrimaryUserFlow string
@secure()
param slackAdminMemberId string
@secure()
param slackBotToken string
Expand Down Expand Up @@ -132,42 +114,6 @@ resource appService 'Microsoft.Web/sites@2023-12-01' = {
name: 'POSTGRES_USER'
value: postgresUser
}
{
name: 'NODE_ENV'
value: nodeEnv
}
{
name: 'NUXT_ORIGIN'
value: nuxtOrigin
}
{
name: 'NUXT_SESSION_PASSWORD'
value: nuxtSessionPassword
}
{
name: 'NUXT_AUTH_CLIENT_ID'
value: nuxtAuthClientId
}
{
name: 'NUXT_AUTH_CLIENT_SECRET'
value: nuxtAuthClientSecret
}
{
name: 'NUXT_AUTH_TENANT_NAME'
value: nuxtAuthTenantName
}
{
name: 'NUXT_AUTH_TENANT_ID'
value: nuxtAuthTenantId
}
{
name: 'NUXT_AUTH_AUTHORITY_DOMAIN'
value: nuxtAuthAuthorityDomain
}
{
name: 'NUXT_AUTH_PRIMARY_USER_FLOW'
value: nuxtAuthPrimaryUserFlow
}
{
name: 'SLACK_ADMIN_MEMBER_ID'
value: slackAdminMemberId
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@final-hill/cathedral",
"version": "0.12.1",
"version": "0.12.0",
"description": "Requirements management system",
"keywords": [],
"private": true,
Expand Down
23 changes: 10 additions & 13 deletions server/api/slack-bot/index.post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,12 @@ export default defineEventHandler(async (event) => {
message: 'Slack bot token not found'
})

console.log('SLACKBOT API BODY:', JSON.stringify(body.data))
/*
if (!body.success)
throw createError({
statusCode: 400,
statusMessage: 'Bad Request: Invalid body parameters',
message: JSON.stringify(body.error.errors)
})
*/
if (!body.success)
throw createError({
statusCode: 400,
statusMessage: 'Bad Request: Invalid body parameters',
message: JSON.stringify(body.error.errors)
})

if (!isValidSlackRequest(headers, rawBody))
throw createError({
Expand All @@ -132,15 +129,15 @@ export default defineEventHandler(async (event) => {
message: 'Invalid Slack request signature'
})

const requestType = body.data!.type
const requestType = body.data.type

switch (requestType) {
case 'url_verification':
return { challenge: body.data!.challenge };
return { challenge: body.data.challenge };
case 'event_callback':
const eventType = body.data!.event!.type
const eventType = body.data.event!.type
if (eventType === 'app_mention')
return await sendResponse(body.data!.event!)
return await sendResponse(body.data.event!)

throw createError({
statusCode: 400,
Expand Down

0 comments on commit c6c3671

Please sign in to comment.