azure auth WIP

This commit is contained in:
Jan Prochazka
2024-08-02 14:32:28 +02:00
parent f777530b1c
commit fc448ed578
10 changed files with 91 additions and 20 deletions

View File

@@ -16,6 +16,7 @@ const { safeJsonParse, getLogger } = require('dbgate-tools');
const platformInfo = require('../utility/platformInfo');
const { connectionHasPermission, testConnectionPermission } = require('../utility/hasPermission');
const pipeForkLogs = require('../utility/pipeForkLogs');
const requireEngineDriver = require('../utility/requireEngineDriver');
const logger = getLogger('connections');
@@ -345,7 +346,7 @@ module.exports = {
const storage = require('./storage');
const storageConnection = await storage.getConnection({conid});
const storageConnection = await storage.getConnection({ conid });
if (storageConnection) {
return storageConnection;
}
@@ -379,4 +380,16 @@ module.exports = {
});
return res;
},
dblogin_meta: {
raw: true,
method: 'get',
},
async dblogin(req, res) {
const { conid } = req.query;
const connection = await this.getCore({ conid });
const driver = requireEngineDriver(connection);
const authUrl = driver.getRedirectAuthUrl(connection);
res.redirect(authUrl);
},
};

View File

@@ -89,6 +89,9 @@ module.exports = {
if (connection.passwordMode == 'askPassword' || connection.passwordMode == 'askUser') {
throw new MissingCredentialsError({ conid, passwordMode: connection.passwordMode });
}
if (connection.useRedirectDbLogin) {
throw new MissingCredentialsError({ conid, redirectToDbLogin: true });
}
const subprocess = fork(
global['API_PACKAGE'] || process.argv[1],
[