mirror of
				https://github.com/zulip/zulip-desktop.git
				synced 2025-10-31 12:03:39 +00:00 
			
		
		
		
	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:
		| @@ -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); | ||||
| 		}); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user