exodus-framework 2.0.968 → 2.0.970
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.
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"access.d.ts","sourceRoot":"","sources":["../../src/middlewares/access.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAEzC,OAAO,cAAc,MAAM,mBAAmB,CAAC;AAC/C,OAAO,
|
1
|
+
{"version":3,"file":"access.d.ts","sourceRoot":"","sources":["../../src/middlewares/access.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAEzC,OAAO,cAAc,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAY,YAAY,EAAE,MAAM,cAAc,CAAC;AAMtD,cAAM,gBAAiB,SAAQ,cAAc;IAO3C,WAAW,UAAW,YAAY,EAAE,KAAG,cAAc,CAWnD;IAEF,SAAS,EAAE,cAAc,CAkHvB;CACH;AAED,eAAe,gBAAgB,CAAC"}
|
@@ -33,10 +33,11 @@ class AccessMiddleware extends _controller.default {
|
|
33
33
|
const account = req.auth?.account;
|
34
34
|
const tenantId = req.header('X-Exodus-Tenant-ID');
|
35
35
|
const applicationId = req.header('X-Exodus-Application-ID');
|
36
|
+
const exodusServiceId = req.header('X-Exodus-Service-ID');
|
36
37
|
let isApplication = false;
|
37
38
|
|
38
39
|
//! Negar caso não haja um ou outro;
|
39
|
-
if (!account && !applicationId && !tenantId) {
|
40
|
+
if (!account && !applicationId && !tenantId && !exodusServiceId) {
|
40
41
|
throw new _app.HttpError({
|
41
42
|
message: 'Credênciais de autênticação não informadas',
|
42
43
|
statusCode: _http.EHttpResponseCode.informationUnauthorized
|
@@ -76,7 +77,7 @@ class AccessMiddleware extends _controller.default {
|
|
76
77
|
});
|
77
78
|
} else {
|
78
79
|
//valido
|
79
|
-
const data = await _security.default.
|
80
|
+
const data = await _security.default.getService().verifySignature(applicationId, _security.default.getService().getServicePublicKey());
|
80
81
|
if (!data) {
|
81
82
|
throw new _app.HttpError({
|
82
83
|
message: 'Token sem autênticidade.',
|
@@ -90,13 +91,33 @@ class AccessMiddleware extends _controller.default {
|
|
90
91
|
requestor.trigger = applicationId;
|
91
92
|
envUuid = data.payload.envUuid;
|
92
93
|
}
|
94
|
+
} else if (exodusServiceId) {
|
95
|
+
const data = await _security.default.getService().verifySignature(exodusServiceId, _security.default.getService().getServicePublicKey());
|
96
|
+
if (!data) {
|
97
|
+
throw new _app.HttpError({
|
98
|
+
message: 'Token de serviço inválido',
|
99
|
+
statusCode: _http.EHttpResponseCode.informationUnauthorized
|
100
|
+
});
|
101
|
+
}
|
102
|
+
requestor.database = data['account'].database;
|
103
|
+
requestor.environmentId = data['account'].envUuid;
|
104
|
+
requestor.name = data['account'].name;
|
105
|
+
requestor.id = data['account'].uuid;
|
106
|
+
requestor.trigger = exodusServiceId;
|
107
|
+
envUuid = data['account'].envUuid;
|
93
108
|
} else if (tenantId) {
|
94
|
-
if (!account) {
|
109
|
+
if (!account || !exodusServiceId) {
|
95
110
|
throw new _app.HttpError({
|
96
111
|
message: 'Não é permitido o uso do tenantId sem uma sessão ativa',
|
97
112
|
statusCode: _http.EHttpResponseCode.informationBlocked
|
98
113
|
});
|
99
114
|
}
|
115
|
+
if (exodusServiceId != process.env.SECURITY_JWT_ISSUER) {
|
116
|
+
throw new _app.HttpError({
|
117
|
+
message: 'O token de serviço é inválido',
|
118
|
+
statusCode: _http.EHttpResponseCode.informationBlocked
|
119
|
+
});
|
120
|
+
}
|
100
121
|
envUuid = tenantId;
|
101
122
|
if (account.type != 'ADMINISTRATOR') {
|
102
123
|
requestor.environmentId = account.envUuid;
|
package/lib/services/express.js
CHANGED
@@ -50,8 +50,8 @@ class ExpressService extends _service.default {
|
|
50
50
|
expss.use(this.mainRouter);
|
51
51
|
expss.use(this.handleAuthorizationFailure.bind(this));
|
52
52
|
expss.use(this.handleNotFoud.bind(this));
|
53
|
-
expss.use(this.handleRequestProcessFailure.bind(this));
|
54
53
|
expss.use(this.handleJSONParseFailure.bind(this));
|
54
|
+
expss.use(this.handleRequestProcessFailure.bind(this));
|
55
55
|
return true;
|
56
56
|
}
|
57
57
|
async onExodusClusterStarted() {
|