mirror of
https://github.com/dbgate/dbgate
synced 2024-11-07 20:26:23 +00:00
single connection support
This commit is contained in:
parent
2440d6b75f
commit
5d6d827044
@ -44,7 +44,7 @@ class AuthProviderBase {
|
||||
return null;
|
||||
}
|
||||
|
||||
getSingleConnection(req) {
|
||||
getSingleConnectionId(req) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -34,12 +34,16 @@ module.exports = {
|
||||
const isLoginForm = authProvider.isLoginForm();
|
||||
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 {
|
||||
runAsPortal: !!connections.portalConnections,
|
||||
singleDbConnection: connections.singleDbConnection,
|
||||
singleConnection: connections.singleConnection,
|
||||
singleConnection: singleConnection,
|
||||
// hideAppEditor: !!process.env.HIDE_APP_EDITOR,
|
||||
allowShellConnection: platformInfo.allowShellConnection,
|
||||
allowShellScripting: platformInfo.allowShellScripting,
|
||||
|
@ -414,11 +414,17 @@ module.exports = {
|
||||
|
||||
dbloginAuth_meta: true,
|
||||
async dbloginAuth({ conid, user, password }) {
|
||||
const saveResp = await this.saveVolatile({ conid, user, password, test: true });
|
||||
if (saveResp.msgtype == 'connected') {
|
||||
const loginResp = await getAuthProvider().login(user, password, { conid: saveResp._id });
|
||||
return loginResp;
|
||||
if (user || password) {
|
||||
const saveResp = await this.saveVolatile({ conid, user, password, test: true });
|
||||
if (saveResp.msgtype == 'connected') {
|
||||
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 {
|
||||
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 config = getCurrentConfig();
|
||||
|
||||
const conidArray = [...value];
|
||||
if (getCurrentConfig().storageDatabase && hasPermission('internal-storage')) {
|
||||
if (config.storageDatabase && hasPermission('internal-storage')) {
|
||||
conidArray.push('__storage');
|
||||
}
|
||||
conidArray.push(...getVolatileConnections());
|
||||
if (config.singleConnection) {
|
||||
conidArray.push(config.singleConnection._id);
|
||||
}
|
||||
|
||||
apiCall('server-connections/ping', {
|
||||
conidArray,
|
||||
@ -51,4 +56,4 @@ export function subscribeConnectionPingers() {
|
||||
export function callServerPing() {
|
||||
const connections = getOpenedConnections();
|
||||
doServerPing(connections);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user