Skip to content

Commit

Permalink
Merge pull request #63 from Ilhasoft/fix/allow-api-key-auth
Browse files Browse the repository at this point in the history
fix twilioflex web callbacks to allow api key auth
  • Loading branch information
rasoro authored Apr 19, 2022
2 parents bf28119 + f2ad9e3 commit 3c02a65
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions services/tickets/twilioflex/testdata/event_callback.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"label": "unauthorized response if auth fails",
"method": "POST",
"path": "/mr/tickets/types/twilioflex/event_callback/12cc5dcf-44c2-4b25-9781-27275873e0df/564fee60-7e84-4a9e-ade3-4fce01af19a2",
"body": "EventType=onMessageSent&InstanceSid=IS38067ec392f1486bb6e4de4610f26fb3&Attributes=%7B%7D&DateCreated=2022-03-10T23%3A56%3A43.412Z&Index=1&From=teste_2Etwilioflex&MessageSid=IM4b440f124820414b8f500a1235532ac1&AccountSid=AC92d44315e19372138bdaffcc13cf3b05&Source=SDK&ChannelSid=CH1880a9cde40c4dbb88dd97fc3aedac08&ClientIdentity=teste_2Etwilioflex&RetryCount=0&WebhookType=webhook&Body=ola&WebhookSid=WH99d1f1895a7c4e6fa10ac5e8ac0c2242",
"body": "EventType=onMessageSent&InstanceSid=IS43167ec392f1486bb6e4de4610f26gc4&Attributes=%7B%7D&DateCreated=2022-03-10T23%3A56%3A43.412Z&Index=1&From=teste_2Etwilioflex&MessageSid=IM4b440f124820414b8f500a1235532ac1&AccountSid=AC92d44315e19372138bdaffcc13cf3b05&Source=SDK&ChannelSid=CH1880a9cde40c4dbb88dd97fc3aedac08&ClientIdentity=teste_2Etwilioflex&RetryCount=0&WebhookType=webhook&Body=ola&WebhookSid=WH99d1f1895a7c4e6fa10ac5e8ac0c2242",
"status": 401,
"response": {
"status": "unauthorized"
Expand Down Expand Up @@ -121,4 +121,4 @@
}
]
}
]
]
4 changes: 2 additions & 2 deletions services/tickets/twilioflex/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ func handleEventCallback(ctx context.Context, rt *runtime.Runtime, r *http.Reque
return errors.Errorf("no such ticketer %s", ticketerUUID), http.StatusNotFound, nil
}

accountSid := request.AccountSid
if accountSid != ticketer.Config(configurationAccountSid) {
serviceSid := request.InstanceSid
if serviceSid != ticketer.Config(configurationChatServiceSid) {
return map[string]string{"status": "unauthorized"}, http.StatusUnauthorized, nil
}

Expand Down

0 comments on commit 3c02a65

Please sign in to comment.