Skip to content

Commit

Permalink
fix: remediated integration url generation & GET handling (#696)
Browse files Browse the repository at this point in the history
  • Loading branch information
graza-io committed Feb 21, 2024
1 parent d0a0d51 commit 86f1656
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion internal/service/api/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import (

func (api *APIService) WebhookRegisterAPI(router *gin.RouterGroup) {
router.POST("/hook/:hook/:hash", api.passHookToProcessor)
router.GET("/hook/:hook/:hash", api.runTriggerHook)
router.GET("/hook/:hook/:hash", api.passHookToProcessor)
}

type JSONPayload struct {
Expand Down Expand Up @@ -101,6 +101,10 @@ func (api *APIService) passHookToProcessor(c *gin.Context) {
case len(nameParts) >= 2 && (nameParts[0] == "trigger" || nameParts[1] == "trigger"):
api.runTriggerHook(c)
case len(nameParts) >= 2 && nameParts[0] == "integration":
if c.Request.Method != http.MethodPost {
common.AbortWithError(c, perr.MethodNotAllowed())
return
}
api.runIntegrationHook(c)
default:
common.AbortWithError(c, perr.NotFoundWithMessage(fmt.Sprintf("Not Found %s", webhookUri.Hook)))
Expand Down
2 changes: 1 addition & 1 deletion internal/service/manager/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ func integrationUrlProcessor(integration modconfig.Integration) error {
integrationName := fmt.Sprintf("integration.%s", integration.GetHclResourceImpl().FullName)
hashString := util.CalculateHash(integrationName, salt)

integrationUrl := fmt.Sprintf("%s/hook/%s/%s", util.GetBaseUrl(), integrationName, hashString)
integrationUrl := fmt.Sprintf("%s/api/latest/hook/%s/%s", util.GetBaseUrl(), integrationName, hashString)
integration.SetUrl(integrationUrl)
}
return nil
Expand Down

0 comments on commit 86f1656

Please sign in to comment.