Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ private WebhookSignatureValidator() {
* manifest before computing the HMAC
* @param dataId value of the {@code data.id} query parameter; may be {@code null} or
* blank, in which case the {@code id:} pair is omitted. When present,
* it is lowercased before being included in the manifest
* it is included in the manifest exactly as received
* @param secret secret signature configured for the application in Tus Integraciones,
* used as the HMAC key
* @throws MPInvalidWebhookSignatureException when the signature is missing, malformed, or
Expand Down Expand Up @@ -201,7 +201,7 @@ private static ParsedSignature parseSignatureHeader(String header) {
private static String buildManifest(String dataId, String requestId, String timestamp) {
StringBuilder sb = new StringBuilder();
if (dataId != null) {
sb.append("id:").append(dataId.toLowerCase()).append(';');
sb.append("id:").append(dataId).append(';');
}
if (requestId != null) {
sb.append("request-id:").append(requestId).append(';');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ private static String computeHash(String dataId, String requestId, String ts, St
try {
StringBuilder mb = new StringBuilder();
if (dataId != null && !dataId.isEmpty()) {
mb.append("id:").append(dataId.toLowerCase()).append(';');
mb.append("id:").append(dataId).append(';');
}
if (requestId != null && !requestId.isEmpty()) {
mb.append("request-id:").append(requestId).append(';');
Expand Down Expand Up @@ -68,9 +68,10 @@ void happyPathLowercase() {

// case 2
@Test
void uppercaseDataIdIsLowercased() {
void uppercaseDataIdIsPreserved() {
String upperHash = computeHash(DATA_ID_RAW, REQUEST_ID, TS, SECRET);
assertDoesNotThrow(() ->
WebhookSignatureValidator.validate(buildHeader(validHash()), REQUEST_ID, DATA_ID_RAW, SECRET));
WebhookSignatureValidator.validate(buildHeader(upperHash), REQUEST_ID, DATA_ID_RAW, SECRET));
}

// case 3
Expand Down