mirror of
https://github.com/dbgate/dbgate
synced 2024-11-07 20:26:23 +00:00
electron auth proxy WIP
This commit is contained in:
parent
ddf385caac
commit
83ce5710ae
@ -37,7 +37,8 @@ function authMiddleware(req, res, next) {
|
|||||||
'/stream',
|
'/stream',
|
||||||
'storage/get-connections-for-login-page',
|
'storage/get-connections-for-login-page',
|
||||||
'auth/get-providers',
|
'auth/get-providers',
|
||||||
'/connections/dblogin',
|
'/connections/dblogin-web',
|
||||||
|
'/connections/dblogin-app',
|
||||||
'/connections/dblogin-auth',
|
'/connections/dblogin-auth',
|
||||||
'/connections/dblogin-auth-token',
|
'/connections/dblogin-auth-token',
|
||||||
];
|
];
|
||||||
|
@ -386,18 +386,33 @@ module.exports = {
|
|||||||
return res;
|
return res;
|
||||||
},
|
},
|
||||||
|
|
||||||
dblogin_meta: {
|
dbloginWeb_meta: {
|
||||||
raw: true,
|
raw: true,
|
||||||
method: 'get',
|
method: 'get',
|
||||||
},
|
},
|
||||||
async dblogin(req, res) {
|
async dbloginWeb(req, res) {
|
||||||
const { conid, state, redirectUri } = req.query;
|
const { conid, state, redirectUri } = req.query;
|
||||||
const connection = await this.getCore({ conid });
|
const connection = await this.getCore({ conid });
|
||||||
const driver = requireEngineDriver(connection);
|
const driver = requireEngineDriver(connection);
|
||||||
const authUrl = await driver.getRedirectAuthUrl(connection, { redirectUri, state });
|
const authUrl = await driver.getRedirectAuthUrl(connection, {
|
||||||
|
redirectUri,
|
||||||
|
state,
|
||||||
|
client: 'web',
|
||||||
|
});
|
||||||
res.redirect(authUrl);
|
res.redirect(authUrl);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
dbloginApp_meta: true,
|
||||||
|
async dbloginApp({ conid, state }) {
|
||||||
|
const connection = await this.getCore({ conid });
|
||||||
|
const driver = requireEngineDriver(connection);
|
||||||
|
const url = await driver.getRedirectAuthUrl(connection, {
|
||||||
|
state,
|
||||||
|
client: 'app',
|
||||||
|
});
|
||||||
|
return { url };
|
||||||
|
},
|
||||||
|
|
||||||
dbloginToken_meta: true,
|
dbloginToken_meta: true,
|
||||||
async dbloginToken({ code, conid, strmid, redirectUri, sid }) {
|
async dbloginToken({ code, conid, strmid, redirectUri, sid }) {
|
||||||
try {
|
try {
|
||||||
|
@ -97,11 +97,19 @@ async function processApiResponse(route, args, resp) {
|
|||||||
|
|
||||||
const state = `dbg-dblogin:${strmid}:${resp.detail.conid}`;
|
const state = `dbg-dblogin:${strmid}:${resp.detail.conid}`;
|
||||||
localStorage.setItem('dbloginState', state);
|
localStorage.setItem('dbloginState', state);
|
||||||
openWebLink(
|
if (getElectron()) {
|
||||||
`connections/dblogin?conid=${resp.detail.conid}&state=${encodeURIComponent(state)}&redirectUri=${
|
const dbloginApp = await apiCall('connections/dblogin-app', {
|
||||||
location.origin + location.pathname
|
conid: resp.detail.conid,
|
||||||
}`
|
state,
|
||||||
);
|
});
|
||||||
|
openWebLink(dbloginApp.url);
|
||||||
|
} else {
|
||||||
|
openWebLink(
|
||||||
|
`connections/dblogin-web?conid=${resp.detail.conid}&state=${encodeURIComponent(state)}&redirectUri=${
|
||||||
|
location.origin + location.pathname
|
||||||
|
}`
|
||||||
|
);
|
||||||
|
}
|
||||||
} else if (!isDatabaseLoginVisible()) {
|
} else if (!isDatabaseLoginVisible()) {
|
||||||
showModal(DatabaseLoginModal, resp.detail);
|
showModal(DatabaseLoginModal, resp.detail);
|
||||||
}
|
}
|
||||||
|
@ -141,7 +141,6 @@ const driver = {
|
|||||||
if (connection.authType != 'msentra') return null;
|
if (connection.authType != 'msentra') return null;
|
||||||
return authProxy.authProxyGetRedirectUrl({
|
return authProxy.authProxyGetRedirectUrl({
|
||||||
...options,
|
...options,
|
||||||
client: platformInfo.isElectron ? 'app' : 'web',
|
|
||||||
type: 'msentra',
|
type: 'msentra',
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user