mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-17 23:45:59 +00:00
token checking
This commit is contained in:
@@ -18,6 +18,7 @@ const { connectionHasPermission, testConnectionPermission } = require('../utilit
|
||||
const pipeForkLogs = require('../utility/pipeForkLogs');
|
||||
const requireEngineDriver = require('../utility/requireEngineDriver');
|
||||
const { getAuthProviderById } = require('../auth/authProvider');
|
||||
const { startTokenChecking } = require('../utility/authProxy');
|
||||
|
||||
const logger = getLogger('connections');
|
||||
|
||||
@@ -394,23 +395,27 @@ module.exports = {
|
||||
const { conid, state, redirectUri } = req.query;
|
||||
const connection = await this.getCore({ conid });
|
||||
const driver = requireEngineDriver(connection);
|
||||
const authUrl = await driver.getRedirectAuthUrl(connection, {
|
||||
const authResp = await driver.getRedirectAuthUrl(connection, {
|
||||
redirectUri,
|
||||
state,
|
||||
client: 'web',
|
||||
});
|
||||
res.redirect(authUrl);
|
||||
res.redirect(authResp.url);
|
||||
},
|
||||
|
||||
dbloginApp_meta: true,
|
||||
async dbloginApp({ conid, state }) {
|
||||
const connection = await this.getCore({ conid });
|
||||
const driver = requireEngineDriver(connection);
|
||||
const url = await driver.getRedirectAuthUrl(connection, {
|
||||
const resp = await driver.getRedirectAuthUrl(connection, {
|
||||
state,
|
||||
client: 'app',
|
||||
});
|
||||
return { url };
|
||||
startTokenChecking(resp.sid, async token => {
|
||||
const volatile = await this.saveVolatile({ conid, accessToken: token });
|
||||
socket.emit('got-volatile-token', { savedConId: conid, volatileConId: volatile._id });
|
||||
});
|
||||
return resp;
|
||||
},
|
||||
|
||||
dbloginToken_meta: true,
|
||||
|
||||
@@ -10,8 +10,11 @@ async function authProxyGetTokenFromCode(options) {
|
||||
return null;
|
||||
}
|
||||
|
||||
function startTokenChecking(sid, callback) {}
|
||||
|
||||
module.exports = {
|
||||
isAuthProxySupported,
|
||||
authProxyGetRedirectUrl,
|
||||
authProxyGetTokenFromCode,
|
||||
startTokenChecking,
|
||||
};
|
||||
|
||||
2
packages/types/engines.d.ts
vendored
2
packages/types/engines.d.ts
vendored
@@ -149,7 +149,7 @@ export interface EngineDriver {
|
||||
summaryCommand(pool, command, row): Promise<void>;
|
||||
startProfiler(pool, options): Promise<any>;
|
||||
stopProfiler(pool, profiler): Promise<void>;
|
||||
getRedirectAuthUrl(connection, options): Promise<string>;
|
||||
getRedirectAuthUrl(connection, options): Promise<{ url: string; sid: string }>;
|
||||
getAuthTokenFromCode(connection, options): Promise<string>;
|
||||
getAccessTokenFromAuth(connection, req): Promise<string | null>;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user