Skip to content
This repository has been archived by the owner on Jun 15, 2021. It is now read-only.

Commit

Permalink
Added formData to be part of signing opts when content type is
Browse files Browse the repository at this point in the history
application/x-www-form-urlencoded
  • Loading branch information
ryanoolala committed Nov 16, 2018
1 parent c480920 commit a2e7495
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
10 changes: 5 additions & 5 deletions docker-compose.yml
Expand Up @@ -10,17 +10,17 @@ services:
SECURE: "false"
# Forward proxy settings
#HTTP_PROXY: https://abc:abc@266.266.266.266:333
#USE_PROXY_AGENT: true
#TO_PROXY: true
#USE_PROXY_AGENT: "true"
#TO_PROXY: "true"
# First Gateway
GATEWAY_IS_SINGLE: "true"
# GATEWAY_IS_SINGLE: "true"
GATEWAY_1_HOST: <yourproject>.api.xxx.sg
GATEWAY_1_SIGNING_HOST: <yourproject>.e.api.xxx.sg
GATEWAY_1_PORT: 443
GATEWAY_1_TYPE: EXTERNAL
GATEWAY_1_URL_PREFIX: app-internet
GATEWAY_1_APP_ID: app-id1
#GATEWAY_1_SECRET: private.pem
#GATEWAY_1_SECRET: secretpassword
#GATEWAY_1_KEY_STRING:
#GATEWAY_1_KEY_FILE: /private.pem
# Second Gateway
Expand All @@ -30,7 +30,7 @@ services:
GATEWAY_2_TYPE: INTERNAL
GATEWAY_2_URL_PREFIX: app-intranet
GATEWAY_2_APP_ID: app-id2
#GATEWAY_2_SECRET:
#GATEWAY_2_SECRET: secretpassword
#GATEWAY_2_KEY_STRING:
#GATEWAY_2_KEY_FILE: /private.pem
expose:
Expand Down
12 changes: 12 additions & 0 deletions src/handler.ts
Expand Up @@ -18,6 +18,7 @@ export const sign = ({
appId,
httpMethod,
urlPath,
formData,
}, config?) => {
let authPrefix;
if(type === 'INTERNAL'){
Expand All @@ -43,6 +44,7 @@ export const sign = ({
httpMethod,
authPrefix,
urlPath,
formData,
};

if(config && config.debug){
Expand Down Expand Up @@ -81,6 +83,7 @@ export const firstGateSignature = (req: http.IncomingMessage, config: IConfig):
appId: gateway1AppId,
httpMethod: method,
urlPath,
formData: formData(req)
}, config);
};

Expand Down Expand Up @@ -111,6 +114,7 @@ export const secondGateSignature = (req: http.IncomingMessage, config: IConfig):
appId: gateway2AppId,
httpMethod: method,
urlPath,
formData: formData(req),
}, config);
};

Expand Down Expand Up @@ -156,3 +160,11 @@ export const proxyHandler = (
}
}
};

function formData(req){
const headers = get(req,'headers');
if (get(headers,'content-type') === 'application/x-www-form-urlencoded') {
return req.body
}
return undefined
}

0 comments on commit a2e7495

Please sign in to comment.