Skip to content

Commit 999ebc2

Browse files
authored
Merge pull request #4111 from techmatters/CHI-3792-fix_url_in_webhook_validation
CHI-3792: Fix URL encoding approach for webhook validation
2 parents e9fa309 + 25c4f1b commit 999ebc2

3 files changed

Lines changed: 9 additions & 7 deletions

File tree

lambdas/account-scoped/src/customChannels/configuration.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ const LEGACY_FACEBOOK_PAGE_ACCESS_TOKEN_PARAMETERS: Record<
4646
},
4747
nz: {
4848
staging: 'FACEBOOK_PAGE_ACCESS_TOKEN_453194187877367_NZ-Staging',
49-
production: 'FACEBOOK_PAGE_ACCESS_TOKEN_103538615719253_Te-Gu-o---L-nea-de-ayuda',
49+
production: 'FACEBOOK_PAGE_ACCESS_TOKEN_134818612864_Youthline',
5050
},
5151
th: {
5252
staging: 'FACEBOOK_PAGE_ACCESS_TOKEN_100136349533502_Childline-TH-Staging',

lambdas/account-scoped/src/validation/twilioWebhook.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ export const validateWebhookRequest: HttpRequestPipelineStep = async (
3838
const queryString = Object.entries(query)
3939
.map(
4040
([key, value]) =>
41-
`${encodeURIComponent(key)}=${encodeURIComponent(value?.toString() ?? 'undefined')}`,
41+
// The ALB sends these values raw, not URL decoded, so they can be used 'as is'
42+
// If we switch to an API Gateway or a function URL (?), we need to encode the key and value with encodeURIComponent
43+
`${key}=${value?.toString() ?? 'undefined'}`,
4244
)
4345
.join('&');
4446
const urlForValidation =

lambdas/testPages/modicaToFlex.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
along with this program. If not, see https://www.gnu.org/licenses/.
1515
-->
1616
<!DOCTYPE html>
17-
<html>
17+
<html lang="en-US">
1818
<head>
1919
<meta charset="UTF-8">
2020
<title>Modica to Flex test page</title>
@@ -25,7 +25,7 @@
2525
</style>
2626
</head>
2727
<body>
28-
<div style="font-family: courier" id="message-history">
28+
<div style="font-family: courier,serif" id="message-history">
2929
</div>
3030
<form name="modica-message-input" onsubmit="sendMessage(event); return false;">
3131
<select name="destination-drop-down">
@@ -35,12 +35,12 @@
3535
<option value="+15375688305">AS_STG</option>
3636
<option value="+12165428033">AS_PROD</option>
3737
</select>
38-
<label for="message-sender-textbox">Sender Number</label> <input type="number" name="message-sender-textbox" value="1111111"/>
38+
<label for="message-sender-textbox">Sender Number</label> <input type="text" id="message-sender-textbox" name="message-sender-textbox" value="1111111"/>
3939
<br/>
4040
<textarea name="message-input-box"></textarea>
4141
<input type="submit" name="message-input-send" />
4242
</form>
43-
<pre style="font-family: courier" id="message-response">
43+
<pre style="font-family: courier,serif" id="message-response">
4444
</pre>
4545

4646
<script>
@@ -63,7 +63,7 @@
6363
const response = await fetch(WEBHOOK_URL, {
6464
method: "POST",
6565
headers: { "Content-Type": "application/json" },
66-
body: JSON.stringify({ destination, source, content, useTestApi: true, testSessionId: 'JSFIDDLE' }),
66+
body: JSON.stringify({ destination, source, content, useTestApi: true, testSessionId: 'TESTPAGE' }),
6767
});
6868
messageHistoryElement.append(messageElement);
6969
messageResponseElement.innerText = `status: ${response.status} [${response.statusText}]

0 commit comments

Comments
 (0)