From 58b597591296f5b2567ca13131a9a467e879a09b Mon Sep 17 00:00:00 2001 From: Ramiro Saenz Date: Thu, 8 Oct 2020 18:04:23 -0300 Subject: [PATCH] Added new Google URLs to avoid security rule Fixes #2835 --- app/Application.js | 10 ++++++++++ app/ux/Auth0.js | 4 +--- app/ux/WebView.js | 5 ++--- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/app/Application.js b/app/Application.js index a47452d6..bb50f913 100644 --- a/app/Application.js +++ b/app/Application.js @@ -23,7 +23,9 @@ Ext.define('Rambox.Application', { ,config: { totalServicesLoaded: 0 ,totalNotifications: 0 + ,googleURLs: [] } + ,launch: function () { const isOnline = require('is-online'); @@ -165,6 +167,14 @@ Ext.define('Rambox.Application', { // Check for updates if ( require('electron').remote.process.argv.indexOf('--without-update') === -1 ) Rambox.app.checkUpdate(true); + // Get Google URLs + Ext.Ajax.request({ + url: 'https://raw.githubusercontent.com/ramboxapp/community-edition/gh-pages/api/google.json' + ,method: 'GET' + ,success: function(response) { + Rambox.app.config.googleURLs = Ext.decode(response.responseText); + } + }); // Shortcuts const platform = require('electron').remote.process.platform; diff --git a/app/ux/Auth0.js b/app/ux/Auth0.js index 29360ad1..6d771b37 100644 --- a/app/ux/Auth0.js +++ b/app/ux/Auth0.js @@ -273,9 +273,7 @@ Ext.define('Rambox.ux.Auth0', { authWindow.webContents.on('did-start-loading', function(e) { authWindow.webContents.session.webRequest.onBeforeSendHeaders((details, callback) => { - let googleLoginURLs = ['accounts.google.com/signin/oauth', 'accounts.google.com/ServiceLogin', 'accounts.google.com/_/lookup/accountlookup'] - - googleLoginURLs.forEach((loginURL) => { + Rambox.app.config.googleURLs.forEach((loginURL) => { if ( details.url.indexOf(loginURL) > -1 ) details.requestHeaders['User-Agent'] = 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:70.0) Gecko/20100101 Firefox/70.0' }) callback({ cancel: false, requestHeaders: details.requestHeaders }); }); diff --git a/app/ux/WebView.js b/app/ux/WebView.js index c7229bf8..3fbd5475 100644 --- a/app/ux/WebView.js +++ b/app/ux/WebView.js @@ -276,7 +276,6 @@ Ext.define('Rambox.ux.WebView',{ if ( !me.record.get('enabled') ) return; var webview = me.getWebView(); - let googleLoginURLs = ['accounts.google.com/signin', 'accounts.google.com/ServiceLogin', 'accounts.google.com/_/lookup/accountlookup'] me.errorCodeLog = [] // Google Analytics Event @@ -290,7 +289,7 @@ Ext.define('Rambox.ux.WebView',{ console.info('Start loading...', me.src); webview.getWebContents().session.webRequest.onBeforeSendHeaders((details, callback) => { - googleLoginURLs.forEach((loginURL) => { if ( details.url.indexOf(loginURL) > -1 ) details.requestHeaders['User-Agent'] = 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:70.0) Gecko/20100101 Firefox/70.0'}) + Rambox.app.config.googleURLs.forEach((loginURL) => { if ( details.url.indexOf(loginURL) > -1 ) details.requestHeaders['User-Agent'] = 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:70.0) Gecko/20100101 Firefox/70.0'}) callback({ cancel: false, requestHeaders: details.requestHeaders }); }); @@ -600,7 +599,7 @@ Ext.define('Rambox.ux.WebView',{ }) eventsOnDom = true; - googleLoginURLs.forEach((loginURL) => { if ( webview.getURL().indexOf(loginURL) > -1 ) webview.reload() }) + Rambox.app.config.googleURLs.forEach((loginURL) => { if ( webview.getURL().indexOf(loginURL) > -1 ) webview.reload() }) } webview.executeJavaScript(js_inject).then(result => {} ).catch(err => { console.log(err) }) });