diff options
Diffstat (limited to 'server/helpers/requests.ts')
-rw-r--r-- | server/helpers/requests.ts | 36 |
1 files changed, 17 insertions, 19 deletions
diff --git a/server/helpers/requests.ts b/server/helpers/requests.ts index b31074373..183f6df0d 100644 --- a/server/helpers/requests.ts +++ b/server/helpers/requests.ts | |||
@@ -33,7 +33,6 @@ type MakeSecureRequestParams = { | |||
33 | method: 'GET'|'POST' | 33 | method: 'GET'|'POST' |
34 | toPod: PodInstance | 34 | toPod: PodInstance |
35 | path: string | 35 | path: string |
36 | sign: boolean | ||
37 | data?: Object | 36 | data?: Object |
38 | } | 37 | } |
39 | function makeSecureRequest (params: MakeSecureRequestParams) { | 38 | function makeSecureRequest (params: MakeSecureRequestParams) { |
@@ -47,31 +46,30 @@ function makeSecureRequest (params: MakeSecureRequestParams) { | |||
47 | return rej(new Error('Cannot make a secure request with a non POST method.')) | 46 | return rej(new Error('Cannot make a secure request with a non POST method.')) |
48 | } | 47 | } |
49 | 48 | ||
50 | // Add signature if it is specified in the params | 49 | const host = CONFIG.WEBSERVER.HOST |
51 | if (params.sign === true) { | ||
52 | const host = CONFIG.WEBSERVER.HOST | ||
53 | 50 | ||
54 | let dataToSign | 51 | let dataToSign |
55 | if (params.data) { | 52 | if (params.data) { |
56 | dataToSign = params.data | 53 | dataToSign = params.data |
57 | } else { | 54 | } else { |
58 | // We do not have data to sign so we just take our host | 55 | // We do not have data to sign so we just take our host |
59 | // It is not ideal but the connection should be in HTTPS | 56 | // It is not ideal but the connection should be in HTTPS |
60 | dataToSign = host | 57 | dataToSign = host |
61 | } | 58 | } |
62 | 59 | ||
60 | sign(dataToSign).then(signature => { | ||
63 | requestParams.json['signature'] = { | 61 | requestParams.json['signature'] = { |
64 | host, // Which host we pretend to be | 62 | host, // Which host we pretend to be |
65 | signature: sign(dataToSign) | 63 | signature |
66 | } | 64 | } |
67 | } | ||
68 | 65 | ||
69 | // If there are data informations | 66 | // If there are data informations |
70 | if (params.data) { | 67 | if (params.data) { |
71 | requestParams.json['data'] = params.data | 68 | requestParams.json['data'] = params.data |
72 | } | 69 | } |
73 | 70 | ||
74 | request.post(requestParams, (err, response, body) => err ? rej(err) : res({ response, body })) | 71 | request.post(requestParams, (err, response, body) => err ? rej(err) : res({ response, body })) |
72 | }) | ||
75 | }) | 73 | }) |
76 | } | 74 | } |
77 | 75 | ||