mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-29 04:06:00 +00:00
cloud login WIP
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
DEVMODE=1
|
||||
SHELL_SCRIPTING=1
|
||||
# LOCAL_DBGATE_IDENTITY=1
|
||||
|
||||
# CLOUD_UPGRADE_FILE=c:\test\upg\upgrade.zip
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ const {
|
||||
} = require('../auth/authProvider');
|
||||
const storage = require('./storage');
|
||||
const { decryptPasswordString } = require('../utility/crypting');
|
||||
const { createDbGateIdentitySession, getIdentitySigninUrl } = require('../utility/cloudIntf');
|
||||
|
||||
const logger = getLogger('auth');
|
||||
|
||||
@@ -135,5 +136,13 @@ module.exports = {
|
||||
return getAuthProviderById(amoid).redirect(params);
|
||||
},
|
||||
|
||||
createCloudLoginSession_meta: true,
|
||||
async createCloudLoginSession({ client }) {
|
||||
const sid = await createDbGateIdentitySession(client);
|
||||
return {
|
||||
url: getIdentitySigninUrl(sid),
|
||||
};
|
||||
},
|
||||
|
||||
authMiddleware,
|
||||
};
|
||||
|
||||
@@ -36,6 +36,14 @@ async function callRefactorSqlQueryApi(query, task, structure, dialect) {
|
||||
return null;
|
||||
}
|
||||
|
||||
function getExternalParamsWithLicense() {
|
||||
return {
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
isAuthProxySupported,
|
||||
authProxyGetRedirectUrl,
|
||||
@@ -47,4 +55,5 @@ module.exports = {
|
||||
callTextToSqlApi,
|
||||
callCompleteOnCursorApi,
|
||||
callRefactorSqlQueryApi,
|
||||
getExternalParamsWithLicense,
|
||||
};
|
||||
|
||||
34
packages/api/src/utility/cloudIntf.js
Normal file
34
packages/api/src/utility/cloudIntf.js
Normal file
@@ -0,0 +1,34 @@
|
||||
const axios = require('axios');
|
||||
const { getExternalParamsWithLicense } = require('./authProxy');
|
||||
|
||||
const DBGATE_IDENTITY_URL = process.env.LOCAL_DBGATE_IDENTITY
|
||||
? 'http://localhost:3001'
|
||||
: process.env.DEVWEB || process.env.DEVMODE
|
||||
? 'https://identity.dbgate.udolni.net'
|
||||
: 'https://identity.dbgate.io';
|
||||
|
||||
const DBGATE_CLOUD_URL = process.env.LOCAL_DBGATE_CLOUD
|
||||
? 'http://localhost:3109'
|
||||
: process.env.DEVWEB || process.env.DEVMODE
|
||||
? 'https://cloud.dbgate.udolni.net'
|
||||
: 'https://cloud.dbgate.io';
|
||||
|
||||
async function createDbGateIdentitySession(client) {
|
||||
const resp = await axios.default.post(
|
||||
`${DBGATE_IDENTITY_URL}/api/create-session`,
|
||||
{
|
||||
client,
|
||||
},
|
||||
getExternalParamsWithLicense()
|
||||
);
|
||||
return resp.data.sid;
|
||||
}
|
||||
|
||||
function getIdentitySigninUrl(sid) {
|
||||
return `${DBGATE_IDENTITY_URL}/signin/${sid}`;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
createDbGateIdentitySession,
|
||||
getIdentitySigninUrl,
|
||||
};
|
||||
@@ -112,6 +112,9 @@
|
||||
'icon square': 'mdi mdi-square',
|
||||
'icon data-deploy': 'mdi mdi-database-settings',
|
||||
|
||||
'icon cloud-account': 'mdi mdi-account-remove-outline',
|
||||
'icon cloud-account-connected': 'mdi mdi-account-check-outline',
|
||||
|
||||
'icon edit': 'mdi mdi-pencil',
|
||||
'icon delete': 'mdi mdi-delete',
|
||||
'icon arrow-up': 'mdi mdi-arrow-up',
|
||||
|
||||
@@ -13,6 +13,9 @@
|
||||
import mainMenuDefinition from '../../../../app/src/mainMenuDefinition';
|
||||
import hasPermission from '../utility/hasPermission';
|
||||
import { isProApp } from '../utility/proTools';
|
||||
import { openWebLink } from '../utility/simpleTools';
|
||||
import { apiCall } from '../utility/api';
|
||||
import getElectron from '../utility/getElectron';
|
||||
|
||||
let domSettings;
|
||||
let domMainMenu;
|
||||
@@ -103,6 +106,11 @@
|
||||
const items = mainMenuDefinition({ editMenu: false });
|
||||
currentDropDownMenu.set({ left, top, items });
|
||||
}
|
||||
|
||||
async function handleOpenCloudLogin() {
|
||||
const { url, sid } = await apiCall('auth/create-cloud-login-session', { client: getElectron() ? 'app' : 'web' });
|
||||
openWebLink(url);
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="main">
|
||||
@@ -129,7 +137,7 @@
|
||||
|
||||
<div class="flex1"> </div>
|
||||
|
||||
<div
|
||||
<!-- <div
|
||||
class="wrapper"
|
||||
title={`Toggle whether tabs from all databases are visible. Currently - ${$lockedDatabaseMode ? 'NO' : 'YES'}`}
|
||||
on:click={() => {
|
||||
@@ -138,6 +146,10 @@
|
||||
data-testid="WidgetIconPanel_lockDb"
|
||||
>
|
||||
<FontIcon icon={$lockedDatabaseMode ? 'icon locked-database-mode' : 'icon unlocked-database-mode'} />
|
||||
</div> -->
|
||||
|
||||
<div class="wrapper" on:click={handleOpenCloudLogin} data-testid="WidgetIconPanel_cloudAccount">
|
||||
<FontIcon icon="icon cloud-account" />
|
||||
</div>
|
||||
|
||||
<div class="wrapper" on:click={handleSettingsMenu} bind:this={domSettings} data-testid="WidgetIconPanel_settings">
|
||||
|
||||
Reference in New Issue
Block a user