Skip to content

Commit

Permalink
#1178: Bug fixes for POST /quotes with unknown destination FSP (mojal…
Browse files Browse the repository at this point in the history
…oop#160)

* Validate that FSP Ids in headers and payload match for both payerfsp and payeefsp
  • Loading branch information
oderayi authored and lewisdaly committed Apr 13, 2020
1 parent 1795b0e commit 0235170
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "quoting-service",
"description": "Quoting Service hosted by a scheme",
"license": "Apache-2.0",
"version": "9.3.2-snapshot",
"version": "9.3.3-snapshot",
"author": "Modusbox",
"contributors": [
"James Bush <james.bush@modusbox.com>",
Expand Down
10 changes: 10 additions & 0 deletions src/model/quotes.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,16 @@ class QuotesModel {
// internal-error
throw ErrorHandler.CreateInternalServerFSPIOPError('Missing quoteRequest', null, fspiopSource)
}

// We need to validate that the FSP Ids in the headers and payload match
if (fspiopSource !== quoteRequest.payer.partyIdInfo.fspId) {
throw ErrorHandler.CreateFSPIOPError(ErrorHandler.Enums.FSPIOPErrorCodes.VALIDATION_ERROR, '"fspiop-source" header does not match the payer FSP ID', null, fspiopSource)
}

if (fspiopDestination !== quoteRequest.payee.partyIdInfo.fspId) {
throw ErrorHandler.CreateFSPIOPError(ErrorHandler.Enums.FSPIOPErrorCodes.VALIDATION_ERROR, '"fspiop-destination" header does not match the payee FSP ID', null, fspiopSource)
}

await this.db.getParticipant(fspiopSource, LOCAL_ENUM.PAYER_DFSP)
await this.db.getParticipant(fspiopDestination, LOCAL_ENUM.PAYEE_DFSP)
}
Expand Down

0 comments on commit 0235170

Please sign in to comment.