Skip to content

Commit

Permalink
fix: 🐛 Fix sigining countercheck because of additional enforced headers.
Browse files Browse the repository at this point in the history
  • Loading branch information
Hobart2967 committed Oct 2, 2023
1 parent 322f005 commit 8b03a13
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/services/request-verification.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,15 @@ export class RequestVerificationService {

const headers = this.getCleansedHeaders(request, incomingSignature);

const extraHeadersToIgnore =
Object
.keys(request.headers)
.map(x => x.toLowerCase())
.filter(x => !incomingSignature.signedHeaders.includes(x))
.reduce((prev, cur) => ({ ...prev, [cur]: true }), {});

this._logger.debug('Ignored headers upon signing: ' + JSON.stringify(extraHeadersToIgnore));

const signedCounterCheckRequest = this._signatureService.signRequestData(
accessKeyId,
secretKey, {
Expand All @@ -104,8 +113,9 @@ export class RequestVerificationService {
body: request.rawBody || request.body || undefined,
service: incomingSignature.credential.service,
headers,
region: incomingSignature.credential.region
});
region: incomingSignature.credential.region,
extraHeadersToIgnore
} as any);

const resultHeaders = signedCounterCheckRequest.headers as OutgoingHttpHeaders;
if (resultHeaders['Authorization']) {
Expand Down

0 comments on commit 8b03a13

Please sign in to comment.