auth: Move social login process to browser.

Moves the social login to browser since there
was no way to verify the authencity of the
auth process for a custom server and to
prevent phishing attacks.

Fixes #849.

Co-authored-by: Kanishk Kakar <kanishk.kakar@gmail.com>
This commit is contained in:
ViPuL
2020-02-25 20:05:27 +05:30
committed by GitHub
parent 0fb610f858
commit 49b29bfed6
10 changed files with 174 additions and 30 deletions

View File

@@ -21,6 +21,7 @@ import ReconnectUtil = require('./utils/reconnect-util');
import Logger = require('./utils/logger-util');
import CommonUtil = require('./utils/common-util');
import EnterpriseUtil = require('./utils/enterprise-util');
import AuthUtil = require('./utils/auth-util');
import Messages = require('./../../resources/messages');
interface FunctionalTabProps {
@@ -47,6 +48,7 @@ interface SettingsOptions {
autoUpdate: boolean;
betaUpdate: boolean;
errorReporting: boolean;
loginInApp: boolean;
customCSS: boolean;
silent: boolean;
lastActiveTab: number;
@@ -199,6 +201,7 @@ class ServerManagerView {
autoUpdate: true,
betaUpdate: false,
errorReporting: true,
loginInApp: false,
customCSS: false,
silent: false,
lastActiveTab: 0,
@@ -808,6 +811,30 @@ class ServerManagerView {
});
}
ipcRenderer.on('deep-linking-url', (event: Event, url: string) => {
if (!ConfigUtil.getConfigItem('desktopOtp')) {
return;
}
const urlObject = new URL(decodeURIComponent(url));
const serverURL = urlObject.searchParams.get('realm');
let apiKey = urlObject.searchParams.get('otp_encrypted_login_key');
const desktopOtp = ConfigUtil.getConfigItem('desktopOtp');
apiKey = AuthUtil.hexToAscii(AuthUtil.xorStrings(apiKey, desktopOtp));
// Use this apiKey to login the realm if it exists
if (apiKey === '') {
console.log('Invalid API Key');
} else {
DomainUtil.getDomains().forEach((domain: any, index: number) => {
if (domain.url.includes(serverURL)) {
this.activateTab(index);
this.tabs[index].webview.loadURL(`${serverURL}/accounts/login/subdomain/${apiKey}`);
}
});
ConfigUtil.setConfigItem('desktopOtp', null);
}
});
ipcRenderer.on('show-network-error', (event: Event, index: number) => {
this.openNetworkTroubleshooting(index);
});