Skip to content

Commit

Permalink
feat (Conversation/e2e): Validate authentication from webhooks (#145)
Browse files Browse the repository at this point in the history
* feat (Conversation/e2e): Validate authentication from webhooks
* feat (Core): Add guard against 'null' key value for headers comparison
  • Loading branch information
JPPortier authored Sep 24, 2024
1 parent 631a602 commit 8b6979f
Show file tree
Hide file tree
Showing 4 changed files with 239 additions and 257 deletions.
10 changes: 0 additions & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,6 @@ jobs:
fetch-depth: 0
path: sinch-sdk-mockserver

- name: Build custom Docker image
run: |
cd sinch-sdk-mockserver
docker build -t sinch-sdk-mockserver -f Dockerfile .
- name: Install Docker Compose
run: |
sudo apt-get update
Expand All @@ -56,11 +51,6 @@ jobs:
cd sinch-sdk-mockserver
docker-compose up -d
- name: Wait for the mock servers to be healthy
run: |
cd sinch-sdk-mockserver
. ./scripts/healthcheck.sh
- name: Link to feature files
run: |
ln -s ${{ github.workspace }}/sinch-sdk-mockserver/features client/src/test/resources
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.sinch.sdk.domains.conversation.api.v1.adapters;

import com.sinch.sdk.core.exceptions.ApiAuthException;
import com.sinch.sdk.core.utils.MapUtils;
import java.nio.charset.StandardCharsets;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
Expand All @@ -22,8 +23,9 @@ public class ConversationWebhooksAuthenticationValidation {
static final String SIGNATURE_HEADER = "x-sinch-webhook-signature";

public boolean validateAuthenticationHeader(
String secret, Map<String, String> headers, String jsonPayload) {
String secret, Map<String, String> _headers, String jsonPayload) {

Map<String, String> headers = MapUtils.getCaseInsensitiveMap(_headers);
String timestampHeader = headers.get(TIMESTAMP_HEADER);
String nonceHeader = headers.get(NONCE_HEADER);
String algorithmHeader = headers.get(ALGORITHM_HEADER);
Expand Down
Loading

0 comments on commit 8b6979f

Please sign in to comment.