mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-29 11:03:57 +00:00
azure auth WIP
This commit is contained in:
@@ -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);
|
||||
},
|
||||
};
|
||||
|
||||
@@ -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],
|
||||
[
|
||||
|
||||
1
packages/types/engines.d.ts
vendored
1
packages/types/engines.d.ts
vendored
@@ -149,6 +149,7 @@ export interface EngineDriver {
|
||||
summaryCommand(pool, command, row): Promise<void>;
|
||||
startProfiler(pool, options): Promise<any>;
|
||||
stopProfiler(pool, profiler): Promise<void>;
|
||||
getRedirectAuthUrl(connection): Promise<string>;
|
||||
|
||||
analyserClass?: any;
|
||||
dumperClass?: any;
|
||||
|
||||
@@ -31,7 +31,8 @@
|
||||
|
||||
$: showConnectionFieldArgs = { config: $config };
|
||||
|
||||
$: showUser = driver?.showConnectionField('user', $values, showConnectionFieldArgs) && $values.passwordMode != 'askUser';
|
||||
$: showUser =
|
||||
driver?.showConnectionField('user', $values, showConnectionFieldArgs) && $values.passwordMode != 'askUser';
|
||||
$: showPassword =
|
||||
driver?.showConnectionField('password', $values, showConnectionFieldArgs) &&
|
||||
$values.passwordMode != 'askPassword' &&
|
||||
@@ -83,17 +84,19 @@
|
||||
{/if}
|
||||
|
||||
{#if $authTypes && driver?.showConnectionField('authType', $values, showConnectionFieldArgs)}
|
||||
<FormSelectField
|
||||
label={driver?.authTypeLabel ?? 'Authentication'}
|
||||
name="authType"
|
||||
isNative
|
||||
disabled={isConnected}
|
||||
defaultValue={driver?.defaultAuthTypeName}
|
||||
options={$authTypes.map(auth => ({
|
||||
value: auth.name,
|
||||
label: auth.title,
|
||||
}))}
|
||||
/>
|
||||
{#key $authTypes}
|
||||
<FormSelectField
|
||||
label={driver?.authTypeLabel ?? 'Authentication'}
|
||||
name="authType"
|
||||
isNative
|
||||
disabled={isConnected}
|
||||
defaultValue={driver?.defaultAuthTypeName}
|
||||
options={$authTypes.map(auth => ({
|
||||
value: auth.name,
|
||||
label: auth.title,
|
||||
}))}
|
||||
/>
|
||||
{/key}
|
||||
{/if}
|
||||
|
||||
{#if driver?.showConnectionField('clientLibraryPath', $values, showConnectionFieldArgs)}
|
||||
|
||||
@@ -9,6 +9,7 @@ import { showModal } from '../modals/modalTools';
|
||||
import DatabaseLoginModal, { isDatabaseLoginVisible } from '../modals/DatabaseLoginModal.svelte';
|
||||
import _ from 'lodash';
|
||||
import uuidv1 from 'uuid/v1';
|
||||
import { openWebLink } from './exportFileTools';
|
||||
|
||||
export const strmid = uuidv1();
|
||||
|
||||
@@ -63,7 +64,9 @@ function processApiResponse(route, args, resp) {
|
||||
// }
|
||||
|
||||
if (resp?.missingCredentials) {
|
||||
if (!isDatabaseLoginVisible()) {
|
||||
if (resp.detail.redirectToDbLogin) {
|
||||
openWebLink('connections/dblogin');
|
||||
} else if (!isDatabaseLoginVisible()) {
|
||||
showModal(DatabaseLoginModal, resp.detail);
|
||||
}
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user