exodus-framework 2.0.706 → 2.0.708
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/lib/contracts/messaging.d.ts +1 -1
- package/lib/contracts/security.d.ts +2 -2
- package/lib/contracts/security.d.ts.map +1 -1
- package/lib/middlewares/access.js +1 -1
- package/lib/models/DatabaseHost.d.ts +1 -1
- package/lib/models/DatabaseHost.js +2 -2
- package/lib/services/security.d.ts +4 -3
- package/lib/services/security.d.ts.map +1 -1
- package/lib/services/security.js +3 -0
- package/lib/services/sequelize.d.ts.map +1 -1
- package/lib/services/sequelize.js +10 -1
- package/package.json +1 -1
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"security.d.ts","sourceRoot":"","sources":["../../src/contracts/security.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG;IAAE,OAAO,EAAE,
|
1
|
+
{"version":3,"file":"security.d.ts","sourceRoot":"","sources":["../../src/contracts/security.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,CAAC,CAAC,GAAG,GAAG,IAAI;IAAE,OAAO,EAAE,CAAC,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAE5E,MAAM,MAAM,sBAAsB,GAAG;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC"}
|
@@ -46,7 +46,7 @@ class AccessMiddleware extends _controller.default {
|
|
46
46
|
if (!data) {
|
47
47
|
throw new _error.ApplicationHttpException('Token sem autênticidade.', _http.EHttpResponseCode.informationBlocked);
|
48
48
|
}
|
49
|
-
envUuid = data.envUuid;
|
49
|
+
envUuid = data.payload.envUuid;
|
50
50
|
}
|
51
51
|
} else if (tenantId) {
|
52
52
|
envUuid = tenantId;
|
@@ -33,11 +33,11 @@ DatabaseHost.init({
|
|
33
33
|
allowNull: false
|
34
34
|
},
|
35
35
|
credential: {
|
36
|
-
type: _sequelize.DataTypes.
|
36
|
+
type: _sequelize.DataTypes.TEXT,
|
37
37
|
allowNull: false
|
38
38
|
},
|
39
39
|
password: {
|
40
|
-
type: _sequelize.DataTypes.
|
40
|
+
type: _sequelize.DataTypes.TEXT,
|
41
41
|
allowNull: false
|
42
42
|
},
|
43
43
|
active: {
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { JWK
|
1
|
+
import { JWK } from 'node-jose';
|
2
2
|
import { Service } from '../app';
|
3
3
|
import { IService } from '../contracts';
|
4
4
|
import { TSignData } from '../contracts/security';
|
@@ -15,13 +15,14 @@ declare class SecurityService extends Service implements IService {
|
|
15
15
|
privateKey: string;
|
16
16
|
}>;
|
17
17
|
loadServicePublicKey(): Promise<void>;
|
18
|
+
loadKeyByStr(data: string): Promise<JWK.Key>;
|
18
19
|
getPrivateKey(): JWK.Key;
|
19
20
|
getPublicKey(): JWK.Key;
|
20
21
|
getServicePublicKey(): JWK.Key;
|
21
22
|
encrypt(data: TSignData, publicKey: JWK.Key): Promise<string | false>;
|
22
23
|
decrypt<T = any>(encryptedData: string, privateKey: JWK.Key): Promise<T | false>;
|
23
|
-
sign(data: TSignData, privateKey: JWK.Key): Promise<
|
24
|
-
verifySignature<T = any>(signature: string, publicKey: JWK.Key): Promise<T | false>;
|
24
|
+
sign(data: TSignData, privateKey: JWK.Key): Promise<string>;
|
25
|
+
verifySignature<T = any>(signature: string, publicKey: JWK.Key): Promise<TSignData<T> | false>;
|
25
26
|
simpleEncrypt(data: string | object): [string, Buffer];
|
26
27
|
simpleDecrypt(data: string, key: Buffer): Buffer | false;
|
27
28
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"security.d.ts","sourceRoot":"","sources":["../../src/services/security.ts"],"names":[],"mappings":"AAEA,OAAO,EAAO,GAAG,
|
1
|
+
{"version":3,"file":"security.d.ts","sourceRoot":"","sources":["../../src/services/security.ts"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.Service {
|
|
69
69
|
throw new _error.ApplicationException('Não foi possível localizar o certificado de serviço. Verifique o caminho nas configurações');
|
70
70
|
}
|
71
71
|
}
|
72
|
+
async loadKeyByStr(data) {
|
73
|
+
return await _nodeJose.JWK.asKey(data, 'pem');
|
74
|
+
}
|
72
75
|
|
73
76
|
/**
|
74
77
|
* Chave privada emitida por este serviço
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"sequelize.d.ts","sourceRoot":"","sources":["../../src/services/sequelize.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAE1D,OAAO,OAAO,MAAM,gBAAgB,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAKhD,OAAO,EAAE,SAAS,EAAgB,MAAM,WAAW,CAAC;
|
1
|
+
{"version":3,"file":"sequelize.d.ts","sourceRoot":"","sources":["../../src/services/sequelize.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAE1D,OAAO,OAAO,MAAM,gBAAgB,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAKhD,OAAO,EAAE,SAAS,EAAgB,MAAM,WAAW,CAAC;AAUpD,cAAM,gBAAiB,SAAQ,OAAQ,YAAW,QAAQ;IACxD,SAAS,EAAE,SAAS,CAAC;IACrB,QAAQ,EAAE,SAAS,CAAC;IACpB,MAAM,EAAE,WAAW,CAAC,GAAG,CAAC,EAAE,CAAC;IAC3B,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IACpC,iBAAiB,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,KAAK,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;IACvD,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;;IAM5B,IAAI;IAOJ,mBAAmB;IAgCzB,SAAS,CAAC,EAAE,EAAE,SAAS,EAAE,QAAQ,SAAI;IAerC,mBAAmB;IAGb,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;IA6CvC,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;IAwCvC,qBAAqB,CAAC,QAAQ,EAAE,MAAM;IA6BtC,YAAY,CAAC,QAAQ,EAAE,MAAM;IAsDnC,cAAc,CAAC,MAAM,EAAE,WAAW,CAAC,GAAG,CAAC,EAAE;IAInC,QAAQ,CAAC,CAAC,SAAS,OAAO,KAAK,CAAC,GAAG,EAAE,GAAG,CAAC,EAC7C,KAAK,EAAE,OAAO,KAAK,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG;QAAE,UAAU,EAAE,CAAC,UAAU,EAAE,SAAS,KAAK,CAAC,CAAA;KAAE,EAC5E,QAAQ,EAAE,MAAM;IAwBlB,uBAAuB,CAAC,MAAM,EAAE,MAAM;;;;IAOtC,sBAAsB,CAAC,QAAQ,EAAE,MAAM;CAGxC;AAED,eAAe,gBAAgB,CAAC"}
|
@@ -12,6 +12,7 @@ var _database = require("../utils/database");
|
|
12
12
|
var _logger = _interopRequireDefault(require("../utils/logger"));
|
13
13
|
var _error = require("./error");
|
14
14
|
var _models = require("../models");
|
15
|
+
var _security = _interopRequireDefault(require("./security"));
|
15
16
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
16
17
|
/**
|
17
18
|
* Serviço de gerênciamento do banco de dados
|
@@ -195,11 +196,19 @@ class SequelizeService extends _service.default {
|
|
195
196
|
this.log('Error on init connection, data not found! uuid: ' + hostUuid, 'danger');
|
196
197
|
return false;
|
197
198
|
}
|
199
|
+
const key = await _security.default.singleton().loadKeyByStr(host.credential);
|
200
|
+
const data = await _security.default.singleton().verifySignature(host.password, key);
|
201
|
+
if (!data) {
|
202
|
+
this.log('Error on decript password by credential: ' + hostUuid, 'danger');
|
203
|
+
return false;
|
204
|
+
}
|
205
|
+
const password = data.payload;
|
198
206
|
const conn = new _sequelize.Sequelize({
|
207
|
+
host: host.host,
|
199
208
|
database: dbName,
|
200
209
|
dialect: host.dialect,
|
201
210
|
username: host.username,
|
202
|
-
password:
|
211
|
+
password: password,
|
203
212
|
define: {
|
204
213
|
timestamps: true
|
205
214
|
},
|