thorin-plugin-cluster-kube 2.0.7 → 2.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +1 -0
- package/lib/clusterClient.js +3 -2
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -15,6 +15,7 @@ module.exports = function init(thorin, opt, pluginName) {
|
|
|
15
15
|
name: thorin.id
|
|
16
16
|
}, // this is the service name
|
|
17
17
|
token: process.env.CLUSTER_TOKEN || null, // A shared verification token used for auth
|
|
18
|
+
tokenHeader: 'x-cluster-token', // The HTTP header to place the auth token in
|
|
18
19
|
namespace: 'svc.cluster.local', // The kube namespace name
|
|
19
20
|
protocol: 'http', // The default protocol for all communication
|
|
20
21
|
alias: { // aliases for services.
|
package/lib/clusterClient.js
CHANGED
|
@@ -10,7 +10,8 @@ const crypto = require('crypto'),
|
|
|
10
10
|
module.exports = function init(thorin, opt) {
|
|
11
11
|
|
|
12
12
|
const ERROR_SERVICE = thorin.error('CLUSTER.DATA', 'Please provide the service name'),
|
|
13
|
-
ERROR_ACTION = thorin.error('CLUSTER.DATA', 'Please provide the action name')
|
|
13
|
+
ERROR_ACTION = thorin.error('CLUSTER.DATA', 'Please provide the action name'),
|
|
14
|
+
ERROR_PROXY = thorin.error('CLUSTER.AUTH', 'Request not authorized', 401);
|
|
14
15
|
|
|
15
16
|
const logger = thorin.logger(opt.logger),
|
|
16
17
|
fetch = thorin.fetch;
|
|
@@ -68,7 +69,7 @@ module.exports = function init(thorin, opt) {
|
|
|
68
69
|
timeout: _opt.timeout || opt.timeout
|
|
69
70
|
};
|
|
70
71
|
if (this.#token) {
|
|
71
|
-
fetchOpt.headers['x-cluster-token'] = this.sign(reqPayload, opt.service.id);
|
|
72
|
+
fetchOpt.headers[opt.tokenHeader || 'x-cluster-token'] = this.sign(reqPayload, opt.service.id);
|
|
72
73
|
}
|
|
73
74
|
if (_opt && _opt.headers) {
|
|
74
75
|
Object.keys(_opt.headers || {}).forEach(k => fetchOpt.headers[k] = _opt.headers[k]);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "thorin-plugin-cluster-kube",
|
|
3
3
|
"author": "UNLOQ Systems",
|
|
4
|
-
"version": "2.0.
|
|
4
|
+
"version": "2.0.9",
|
|
5
5
|
"dependencies": {},
|
|
6
6
|
"description": "Thorin.js cluster plugin for microservice communication within a kubernetes environment",
|
|
7
7
|
"main": "index.js",
|