Skip to content

Commit

Permalink
Merge pull request #35 from pagopa/feature/PN-13011
Browse files Browse the repository at this point in the history
PN-13011 changed validation of prefix for throttling intergation head…
alessioangelotti-pagopa authored Nov 7, 2024
2 parents a55e5ad + 56a4ed9 commit b924807
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/lib/awsOpenApiBuilder.js
Original file line number Diff line number Diff line change
@@ -31,6 +31,16 @@ function getPathParams(path){
})
}

function isApplicativeThrottlingValue(value) {
const allowedPrefixes = ['method.request', 'context.authorizer'];
for (let i = 0; i < allowedPrefixes.length; i++) {
if (value.startsWith(allowedPrefixes[i])) {
return true;
}
}
return false;
}

function getRequestParametersByIntendedUsage(intendedUsage, path, options = false, authorizerConfig, pathConfig = {}){
const parameters = {}

@@ -44,8 +54,9 @@ function getRequestParametersByIntendedUsage(intendedUsage, path, options = fals
// search for pathConfig the whitelistHeaders and set as parameters for the integration
for(let i=0; i<throttlingHeaders.length; i++){
if(pathConfig[throttlingHeaders[i]]){
// if pathConfig starts with method.request then set as is else set in "'"+value+"'"
const value = pathConfig[throttlingHeaders[i]].startsWith('method.request')?pathConfig[throttlingHeaders[i]]:"'"+pathConfig[throttlingHeaders[i]]+"'"
const value = isApplicativeThrottlingValue(pathConfig[throttlingHeaders[i]]) ?
pathConfig[throttlingHeaders[i]] :
"'"+pathConfig[throttlingHeaders[i]]+"'"
parameters['integration.request.header.'+throttlingHeaders[i]] = value
}
}

0 comments on commit b924807

Please sign in to comment.