Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Prochazka committed Aug 13, 2024
1 parent 838bc34 commit 42a79b2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
25 changes: 13 additions & 12 deletions packages/web/src/clientAuth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 49,7 @@ export function handleOauthCallback() {
code: sentCode,
amoid,
redirectUri: location.origin location.pathname,
sid,
}).then(authResp => {
const { accessToken, error, errorMessage } = authResp;

Expand Down Expand Up @@ -164,18 165,18 @@ export async function redirectToLogin(config = null, force = false) {
return;
}

if (config.oauth) {
const state = `dbg-oauth:${Math.random().toString().substr(2)}`;
const scopeParam = config.oauthScope ? `&scope=${config.oauthScope}` : '';
sessionStorage.setItem('oauthState', state);
console.log('Redirecting to OAUTH provider');
location.replace(
`${config.oauth}?client_id=${config.oauthClient}&response_type=code&redirect_uri=${encodeURIComponent(
location.origin location.pathname
)}&state=${encodeURIComponent(state)}${scopeParam}`
);
return;
}
// if (config.oauth) {
// const state = `dbg-oauth:${Math.random().toString().substr(2)}`;
// const scopeParam = config.oauthScope ? `&scope=${config.oauthScope}` : '';
// sessionStorage.setItem('oauthState', state);
// console.log('Redirecting to OAUTH provider');
// location.replace(
// `${config.oauth}?client_id=${config.oauthClient}&response_type=code&redirect_uri=${encodeURIComponent(
// location.origin location.pathname
// )}&state=${encodeURIComponent(state)}${scopeParam}`
// );
// return;
// }
}

export function internalRedirectTo(path) {
Expand Down
3 changes: 2 additions & 1 deletion plugins/dbgate-plugin-mssql/src/backend/driver.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 141,7 @@ const driver = {
if (connection.authType != 'msentra') return null;
return authProxy.authProxyGetRedirectUrl({
...options,
client: platformInfo.isElectron ? 'app' : 'web',
type: 'msentra',
});
},
Expand All @@ -157,7 158,7 @@ driver.initialize = dbgateEnv => {
requireMsnodesqlv8 = dbgateEnv.nativeModules.msnodesqlv8;
}
platformInfo = dbgateEnv.platformInfo;
azureAuth = dbgateEnv.azureAuth;
authProxy = dbgateEnv.authProxy;
nativeDriver.initialize(dbgateEnv);
};

Expand Down

0 comments on commit 42a79b2

Please sign in to comment.