mirror of
https://github.com/dbgate/dbgate
synced 2024-11-08 04:35:58 +00:00
single connection support
This commit is contained in:
parent
2440d6b75f
commit
5d6d827044
@ -44,7 +44,7 @@ class AuthProviderBase {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
getSingleConnection(req) {
|
getSingleConnectionId(req) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,12 +34,16 @@ module.exports = {
|
|||||||
const isLoginForm = authProvider.isLoginForm();
|
const isLoginForm = authProvider.isLoginForm();
|
||||||
const additionalConfigProps = authProvider.getAdditionalConfigProps();
|
const additionalConfigProps = authProvider.getAdditionalConfigProps();
|
||||||
|
|
||||||
const singleConnection = await authProvider.getSingleConnection(req);
|
const singleConid = authProvider.getSingleConnectionId(req);
|
||||||
|
|
||||||
|
const singleConnection = singleConid
|
||||||
|
? await connections.getCore({ conid: singleConid })
|
||||||
|
: connections.singleConnection;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
runAsPortal: !!connections.portalConnections,
|
runAsPortal: !!connections.portalConnections,
|
||||||
singleDbConnection: connections.singleDbConnection,
|
singleDbConnection: connections.singleDbConnection,
|
||||||
singleConnection: connections.singleConnection,
|
singleConnection: singleConnection,
|
||||||
// hideAppEditor: !!process.env.HIDE_APP_EDITOR,
|
// hideAppEditor: !!process.env.HIDE_APP_EDITOR,
|
||||||
allowShellConnection: platformInfo.allowShellConnection,
|
allowShellConnection: platformInfo.allowShellConnection,
|
||||||
allowShellScripting: platformInfo.allowShellScripting,
|
allowShellScripting: platformInfo.allowShellScripting,
|
||||||
|
@ -414,11 +414,17 @@ module.exports = {
|
|||||||
|
|
||||||
dbloginAuth_meta: true,
|
dbloginAuth_meta: true,
|
||||||
async dbloginAuth({ conid, user, password }) {
|
async dbloginAuth({ conid, user, password }) {
|
||||||
const saveResp = await this.saveVolatile({ conid, user, password, test: true });
|
if (user || password) {
|
||||||
if (saveResp.msgtype == 'connected') {
|
const saveResp = await this.saveVolatile({ conid, user, password, test: true });
|
||||||
const loginResp = await getAuthProvider().login(user, password, { conid: saveResp._id });
|
if (saveResp.msgtype == 'connected') {
|
||||||
return loginResp;
|
const loginResp = await getAuthProvider().login(user, password, { conid: saveResp._id });
|
||||||
|
return loginResp;
|
||||||
|
}
|
||||||
|
return saveResp;
|
||||||
}
|
}
|
||||||
return saveResp;
|
|
||||||
|
// user and password is stored in connection, volatile connection is not needed
|
||||||
|
const loginResp = await getAuthProvider().login(null, null, { conid });
|
||||||
|
return loginResp;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -134,6 +134,13 @@
|
|||||||
} else {
|
} else {
|
||||||
sqlConnectResult = resp;
|
sqlConnectResult = resp;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
enableApi();
|
||||||
|
const resp = await apiCall('connections/dblogin-auth', {
|
||||||
|
conid: selectedConnection.conid,
|
||||||
|
});
|
||||||
|
localStorage.setItem('accessToken', resp.accessToken);
|
||||||
|
internalRedirectTo('?');
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
@ -10,11 +10,16 @@ import hasPermission from '../utility/hasPermission';
|
|||||||
// };
|
// };
|
||||||
|
|
||||||
const doServerPing = value => {
|
const doServerPing = value => {
|
||||||
|
const config = getCurrentConfig();
|
||||||
|
|
||||||
const conidArray = [...value];
|
const conidArray = [...value];
|
||||||
if (getCurrentConfig().storageDatabase && hasPermission('internal-storage')) {
|
if (config.storageDatabase && hasPermission('internal-storage')) {
|
||||||
conidArray.push('__storage');
|
conidArray.push('__storage');
|
||||||
}
|
}
|
||||||
conidArray.push(...getVolatileConnections());
|
conidArray.push(...getVolatileConnections());
|
||||||
|
if (config.singleConnection) {
|
||||||
|
conidArray.push(config.singleConnection._id);
|
||||||
|
}
|
||||||
|
|
||||||
apiCall('server-connections/ping', {
|
apiCall('server-connections/ping', {
|
||||||
conidArray,
|
conidArray,
|
||||||
|
Loading…
Reference in New Issue
Block a user