dbgate-api-premium 7.2.2 → 7.2.3
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/package.json +6 -6
- package/src/auth/authProvider.js +1 -1
- package/src/controllers/storage.js +23 -1
- package/src/currentVersion.js +2 -2
- package/src/mcp.js +7 -10
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dbgate-api-premium",
|
|
3
3
|
"main": "src/index.js",
|
|
4
|
-
"version": "7.2.
|
|
4
|
+
"version": "7.2.3",
|
|
5
5
|
"homepage": "https://www.dbgate.io/",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -30,11 +30,11 @@
|
|
|
30
30
|
"compare-versions": "^3.6.0",
|
|
31
31
|
"cors": "^2.8.5",
|
|
32
32
|
"cross-env": "^6.0.3",
|
|
33
|
-
"dbgate-datalib": "7.2.
|
|
33
|
+
"dbgate-datalib": "7.2.3",
|
|
34
34
|
"dbgate-query-splitter": "^4.12.0",
|
|
35
|
-
"dbgate-rest": "7.2.
|
|
36
|
-
"dbgate-sqltree": "7.2.
|
|
37
|
-
"dbgate-tools": "7.2.
|
|
35
|
+
"dbgate-rest": "7.2.3",
|
|
36
|
+
"dbgate-sqltree": "7.2.3",
|
|
37
|
+
"dbgate-tools": "7.2.3",
|
|
38
38
|
"debug": "^4.3.4",
|
|
39
39
|
"diff": "^5.0.0",
|
|
40
40
|
"diff2html": "^3.4.13",
|
|
@@ -96,7 +96,7 @@
|
|
|
96
96
|
"@types/fs-extra": "^9.0.11",
|
|
97
97
|
"@types/jest": "^30.0.0",
|
|
98
98
|
"@types/lodash": "^4.14.149",
|
|
99
|
-
"dbgate-types": "7.2.
|
|
99
|
+
"dbgate-types": "7.2.3",
|
|
100
100
|
"env-cmd": "^10.1.0",
|
|
101
101
|
"jest": "^30.4.2",
|
|
102
102
|
"jsdoc-to-markdown": "^9.0.5",
|
package/src/auth/authProvider.js
CHANGED
|
@@ -349,7 +349,7 @@ function getDefaultAuthProvider() {
|
|
|
349
349
|
function getAuthProviderFromReq(req) {
|
|
350
350
|
const authProviderId = req?.auth?.amoid || req?.user?.amoid;
|
|
351
351
|
if (authProviderId == 'mcp') {
|
|
352
|
-
return require('
|
|
352
|
+
return require('../controllers/storage').getMcpAuthProvider();
|
|
353
353
|
}
|
|
354
354
|
return getAuthProviderById(authProviderId) ?? getDefaultAuthProvider();
|
|
355
355
|
}
|
|
@@ -2,12 +2,16 @@ const fs = require('fs-extra');
|
|
|
2
2
|
const _ = require('lodash');
|
|
3
3
|
const path = require('path');
|
|
4
4
|
const { setAuthProviders, getAuthProviderById } = require('../auth/authProvider');
|
|
5
|
-
const { createStorageAuthProvider, SuperadminAuthProvider } = require('../auth/storageAuthProvider');
|
|
5
|
+
const { createStorageAuthProvider, SuperadminAuthProvider, getMcpAuthProvider } = require('../auth/storageAuthProvider');
|
|
6
6
|
const {
|
|
7
7
|
getStorageConnection,
|
|
8
8
|
getDbConnectionParams,
|
|
9
9
|
storageSelectFmt,
|
|
10
10
|
storageReadUserRolePermissions,
|
|
11
|
+
storageReadRolePermissions: storageDbReadRolePermissions,
|
|
12
|
+
readComplexRolePermissions: storageDbReadComplexRolePermissions,
|
|
13
|
+
resolvePermissionConnectionIds: storageDbResolvePermissionConnectionIds,
|
|
14
|
+
storageCheckMcpConnectionAccess: storageDbCheckMcpConnectionAccess,
|
|
11
15
|
storageReadConfig,
|
|
12
16
|
storageWriteConfig,
|
|
13
17
|
getStorageConnectionError,
|
|
@@ -59,6 +63,24 @@ function mapConnection(connnection) {
|
|
|
59
63
|
let refreshLicenseStarted = false;
|
|
60
64
|
|
|
61
65
|
module.exports = {
|
|
66
|
+
getMcpAuthProvider,
|
|
67
|
+
|
|
68
|
+
async storageReadRolePermissions(roleId) {
|
|
69
|
+
return storageDbReadRolePermissions(roleId);
|
|
70
|
+
},
|
|
71
|
+
|
|
72
|
+
async readComplexRolePermissions(roleId, permissionType) {
|
|
73
|
+
return storageDbReadComplexRolePermissions(roleId, permissionType);
|
|
74
|
+
},
|
|
75
|
+
|
|
76
|
+
async resolvePermissionConnectionIds(permissions) {
|
|
77
|
+
return storageDbResolvePermissionConnectionIds(permissions);
|
|
78
|
+
},
|
|
79
|
+
|
|
80
|
+
async storageCheckMcpConnectionAccess(req, conid) {
|
|
81
|
+
return storageDbCheckMcpConnectionAccess(req, conid);
|
|
82
|
+
},
|
|
83
|
+
|
|
62
84
|
async _init() {
|
|
63
85
|
if (!process.env.STORAGE_DATABASE) {
|
|
64
86
|
return;
|
package/src/currentVersion.js
CHANGED
package/src/mcp.js
CHANGED
|
@@ -3,6 +3,7 @@ const jwt = require('jsonwebtoken');
|
|
|
3
3
|
const connections = require('./controllers/connections');
|
|
4
4
|
const serverConnections = require('./controllers/serverConnections');
|
|
5
5
|
const databaseConnections = require('./controllers/databaseConnections');
|
|
6
|
+
const storage = require('./controllers/storage');
|
|
6
7
|
const { maskConnection } = require('./utility/crypting');
|
|
7
8
|
const { isProApp } = require('./utility/checkLicense');
|
|
8
9
|
const requireEngineDriver = require('./utility/requireEngineDriver');
|
|
@@ -597,8 +598,7 @@ async function loadMcpRolePermissions(req) {
|
|
|
597
598
|
return null;
|
|
598
599
|
}
|
|
599
600
|
if (!req.__mcpRolePermissions) {
|
|
600
|
-
|
|
601
|
-
req.__mcpRolePermissions = (await storageReadRolePermissions(mcpRoleId)) ?? [];
|
|
601
|
+
req.__mcpRolePermissions = (await storage.storageReadRolePermissions(mcpRoleId)) ?? [];
|
|
602
602
|
}
|
|
603
603
|
return req.__mcpRolePermissions;
|
|
604
604
|
}
|
|
@@ -608,9 +608,8 @@ async function loadMcpDatabasePermissions(req) {
|
|
|
608
608
|
return null;
|
|
609
609
|
}
|
|
610
610
|
if (!req.__mcpDatabasePermissions) {
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
(await readComplexRolePermissions(mcpRoleId, 'role_databases')) ?? []
|
|
611
|
+
req.__mcpDatabasePermissions = await storage.resolvePermissionConnectionIds(
|
|
612
|
+
(await storage.readComplexRolePermissions(mcpRoleId, 'role_databases')) ?? []
|
|
614
613
|
);
|
|
615
614
|
}
|
|
616
615
|
return req.__mcpDatabasePermissions;
|
|
@@ -621,9 +620,8 @@ async function loadMcpTablePermissions(req) {
|
|
|
621
620
|
return null;
|
|
622
621
|
}
|
|
623
622
|
if (!req.__mcpTablePermissions) {
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
(await readComplexRolePermissions(mcpRoleId, 'role_tables')) ?? []
|
|
623
|
+
req.__mcpTablePermissions = await storage.resolvePermissionConnectionIds(
|
|
624
|
+
(await storage.readComplexRolePermissions(mcpRoleId, 'role_tables')) ?? []
|
|
627
625
|
);
|
|
628
626
|
}
|
|
629
627
|
return req.__mcpTablePermissions;
|
|
@@ -648,8 +646,7 @@ async function isMcpConnectionEnabled(connection, req) {
|
|
|
648
646
|
if (await mcpHasPermission('all-connections', req)) {
|
|
649
647
|
return true;
|
|
650
648
|
}
|
|
651
|
-
|
|
652
|
-
return storageCheckMcpConnectionAccess(req, getMcpConnectionId(connection));
|
|
649
|
+
return storage.storageCheckMcpConnectionAccess(req, getMcpConnectionId(connection));
|
|
653
650
|
}
|
|
654
651
|
return isMcpEnabledValue(connection.mcpEnabled);
|
|
655
652
|
}
|