Skip to content

Commit

Permalink
- disabled slack api body validation (#317)
Browse files Browse the repository at this point in the history
- added missing ENV variables to bicep template
  • Loading branch information
mlhaufe authored Aug 10, 2024
1 parent 2af8370 commit c6cd5f5
Show file tree
Hide file tree
Showing 6 changed files with 115 additions and 13 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/azure-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,15 @@ 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 @@ -131,6 +140,15 @@ 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: 27 additions & 0 deletions azure/bicep/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,24 @@ 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 @@ -63,6 +81,15 @@ 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: 54 additions & 0 deletions azure/bicep/modules/appService.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,24 @@ 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 @@ -114,6 +132,42 @@ 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.0",
"version": "0.12.1",
"description": "Requirements management system",
"keywords": [],
"private": true,
Expand Down
23 changes: 13 additions & 10 deletions server/api/slack-bot/index.post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,15 @@ export default defineEventHandler(async (event) => {
message: 'Slack bot token not found'
})

if (!body.success)
throw createError({
statusCode: 400,
statusMessage: 'Bad Request: Invalid body parameters',
message: JSON.stringify(body.error.errors)
})
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 (!isValidSlackRequest(headers, rawBody))
throw createError({
Expand All @@ -129,15 +132,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 c6cd5f5

Please sign in to comment.