mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-29 19:13:59 +00:00
azure auth moved to auth proxy
This commit is contained in:
@@ -17,7 +17,6 @@
|
||||
"dbgate"
|
||||
],
|
||||
"dependencies": {
|
||||
"@azure/msal-node": "^2.12.0",
|
||||
"activedirectory2": "^2.1.0",
|
||||
"async-lock": "^1.2.4",
|
||||
"axios": "^0.21.1",
|
||||
|
||||
@@ -399,11 +399,11 @@ module.exports = {
|
||||
},
|
||||
|
||||
dbloginToken_meta: true,
|
||||
async dbloginToken({ code, conid, strmid, redirectUri }) {
|
||||
async dbloginToken({ code, conid, strmid, redirectUri, sid }) {
|
||||
try {
|
||||
const connection = await this.getCore({ conid });
|
||||
const driver = requireEngineDriver(connection);
|
||||
const accessToken = await driver.getAuthTokenFromCode(connection, { code, redirectUri });
|
||||
const accessToken = await driver.getAuthTokenFromCode(connection, { sid, code, redirectUri });
|
||||
const volatile = await this.saveVolatile({ conid, accessToken });
|
||||
// console.log('******************************** WE HAVE ACCESS TOKEN', accessToken);
|
||||
socket.emit('got-volatile-token', { strmid, savedConId: conid, volatileConId: volatile._id });
|
||||
@@ -415,11 +415,11 @@ module.exports = {
|
||||
},
|
||||
|
||||
dbloginAuthToken_meta: true,
|
||||
async dbloginAuthToken({ amoid, code, conid, redirectUri }) {
|
||||
async dbloginAuthToken({ amoid, code, conid, redirectUri, sid }) {
|
||||
try {
|
||||
const connection = await this.getCore({ conid });
|
||||
const driver = requireEngineDriver(connection);
|
||||
const accessToken = await driver.getAuthTokenFromCode(connection, { code, redirectUri });
|
||||
const accessToken = await driver.getAuthTokenFromCode(connection, { code, redirectUri, sid });
|
||||
const volatile = await this.saveVolatile({ conid, accessToken });
|
||||
const authProvider = getAuthProviderById(amoid);
|
||||
const resp = await authProvider.login(null, null, { conid: volatile._id });
|
||||
|
||||
@@ -3,7 +3,7 @@ const fs = require('fs');
|
||||
const { pluginsdir, packagedPluginsDir, getPluginBackendPath } = require('../utility/directories');
|
||||
const nativeModules = require('../nativeModules');
|
||||
const platformInfo = require('../utility/platformInfo');
|
||||
const azureAuth = require('../utility/azureAuth');
|
||||
const authProxy = require('../utility/authProxy');
|
||||
const { getLogger } = require('dbgate-tools');
|
||||
const logger = getLogger('requirePlugin');
|
||||
|
||||
@@ -13,7 +13,7 @@ const dbgateEnv = {
|
||||
dbgateApi: null,
|
||||
nativeModules,
|
||||
platformInfo,
|
||||
azureAuth,
|
||||
authProxy,
|
||||
};
|
||||
function requirePlugin(packageName, requiredPlugin = null) {
|
||||
if (!packageName) throw new Error('Missing packageName in plugin');
|
||||
|
||||
17
packages/api/src/utility/authProxy.js
Normal file
17
packages/api/src/utility/authProxy.js
Normal file
@@ -0,0 +1,17 @@
|
||||
function isAuthProxySupported() {
|
||||
return false;
|
||||
}
|
||||
|
||||
async function authProxyGetRedirectUrl(options) {
|
||||
return null;
|
||||
}
|
||||
|
||||
async function authProxyGetTokenFromCode(options) {
|
||||
return null;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
isAuthProxySupported,
|
||||
authProxyGetRedirectUrl,
|
||||
authProxyGetTokenFromCode,
|
||||
};
|
||||
@@ -1,17 +0,0 @@
|
||||
function isAzureAuthSupported() {
|
||||
return false;
|
||||
}
|
||||
|
||||
async function azureGetRedirectAuthUrl(options) {
|
||||
return null;
|
||||
}
|
||||
|
||||
async function azureGetAuthTokenFromCode(options) {
|
||||
return null;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
isAzureAuthSupported,
|
||||
azureGetRedirectAuthUrl,
|
||||
azureGetAuthTokenFromCode,
|
||||
};
|
||||
@@ -39,6 +39,7 @@ export function isDbLoginAuthCallback() {
|
||||
export function handleOauthCallback() {
|
||||
const params = new URLSearchParams(location.search);
|
||||
const sentCode = params.get('code');
|
||||
const sid = params.get('sid');
|
||||
|
||||
if (isOauthCallback()) {
|
||||
const [_prefix, strmid, amoid] = sessionStorage.getItem('oauthState').split(':');
|
||||
@@ -72,6 +73,7 @@ export function handleOauthCallback() {
|
||||
code: sentCode,
|
||||
conid,
|
||||
strmid,
|
||||
sid,
|
||||
redirectUri: location.origin + location.pathname,
|
||||
}).then(authResp => {
|
||||
if (authResp.success) {
|
||||
@@ -95,6 +97,7 @@ export function handleOauthCallback() {
|
||||
conid,
|
||||
redirectUri: location.origin + location.pathname,
|
||||
amoid,
|
||||
sid,
|
||||
}).then(authResp => {
|
||||
if (authResp.accessToken) {
|
||||
localStorage.setItem('accessToken', authResp.accessToken);
|
||||
|
||||
Reference in New Issue
Block a user