Browse Source

Added new Google URLs to avoid security rule

Fixes #2835
pull/2897/head
Ramiro Saenz 5 years ago
parent
commit
58b5975912
  1. 10
      app/Application.js
  2. 4
      app/ux/Auth0.js
  3. 5
      app/ux/WebView.js

10
app/Application.js

@ -23,7 +23,9 @@ Ext.define('Rambox.Application', {
,config: { ,config: {
totalServicesLoaded: 0 totalServicesLoaded: 0
,totalNotifications: 0 ,totalNotifications: 0
,googleURLs: []
} }
,launch: function () { ,launch: function () {
const isOnline = require('is-online'); const isOnline = require('is-online');
@ -165,6 +167,14 @@ Ext.define('Rambox.Application', {
// Check for updates // Check for updates
if ( require('electron').remote.process.argv.indexOf('--without-update') === -1 ) Rambox.app.checkUpdate(true); 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 // Shortcuts
const platform = require('electron').remote.process.platform; const platform = require('electron').remote.process.platform;

4
app/ux/Auth0.js

@ -273,9 +273,7 @@ Ext.define('Rambox.ux.Auth0', {
authWindow.webContents.on('did-start-loading', function(e) { authWindow.webContents.on('did-start-loading', function(e) {
authWindow.webContents.session.webRequest.onBeforeSendHeaders((details, callback) => { authWindow.webContents.session.webRequest.onBeforeSendHeaders((details, callback) => {
let googleLoginURLs = ['accounts.google.com/signin/oauth', 'accounts.google.com/ServiceLogin', 'accounts.google.com/_/lookup/accountlookup'] Rambox.app.config.googleURLs.forEach((loginURL) => {
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' }) 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 }); callback({ cancel: false, requestHeaders: details.requestHeaders });
}); });

5
app/ux/WebView.js

@ -276,7 +276,6 @@ Ext.define('Rambox.ux.WebView',{
if ( !me.record.get('enabled') ) return; if ( !me.record.get('enabled') ) return;
var webview = me.getWebView(); var webview = me.getWebView();
let googleLoginURLs = ['accounts.google.com/signin', 'accounts.google.com/ServiceLogin', 'accounts.google.com/_/lookup/accountlookup']
me.errorCodeLog = [] me.errorCodeLog = []
// Google Analytics Event // Google Analytics Event
@ -290,7 +289,7 @@ Ext.define('Rambox.ux.WebView',{
console.info('Start loading...', me.src); console.info('Start loading...', me.src);
webview.getWebContents().session.webRequest.onBeforeSendHeaders((details, callback) => { 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 }); callback({ cancel: false, requestHeaders: details.requestHeaders });
}); });
@ -600,7 +599,7 @@ Ext.define('Rambox.ux.WebView',{
}) })
eventsOnDom = true; 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) }) webview.executeJavaScript(js_inject).then(result => {} ).catch(err => { console.log(err) })
}); });

Loading…
Cancel
Save