This repository has been archived by the owner on Jun 4, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 278
disable nodeintegration #453
Merged
Merged
Changes from 9 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
5fff066
app: prevent new windows out of initial origin
n-riesco 90e5f7d
app: replace 'new-window` with shell.openExternal
n-riesco dbd1e82
Settings: silence uncaught promise
n-riesco 8b16fc0
routes: fix URL to csv file returned by /datacache
n-riesco 9778cac
Link: don't use shell.openExternal
n-riesco ea0ffa7
Login: don't use shell.openExternal
n-riesco 6100bba
Login: remove build-time global variables
n-riesco f362921
oauth: fix authorisation in the web app
n-riesco ce0be62
app: disable nodeIntegration
n-riesco 2e09698
Query: enable query panel for non-sql connectors
n-riesco 2344f2c
electron-builder: force dtrace-provider rebuild
n-riesco f35bbca
doc: fix link
n-riesco 0ee49a2
oauth2: rename cookie
n-riesco File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,5 @@ | ||
import R from 'ramda'; | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import {dynamicRequireElectron} from '../utils/utils'; | ||
|
||
|
||
let shell; | ||
try { | ||
shell = dynamicRequireElectron().shell; | ||
} catch (e) { | ||
shell = null; | ||
} | ||
|
||
export function Link(props) { | ||
const {href} = props; | ||
if (shell) { | ||
return ( | ||
<span | ||
className={`${props.className}`} | ||
onClick={() => {shell.openExternal(href);}} | ||
{...R.omit(['className'], props)} | ||
/> | ||
); | ||
} | ||
return <a href={href} target="_blank" {...props}/>; | ||
return <a target="_blank" rel="noopener" {...props}/>; | ||
} | ||
|
||
Link.propTypes = { | ||
href: PropTypes.string, | ||
className: PropTypes.string | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,6 @@ import React, {Component} from 'react'; | |
import {connect} from 'react-redux'; | ||
import { | ||
baseUrl, | ||
dynamicRequireElectron, | ||
homeUrl, | ||
isOnPrem, | ||
plotlyUrl | ||
|
@@ -21,35 +20,12 @@ const CLOUD = 'cloud'; | |
const ONPREM = 'onprem'; | ||
|
||
window.document.title = `${build.productName} v${version}`; | ||
let usernameLogged = ''; | ||
|
||
// http://stackoverflow.com/questions/4068373/center-a-popup-window-on-screen | ||
const PopupCenter = (url, title, w, h) => { | ||
// Fixes dual-screen position | ||
const dualScreenLeft = 'screenLeft' in window ? window.screenLeft : screen.left; | ||
const dualScreenTop = 'screenTop' in window ? window.screenTop : screen.top; | ||
|
||
const width = window.innerWidth | ||
? window.innerWidth | ||
: document.documentElement.clientWidth | ||
? document.documentElement.clientWidth | ||
: screen.width; | ||
const height = window.innerHeight | ||
? window.innerHeight | ||
: document.documentElement.clientHeight | ||
? document.documentElement.clientHeight | ||
: screen.height; | ||
|
||
const left = ((width / 2) - (w / 2)) + dualScreenLeft; | ||
const top = ((height / 2) - (h / 2)) + dualScreenTop; | ||
const popupWindow = window.open(url, title, `scrollbars=yes, width=${w}, height=${h}, top=${top}, left=${left}`); | ||
return popupWindow; | ||
}; | ||
|
||
class Login extends Component { | ||
constructor(props) { | ||
super(props); | ||
this.state = { | ||
clientId: cookie.load('db-connector-client-id'), | ||
domain: (isOnPrem() ? plotlyUrl() : 'https://plot.ly'), | ||
statusMessage: '', | ||
serverType: CLOUD, | ||
|
@@ -58,6 +34,11 @@ class Login extends Component { | |
this.buildOauthUrl = this.buildOauthUrl.bind(this); | ||
this.oauthPopUp = this.oauthPopUp.bind(this); | ||
this.logIn = this.logIn.bind(this); | ||
|
||
// the web app: | ||
// - sets this property to the popup window opened for authorization | ||
// - and triggers a reload when `this.popup.closed` becomes true | ||
this.popup = null; | ||
} | ||
|
||
componentDidMount() { | ||
|
@@ -69,8 +50,7 @@ class Login extends Component { | |
* to check for authentication. | ||
*/ | ||
setInterval(() => { | ||
usernameLogged = cookie.load('db-connector-user'); | ||
if (usernameLogged) { | ||
if (this.popup && this.popup.closed) { | ||
if (serverType === ONPREM) { | ||
this.setState({ | ||
status: 'authorized', | ||
|
@@ -101,7 +81,6 @@ class Login extends Component { | |
} | ||
|
||
saveDomainToSettings() { | ||
|
||
const {domain} = this.state; | ||
let PLOTLY_API_SSL_ENABLED = true; | ||
let PLOTLY_API_DOMAIN = ''; | ||
|
@@ -125,35 +104,41 @@ class Login extends Component { | |
|
||
} | ||
buildOauthUrl() { | ||
const {domain} = this.state; | ||
/* global PLOTLY_ENV */ | ||
const oauthClientId = PLOTLY_ENV.OAUTH2_CLIENT_ID; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good to get rid of this.. #Cleanup.. :) |
||
|
||
const {clientId, domain} = this.state; | ||
const redirect_uri = baseUrlWrapped; | ||
return ( | ||
`${domain}/o/authorize/?response_type=token&` + | ||
`client_id=${oauthClientId}&` + | ||
`client_id=${clientId}&` + | ||
`redirect_uri=${redirect_uri}/oauth2/callback` | ||
); | ||
} | ||
|
||
oauthPopUp() { | ||
try { | ||
const electron = dynamicRequireElectron(); | ||
const oauthUrl = this.buildOauthUrl(); | ||
electron.shell.openExternal(oauthUrl); | ||
} catch (e) { | ||
// eslint-disable-next-line no-console | ||
console.log('Unable to openExternal, opening a popupWindow instead:'); | ||
// eslint-disable-next-line no-console | ||
console.log(e); | ||
const popupWindow = PopupCenter( | ||
this.buildOauthUrl(), 'Authorization', '500', '500' | ||
); | ||
if (window.focus) { | ||
popupWindow.focus(); | ||
} | ||
} | ||
// http://stackoverflow.com/questions/4068373/center-a-popup-window-on-screen | ||
const url = this.buildOauthUrl(); | ||
const title = 'Authorization'; | ||
const w = '600'; | ||
const h = '600'; | ||
|
||
// Fixes dual-screen position | ||
const dualScreenLeft = 'screenLeft' in window ? window.screenLeft : screen.left; | ||
const dualScreenTop = 'screenTop' in window ? window.screenTop : screen.top; | ||
|
||
const width = window.innerWidth | ||
? window.innerWidth | ||
: document.documentElement.clientWidth | ||
? document.documentElement.clientWidth | ||
: screen.width; | ||
const height = window.innerHeight | ||
? window.innerHeight | ||
: document.documentElement.clientHeight | ||
? document.documentElement.clientHeight | ||
: screen.height; | ||
|
||
const left = ((width / 2) - (w / 2)) + dualScreenLeft; | ||
const top = ((height / 2) - (h / 2)) + dualScreenTop; | ||
|
||
this.popup = window.open(url, title, `scrollbars=yes, width=${w}, height=${h}, top=${top}, left=${left}`); | ||
} | ||
|
||
logIn () { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
its oauth2 client id, so we can probably name it like that. DB connector in itself doesn't have a notion of client-id.