dbgate-api 7.0.6 → 7.1.1

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 CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "dbgate-api",
3
3
  "main": "src/index.js",
4
- "version": "7.0.6",
5
- "homepage": "https://dbgate.org/",
4
+ "version": "7.1.1",
5
+ "homepage": "https://www.dbgate.io/",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "https://github.com/dbgate/dbgate.git"
@@ -30,10 +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.0.6",
34
- "dbgate-query-splitter": "^4.11.9",
35
- "dbgate-sqltree": "^7.0.6",
36
- "dbgate-tools": "^7.0.6",
33
+ "dbgate-datalib": "^7.1.1",
34
+ "dbgate-query-splitter": "^4.12.0",
35
+ "dbgate-rest": "^7.1.1",
36
+ "dbgate-sqltree": "^7.1.1",
37
+ "dbgate-tools": "^7.1.1",
37
38
  "debug": "^4.3.4",
38
39
  "diff": "^5.0.0",
39
40
  "diff2html": "^3.4.13",
@@ -87,7 +88,7 @@
87
88
  "devDependencies": {
88
89
  "@types/fs-extra": "^9.0.11",
89
90
  "@types/lodash": "^4.14.149",
90
- "dbgate-types": "^7.0.6",
91
+ "dbgate-types": "^7.1.1",
91
92
  "env-cmd": "^10.1.0",
92
93
  "jsdoc-to-markdown": "^9.0.5",
93
94
  "node-loader": "^1.0.2",
@@ -202,7 +202,7 @@ module.exports = {
202
202
 
203
203
  const storageConnections = await storage.connections(req);
204
204
  if (storageConnections) {
205
- return storageConnections;
205
+ return storageConnections.map(maskConnection);
206
206
  }
207
207
  if (portalConnections) {
208
208
  if (platformInfo.allowShellConnection) return portalConnections.map(x => encryptConnection(x));
@@ -484,7 +484,7 @@ module.exports = {
484
484
 
485
485
  const storageConnection = await storage.getConnection({ conid });
486
486
  if (storageConnection) {
487
- return storageConnection;
487
+ return mask ? maskConnection(storageConnection) : storageConnection;
488
488
  }
489
489
 
490
490
  if (portalConnections) {
@@ -502,6 +502,9 @@ module.exports = {
502
502
  _id: '__model',
503
503
  };
504
504
  }
505
+ if (!conid) {
506
+ return null;
507
+ }
505
508
  await testConnectionPermission(conid, req);
506
509
  return this.getCore({ conid, mask: true });
507
510
  },
@@ -15,6 +15,7 @@ const {
15
15
  getLogger,
16
16
  extractErrorLogData,
17
17
  filterStructureBySchema,
18
+ serializeJsTypesForJsonStringify,
18
19
  } = require('dbgate-tools');
19
20
  const { html, parse } = require('diff2html');
20
21
  const { handleProcessCommunication } = require('../utility/processComm');
@@ -165,6 +166,11 @@ module.exports = {
165
166
  if (!connection) {
166
167
  throw new Error(`databaseConnections: Connection with conid="${conid}" not found`);
167
168
  }
169
+
170
+ if (connection.engine?.endsWith('@rest')) {
171
+ return { isApiConnection: true };
172
+ }
173
+
168
174
  if (connection.passwordMode == 'askPassword' || connection.passwordMode == 'askUser') {
169
175
  throw new MissingCredentialsError({ conid, passwordMode: connection.passwordMode });
170
176
  }
@@ -219,12 +225,13 @@ module.exports = {
219
225
  this.close(conid, database, false);
220
226
  });
221
227
 
222
- subprocess.send({
228
+ const connectMessage = serializeJsTypesForJsonStringify({
223
229
  msgtype: 'connect',
224
230
  connection: { ...connection, database },
225
231
  structure: lastClosed ? lastClosed.structure : null,
226
232
  globalSettings: await config.getSettings(),
227
233
  });
234
+ subprocess.send(connectMessage);
228
235
  return newOpened;
229
236
  },
230
237
 
@@ -234,7 +241,8 @@ module.exports = {
234
241
  const promise = new Promise((resolve, reject) => {
235
242
  this.requests[msgid] = [resolve, reject, additionalData];
236
243
  try {
237
- conn.subprocess.send({ msgid, ...message });
244
+ const serializedMessage = serializeJsTypesForJsonStringify({ msgid, ...message });
245
+ conn.subprocess.send(serializedMessage);
238
246
  } catch (err) {
239
247
  logger.error(extractErrorLogData(err), 'DBGM-00115 Error sending request do process');
240
248
  this.close(conn.conid, conn.database);
@@ -468,6 +476,7 @@ module.exports = {
468
476
 
469
477
  const databasePermissions = await loadDatabasePermissionsFromRequest(req);
470
478
  const tablePermissions = await loadTablePermissionsFromRequest(req);
479
+ const databasePermissionRole = getDatabasePermissionRole(conid, database, databasePermissions);
471
480
  const fieldsAndRoles = [
472
481
  [changeSet.inserts, 'create_update_delete'],
473
482
  [changeSet.deletes, 'create_update_delete'],
@@ -482,7 +491,7 @@ module.exports = {
482
491
  operation.schemaName,
483
492
  operation.pureName,
484
493
  tablePermissions,
485
- databasePermissions
494
+ databasePermissionRole
486
495
  );
487
496
  if (getTablePermissionRoleLevelIndex(role) < getTablePermissionRoleLevelIndex(requiredRole)) {
488
497
  throw new Error('DBGM-00262 Permission not granted');
@@ -0,0 +1,41 @@
1
+ module.exports = {
2
+ disconnect_meta: true,
3
+ async disconnect({ conid }, req) {
4
+ return null;
5
+ },
6
+
7
+ getApiInfo_meta: true,
8
+ async getApiInfo({ conid }, req) {
9
+ return null;
10
+ },
11
+
12
+ restStatus_meta: true,
13
+ async restStatus() {
14
+ return {};
15
+ },
16
+
17
+ ping_meta: true,
18
+ async ping({ conidArray, strmid }) {
19
+ return null;
20
+ },
21
+
22
+ refresh_meta: true,
23
+ async refresh({ conid, keepOpen }, req) {
24
+ return null;
25
+ },
26
+
27
+ testConnection_meta: true,
28
+ async testConnection({ conid }, req) {
29
+ return null;
30
+ },
31
+
32
+ execute_meta: true,
33
+ async execute({ conid, method, endpoint, parameters, server }, req) {
34
+ return null;
35
+ },
36
+
37
+ apiQuery_meta: true,
38
+ async apiQuery({ conid, server, query, variables }, req) {
39
+ return null;
40
+ },
41
+ };
@@ -172,7 +172,7 @@ module.exports = {
172
172
  byline(subprocess.stderr).on('data', pipeDispatcher('error'));
173
173
  subprocess.on('exit', code => {
174
174
  // console.log('... EXITED', code);
175
- this.rejectRequest(runid, { message: 'No data returned, maybe input data source is too big' });
175
+ this.rejectRequest(runid, { message: 'DBGM-00281 No data returned, maybe input data source is too big' });
176
176
  logger.info({ code, pid: subprocess.pid }, 'DBGM-00016 Exited process');
177
177
  socket.emit(`runner-done-${runid}`, code);
178
178
  this.opened = this.opened.filter(x => x.runid != runid);
@@ -225,7 +225,7 @@ module.exports = {
225
225
  subprocess.on('exit', code => {
226
226
  console.log('... EXITED', code);
227
227
  logger.info({ code, pid: subprocess.pid }, 'DBGM-00017 Exited process');
228
- this.dispatchMessage(runid, `Finished external process with code ${code}`);
228
+ this.dispatchMessage(runid, `DBGM-00282 Finished external process with code ${code}`);
229
229
  socket.emit(`runner-done-${runid}`, code);
230
230
  if (onFinished) {
231
231
  onFinished();
@@ -233,7 +233,7 @@ module.exports = {
233
233
  this.opened = this.opened.filter(x => x.runid != runid);
234
234
  });
235
235
  subprocess.on('spawn', () => {
236
- this.dispatchMessage(runid, `Started external process ${command}`);
236
+ this.dispatchMessage(runid, `DBGM-00283 Started external process ${command}`);
237
237
  });
238
238
  subprocess.on('error', error => {
239
239
  console.log('... ERROR subprocess', error);
@@ -279,7 +279,7 @@ module.exports = {
279
279
  if (script.type == 'json') {
280
280
  if (!platformInfo.isElectron) {
281
281
  if (!checkSecureDirectoriesInScript(script)) {
282
- return { errorMessage: 'Unallowed directories in script' };
282
+ return { errorMessage: 'DBGM-00284 Unallowed directories in script' };
283
283
  }
284
284
  }
285
285
 
@@ -299,10 +299,10 @@ module.exports = {
299
299
  action: 'script',
300
300
  severity: 'warn',
301
301
  detail: script,
302
- message: 'Scripts are not allowed',
302
+ message: 'DBGM-00285 Scripts are not allowed',
303
303
  });
304
304
 
305
- return { errorMessage: 'Shell scripting is not allowed' };
305
+ return { errorMessage: 'DBGM-00286 Shell scripting is not allowed' };
306
306
  }
307
307
 
308
308
  sendToAuditLog(req, {
@@ -312,7 +312,7 @@ module.exports = {
312
312
  action: 'script',
313
313
  severity: 'info',
314
314
  detail: script,
315
- message: 'Running JS script',
315
+ message: 'DBGM-00287 Running JS script',
316
316
  });
317
317
 
318
318
  return this.startCore(runid, scriptTemplate(script, false));
@@ -327,7 +327,7 @@ module.exports = {
327
327
  async cancel({ runid }) {
328
328
  const runner = this.opened.find(x => x.runid == runid);
329
329
  if (!runner) {
330
- throw new Error('Invalid runner');
330
+ throw new Error('DBGM-00288 Invalid runner');
331
331
  }
332
332
  runner.subprocess.kill();
333
333
  return { state: 'ok' };
@@ -353,7 +353,7 @@ module.exports = {
353
353
  async loadReader({ functionName, props }) {
354
354
  if (!platformInfo.isElectron) {
355
355
  if (props?.fileName && !checkSecureDirectories(props.fileName)) {
356
- return { errorMessage: 'Unallowed file' };
356
+ return { errorMessage: 'DBGM-00289 Unallowed file' };
357
357
  }
358
358
  }
359
359
  const prefix = extractShellApiPlugins(functionName)
@@ -371,7 +371,7 @@ module.exports = {
371
371
  scriptResult_meta: true,
372
372
  async scriptResult({ script }) {
373
373
  if (script.type != 'json') {
374
- return { errorMessage: 'Only JSON scripts are allowed' };
374
+ return { errorMessage: 'DBGM-00290 Only JSON scripts are allowed' };
375
375
  }
376
376
 
377
377
  const promise = new Promise(async (resolve, reject) => {
@@ -171,7 +171,7 @@ module.exports = {
171
171
  const databasePermissions = await loadDatabasePermissionsFromRequest(req);
172
172
  const res = [];
173
173
  for (const db of opened?.databases ?? []) {
174
- const databasePermissionRole = getDatabasePermissionRole(db.id, db.name, databasePermissions);
174
+ const databasePermissionRole = getDatabasePermissionRole(conid, db.name, databasePermissions);
175
175
  if (databasePermissionRole != 'deny') {
176
176
  res.push({
177
177
  ...db,
@@ -1,5 +1,5 @@
1
1
 
2
2
  module.exports = {
3
- version: '7.0.6',
4
- buildTime: '2026-02-13T08:57:16.844Z'
3
+ version: '7.1.1',
4
+ buildTime: '2026-02-27T15:10:31.914Z'
5
5
  };
package/src/main.js CHANGED
@@ -14,6 +14,7 @@ const socket = require('./utility/socket');
14
14
  const connections = require('./controllers/connections');
15
15
  const serverConnections = require('./controllers/serverConnections');
16
16
  const databaseConnections = require('./controllers/databaseConnections');
17
+ const restConnections = require('./controllers/restConnections');
17
18
  const metadata = require('./controllers/metadata');
18
19
  const sessions = require('./controllers/sessions');
19
20
  const runners = require('./controllers/runners');
@@ -267,6 +268,7 @@ function useAllControllers(app, electron) {
267
268
  useController(app, electron, '/auth', auth);
268
269
  useController(app, electron, '/cloud', cloud);
269
270
  useController(app, electron, '/team-files', teamFiles);
271
+ useController(app, electron, '/rest-connections', restConnections);
270
272
  }
271
273
 
272
274
  function setElectronSender(electronSender) {
@@ -1,6 +1,6 @@
1
1
  const childProcessChecker = require('../utility/childProcessChecker');
2
2
  const requireEngineDriver = require('../utility/requireEngineDriver');
3
- const { connectUtility } = require('../utility/connectUtility');
3
+ const { connectUtility, getRestAuthFromConnection } = require('../utility/connectUtility');
4
4
  const { handleProcessCommunication } = require('../utility/processComm');
5
5
  const { pickSafeConnectionInfo } = require('../utility/crypting');
6
6
  const _ = require('lodash');
@@ -29,6 +29,9 @@ function start() {
29
29
  try {
30
30
  const driver = requireEngineDriver(connection);
31
31
  const connectionChanged = driver?.beforeConnectionSave ? driver.beforeConnectionSave(connection) : connection;
32
+ if (driver?.databaseEngineTypes?.includes('rest')) {
33
+ connectionChanged.restAuth = getRestAuthFromConnection(connection);
34
+ }
32
35
 
33
36
  if (!connection.isVolatileResolved) {
34
37
  if (connectionChanged.useRedirectDbLogin) {
package/src/proc/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  const connectProcess = require('./connectProcess');
2
2
  const databaseConnectionProcess = require('./databaseConnectionProcess');
3
3
  const serverConnectionProcess = require('./serverConnectionProcess');
4
+ const restConnectionProcess = require('./restConnectionProcess');
4
5
  const sessionProcess = require('./sessionProcess');
5
6
  const jslDatastoreProcess = require('./jslDatastoreProcess');
6
7
  const sshForwardProcess = require('./sshForwardProcess');
@@ -9,6 +10,7 @@ module.exports = {
9
10
  connectProcess,
10
11
  databaseConnectionProcess,
11
12
  serverConnectionProcess,
13
+ restConnectionProcess,
12
14
  sessionProcess,
13
15
  jslDatastoreProcess,
14
16
  sshForwardProcess,
@@ -0,0 +1,7 @@
1
+ const childProcessChecker = require('../utility/childProcessChecker');
2
+
3
+ function start() {
4
+ childProcessChecker();
5
+ }
6
+
7
+ module.exports = { start };
@@ -4,7 +4,8 @@ const { pluginsdir, packagedPluginsDir, getPluginBackendPath } = require('../uti
4
4
  const platformInfo = require('../utility/platformInfo');
5
5
  const authProxy = require('../utility/authProxy');
6
6
  const { getLogger } = require('dbgate-tools');
7
- //
7
+ const { openApiDriver, graphQlDriver, oDataDriver } = require('dbgate-rest');
8
+ //
8
9
  const logger = getLogger('requirePlugin');
9
10
 
10
11
  const loadedPlugins = {};
@@ -13,16 +14,21 @@ const dbgateEnv = {
13
14
  dbgateApi: null,
14
15
  platformInfo,
15
16
  authProxy,
16
- isProApp: () =>{
17
+ isProApp: () => {
17
18
  const { isProApp } = require('../utility/checkLicense');
18
19
  return isProApp();
19
- }
20
+ },
20
21
  };
21
22
  function requirePlugin(packageName, requiredPlugin = null) {
22
23
  if (!packageName) throw new Error('Missing packageName in plugin');
23
24
  if (loadedPlugins[packageName]) return loadedPlugins[packageName];
24
25
 
25
26
  if (requiredPlugin == null) {
27
+ if (packageName.endsWith('@rest') || packageName === 'rest') {
28
+ return {
29
+ drivers: [openApiDriver, graphQlDriver, oDataDriver],
30
+ };
31
+ }
26
32
  let module;
27
33
  const modulePath = getPluginBackendPath(packageName);
28
34
  logger.info(`DBGM-00062 Loading module ${packageName} from ${modulePath}`);
@@ -850,84 +850,6 @@ module.exports = {
850
850
  }
851
851
  ]
852
852
  },
853
- {
854
- "pureName": "password_reset_tokens",
855
- "columns": [
856
- {
857
- "pureName": "password_reset_tokens",
858
- "columnName": "id",
859
- "dataType": "int",
860
- "autoIncrement": true,
861
- "notNull": true
862
- },
863
- {
864
- "pureName": "password_reset_tokens",
865
- "columnName": "user_id",
866
- "dataType": "int",
867
- "notNull": true
868
- },
869
- {
870
- "pureName": "password_reset_tokens",
871
- "columnName": "token",
872
- "dataType": "varchar(500)",
873
- "notNull": true
874
- },
875
- {
876
- "pureName": "password_reset_tokens",
877
- "columnName": "created_at",
878
- "dataType": "datetime",
879
- "notNull": true
880
- },
881
- {
882
- "pureName": "password_reset_tokens",
883
- "columnName": "expires_at",
884
- "dataType": "datetime",
885
- "notNull": true
886
- },
887
- {
888
- "pureName": "password_reset_tokens",
889
- "columnName": "used_at",
890
- "dataType": "datetime",
891
- "notNull": false
892
- }
893
- ],
894
- "foreignKeys": [
895
- {
896
- "constraintType": "foreignKey",
897
- "constraintName": "FK_password_reset_tokens_user_id",
898
- "pureName": "password_reset_tokens",
899
- "refTableName": "users",
900
- "columns": [
901
- {
902
- "columnName": "user_id",
903
- "refColumnName": "id"
904
- }
905
- ]
906
- }
907
- ],
908
- "indexes": [
909
- {
910
- "constraintName": "idx_token",
911
- "pureName": "password_reset_tokens",
912
- "constraintType": "index",
913
- "columns": [
914
- {
915
- "columnName": "token"
916
- }
917
- ]
918
- }
919
- ],
920
- "primaryKey": {
921
- "pureName": "password_reset_tokens",
922
- "constraintType": "primaryKey",
923
- "constraintName": "PK_password_reset_tokens",
924
- "columns": [
925
- {
926
- "columnName": "id"
927
- }
928
- ]
929
- }
930
- },
931
853
  {
932
854
  "pureName": "roles",
933
855
  "columns": [
@@ -2252,6 +2174,84 @@ module.exports = {
2252
2174
  ]
2253
2175
  }
2254
2176
  },
2177
+ {
2178
+ "pureName": "user_password_reset_tokens",
2179
+ "columns": [
2180
+ {
2181
+ "pureName": "user_password_reset_tokens",
2182
+ "columnName": "id",
2183
+ "dataType": "int",
2184
+ "autoIncrement": true,
2185
+ "notNull": true
2186
+ },
2187
+ {
2188
+ "pureName": "user_password_reset_tokens",
2189
+ "columnName": "user_id",
2190
+ "dataType": "int",
2191
+ "notNull": true
2192
+ },
2193
+ {
2194
+ "pureName": "user_password_reset_tokens",
2195
+ "columnName": "token",
2196
+ "dataType": "varchar(500)",
2197
+ "notNull": true
2198
+ },
2199
+ {
2200
+ "pureName": "user_password_reset_tokens",
2201
+ "columnName": "created_at",
2202
+ "dataType": "varchar(32)",
2203
+ "notNull": true
2204
+ },
2205
+ {
2206
+ "pureName": "user_password_reset_tokens",
2207
+ "columnName": "expires_at",
2208
+ "dataType": "varchar(32)",
2209
+ "notNull": true
2210
+ },
2211
+ {
2212
+ "pureName": "user_password_reset_tokens",
2213
+ "columnName": "used_at",
2214
+ "dataType": "varchar(32)",
2215
+ "notNull": false
2216
+ }
2217
+ ],
2218
+ "foreignKeys": [
2219
+ {
2220
+ "constraintType": "foreignKey",
2221
+ "constraintName": "FK_user_password_reset_tokens_user_id",
2222
+ "pureName": "user_password_reset_tokens",
2223
+ "refTableName": "users",
2224
+ "columns": [
2225
+ {
2226
+ "columnName": "user_id",
2227
+ "refColumnName": "id"
2228
+ }
2229
+ ]
2230
+ }
2231
+ ],
2232
+ "indexes": [
2233
+ {
2234
+ "constraintName": "idx_token",
2235
+ "pureName": "user_password_reset_tokens",
2236
+ "constraintType": "index",
2237
+ "columns": [
2238
+ {
2239
+ "columnName": "token"
2240
+ }
2241
+ ]
2242
+ }
2243
+ ],
2244
+ "primaryKey": {
2245
+ "pureName": "user_password_reset_tokens",
2246
+ "constraintType": "primaryKey",
2247
+ "constraintName": "PK_user_password_reset_tokens",
2248
+ "columns": [
2249
+ {
2250
+ "columnName": "id"
2251
+ }
2252
+ ]
2253
+ }
2254
+ },
2255
2255
  {
2256
2256
  "pureName": "user_permissions",
2257
2257
  "columns": [
@@ -1,9 +1,10 @@
1
1
  const fs = require('fs-extra');
2
- const { decryptConnection } = require('./crypting');
2
+ const { decryptConnection, decryptPasswordString } = require('./crypting');
3
3
  const { getSshTunnelProxy } = require('./sshTunnelProxy');
4
4
  const platformInfo = require('../utility/platformInfo');
5
5
  const connections = require('../controllers/connections');
6
6
  const _ = require('lodash');
7
+ const axios = require('axios');
7
8
 
8
9
  async function loadConnection(driver, storedConnection, connectionMode) {
9
10
  const { allowShellConnection, allowConnectionFromEnvVariables } = platformInfo;
@@ -131,12 +132,39 @@ async function connectUtility(driver, storedConnection, connectionMode, addition
131
132
  }
132
133
 
133
134
  connection.ssl = await extractConnectionSslParams(connection);
135
+ connection.axios = axios.default;
134
136
 
135
137
  const conn = await driver.connect({ conid: connectionLoaded?._id, ...connection, ...additionalOptions });
136
138
  return conn;
137
139
  }
138
140
 
141
+ function getRestAuthFromConnection(connection) {
142
+ if (!connection) return null;
143
+ if (connection.authType == 'basic') {
144
+ return {
145
+ type: 'basic',
146
+ user: connection.user,
147
+ password: decryptPasswordString(connection.password),
148
+ };
149
+ }
150
+ if (connection.authType == 'bearer') {
151
+ return {
152
+ type: 'bearer',
153
+ token: connection.authToken,
154
+ };
155
+ }
156
+ if (connection.authType == 'apikey') {
157
+ return {
158
+ type: 'apikey',
159
+ header: connection.apiKeyHeader,
160
+ value: connection.apiKeyValue,
161
+ };
162
+ }
163
+ return null;
164
+ }
165
+
139
166
  module.exports = {
140
167
  extractConnectionSslParams,
141
168
  connectUtility,
169
+ getRestAuthFromConnection,
142
170
  };
@@ -102,6 +102,26 @@ function decryptObjectPasswordField(obj, field, encryptor = null) {
102
102
  }
103
103
 
104
104
  const fieldsToEncrypt = ['password', 'sshPassword', 'sshKeyfilePassword', 'connectionDefinition'];
105
+ const additionalFieldsToMask = [
106
+ 'databaseUrl',
107
+ 'server',
108
+ 'port',
109
+ 'user',
110
+ 'sshBastionHost',
111
+ 'sshHost',
112
+ 'sshKeyFile',
113
+ 'sshLogin',
114
+ 'sshMode',
115
+ 'sshPort',
116
+ 'sslCaFile',
117
+ 'sslCertFilePassword',
118
+ 'sslKeyFile',
119
+ 'sslRejectUnauthorized',
120
+ 'secretAccessKey',
121
+ 'accessKeyId',
122
+ 'endpoint',
123
+ 'endpointKey',
124
+ ];
105
125
 
106
126
  function encryptConnection(connection, encryptor = null) {
107
127
  if (connection.passwordMode != 'saveRaw') {
@@ -114,7 +134,7 @@ function encryptConnection(connection, encryptor = null) {
114
134
 
115
135
  function maskConnection(connection) {
116
136
  if (!connection) return connection;
117
- return _.omit(connection, fieldsToEncrypt);
137
+ return _.omit(connection, [...fieldsToEncrypt, ...additionalFieldsToMask]);
118
138
  }
119
139
 
120
140
  function decryptConnection(connection) {
@@ -25,8 +25,14 @@ function extractConnectionsFromEnv(env) {
25
25
  socketPath: env[`SOCKET_PATH_${id}`],
26
26
  serviceName: env[`SERVICE_NAME_${id}`],
27
27
  authType: env[`AUTH_TYPE_${id}`] || (env[`SOCKET_PATH_${id}`] ? 'socket' : undefined),
28
- defaultDatabase: env[`DATABASE_${id}`] || (env[`FILE_${id}`] ? getDatabaseFileLabel(env[`FILE_${id}`]) : null),
29
- singleDatabase: !!env[`DATABASE_${id}`] || !!env[`FILE_${id}`],
28
+ defaultDatabase:
29
+ env[`DATABASE_${id}`] ||
30
+ (env[`FILE_${id}`]
31
+ ? getDatabaseFileLabel(env[`FILE_${id}`])
32
+ : env[`APISERVERURL1_${id}`]
33
+ ? '_api_database_'
34
+ : null),
35
+ singleDatabase: !!env[`DATABASE_${id}`] || !!env[`FILE_${id}`] || !!env[`APISERVERURL1_${id}`],
30
36
  displayName: env[`LABEL_${id}`],
31
37
  isReadOnly: env[`READONLY_${id}`],
32
38
  databases: env[`DBCONFIG_${id}`] ? safeJsonParse(env[`DBCONFIG_${id}`]) : null,
@@ -54,6 +60,11 @@ function extractConnectionsFromEnv(env) {
54
60
  sslKeyFile: env[`SSL_KEY_FILE_${id}`],
55
61
  sslRejectUnauthorized: env[`SSL_REJECT_UNAUTHORIZED_${id}`],
56
62
  trustServerCertificate: env[`SSL_TRUST_CERTIFICATE_${id}`],
63
+
64
+ apiServerUrl1: env[`APISERVERURL1_${id}`],
65
+ apiServerUrl2: env[`APISERVERURL2_${id}`],
66
+ apiKeyHeader: env[`APIKEYHEADER_${id}`],
67
+ apiKeyValue: env[`APIKEYVALUE_${id}`],
57
68
  }));
58
69
 
59
70
  return connections;
@@ -96,8 +96,9 @@ async function loadFilePermissionsFromRequest(req) {
96
96
  }
97
97
 
98
98
  function matchDatabasePermissionRow(conid, database, permissionRow) {
99
- if (permissionRow.connection_id) {
100
- if (conid != permissionRow.connection_id) {
99
+ const connectionIdentifier = permissionRow.connection_conid ?? permissionRow.connection_id;
100
+ if (connectionIdentifier) {
101
+ if (conid != connectionIdentifier) {
101
102
  return false;
102
103
  }
103
104
  }