Skip to content
This repository has been archived by the owner on Dec 28, 2021. It is now read-only.

User Authentication in IDE #1653

Merged
merged 18 commits into from
Jul 6, 2021
Merged
5 changes: 5 additions & 0 deletions .github/workflows/gui-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ jobs:
CSC_IDENTITY_AUTO_DISCOVERY: true
APPLEID: ${{secrets.APPLE_NOTARIZATION_USERNAME}}
APPLEIDPASS: ${{secrets.APPLE_NOTARIZATION_PASSWORD}}
FIREBASE_API_KEY: ${{secrets.FIREBASE_API_KEY}}
run: node ./run dist --skip-version-validation --target macos
if: startsWith(matrix.os,'macos')
build:
Expand Down Expand Up @@ -330,15 +331,19 @@ jobs:
CSC_IDENTITY_AUTO_DISCOVERY: true
APPLEID: ${{secrets.APPLE_NOTARIZATION_USERNAME}}
APPLEIDPASS: ${{secrets.APPLE_NOTARIZATION_PASSWORD}}
FIREBASE_API_KEY: ${{secrets.FIREBASE_API_KEY}}
run: node ./run dist --skip-version-validation --target macos
if: startsWith(matrix.os,'macos')
- name: Build (win)
env:
WIN_CSC_LINK: ${{secrets.MICROSOFT_CODE_SIGNING_CERT}}
WIN_CSC_KEY_PASSWORD: ${{secrets.MICROSOFT_CODE_SIGNING_CERT_PASSWORD}}
FIREBASE_API_KEY: ${{secrets.FIREBASE_API_KEY}}
run: node ./run dist --skip-version-validation --target win
if: startsWith(matrix.os,'windows')
- name: Build (linux)
env:
FIREBASE_API_KEY: ${{secrets.FIREBASE_API_KEY}}
run: node ./run dist --skip-version-validation --target linux
if: startsWith(matrix.os,'ubuntu')
- name: Upload Content Artifacts
Expand Down
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,25 @@
# Enso 2.0.0-alpha.7 (2021-06-06)

<br/>![New Features](/docs/assets/tags/new_features.svg)

#### Visual Environment

- [User Authentication][1653]. Users can sign in to Enso using Google, GitHub or
email accounts.

<br/>![Bug Fixes](/docs/assets/tags/bug_fixes.svg)

#### Visual Environment

- [Fix node selection bug ][1664]. Fix nodes not being deselected correctly in
some circumstances. This would lead to nodes moving too fast when dragged
[1650] or the internal state of the project being inconsistent [1626].

[1653]: https://github.com/enso-org/ide/pull/1653
[1664]: https://github.com/enso-org/ide/pull/1664

<br/>

# Enso 2.0.0-alpha.6 (2021-06-28)

<br/>![New Features](/docs/assets/tags/new_features.svg)
Expand Down
10 changes: 7 additions & 3 deletions build/workflow.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,14 +172,18 @@ buildOnMacOS = buildOn('macos', 'macos', {
CSC_LINK: '${{secrets.APPLE_CODE_SIGNING_CERT}}',
CSC_KEY_PASSWORD: '${{secrets.APPLE_CODE_SIGNING_CERT_PASSWORD}}',
CSC_IDENTITY_AUTO_DISCOVERY: true,
APPLEID:'${{secrets.APPLE_NOTARIZATION_USERNAME}}',
APPLEIDPASS:'${{secrets.APPLE_NOTARIZATION_PASSWORD}}',
APPLEID: '${{secrets.APPLE_NOTARIZATION_USERNAME}}',
APPLEIDPASS: '${{secrets.APPLE_NOTARIZATION_PASSWORD}}',
FIREBASE_API_KEY: '${{secrets.FIREBASE_API_KEY}}',
})
buildOnWindows = buildOn('win', 'windows', {
WIN_CSC_LINK: '${{secrets.MICROSOFT_CODE_SIGNING_CERT}}',
WIN_CSC_KEY_PASSWORD: '${{secrets.MICROSOFT_CODE_SIGNING_CERT_PASSWORD}}',
FIREBASE_API_KEY: '${{secrets.FIREBASE_API_KEY}}',
})
buildOnLinux = buildOn('linux', 'ubuntu', {
FIREBASE_API_KEY: '${{secrets.FIREBASE_API_KEY}}',
})
buildOnLinux = buildOn('linux', 'ubuntu')

let lintMarkdown = {
name: "Lint Markdown sources",
Expand Down
3 changes: 3 additions & 0 deletions config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"minimumSupportedVersion": "2.0.0-alpha.6"
}
24 changes: 23 additions & 1 deletion src/js/lib/client/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ function capitalizeFirstLetter(string) {
const execFile = util.promisify(child_process.execFile);


// The list of hosts that the app can access. They are required for
// user authentication to work.
const trustedHosts = [
'enso-org.firebaseapp.com',
'accounts.google.com',
'accounts.youtube.com',
'github.com',
]

// =====================
// === Option Parser ===
Expand Down Expand Up @@ -332,7 +340,7 @@ Electron.app.on('web-contents-created', (event,contents) => {
Electron.app.on('web-contents-created', (event,contents) => {
contents.on('will-navigate', (event,navigationUrl) => {
const parsedUrl = new URL(navigationUrl)
if (parsedUrl.origin !== origin) {
if (parsedUrl.origin !== origin && !trustedHosts.includes(parsedUrl.host)) {
event.preventDefault()
console.error(`Prevented navigation to '${navigationUrl}'.`)
}
Expand Down Expand Up @@ -441,6 +449,7 @@ let mainWindow = null
let origin = null

async function main(args) {
setUserAgent()
runBackend()
console.log("Starting the IDE service.")
if(args.server !== false) {
Expand All @@ -462,6 +471,19 @@ async function main(args) {
}
}

/// Set custom user agent to fix the issue with Google authentication.
///
/// Google authentication doesn't work with the default Electron user agent. And
/// Google is quite picky about the values you provide. For example, just
/// removing Electron occurrences from the default user agent doesn't work. This
/// user agent was chosen by trial and error as a stable one.
///
/// https://github.com/firebase/firebase-js-sdk/issues/2478
function setUserAgent() {
const agent = 'Mozilla/5.0 (Windows NT 10.0; WOW64; rv:70.0) Gecko/20100101 Firefox/70.0'
Comment on lines +474 to +483
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is so strange. It's ok, just strange

Electron.app.userAgentFallback = agent
Electron.session.defaultSession.setUserAgent(agent)
}
function urlParamsFromObject(obj) {
let params = []
for (let key in obj) {
Expand Down
7 changes: 7 additions & 0 deletions src/js/lib/content/firebase.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
authDomain: "enso-org.firebaseapp.com"
projectId: "enso-org"
storageBucket: "enso-org.appspot.com"
messagingSenderId: "451746386966"
appId: "1:451746386966:web:558a832abe486208d61137"
measurementId: "G-W11ZNCQ476"
clientId: "451746386966-u5piv17hgvnimpq5ic5p60liekcqmqmu.apps.googleusercontent.com"
2 changes: 2 additions & 0 deletions src/js/lib/content/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ let config = {
},
dependencies: {
"enso-studio-common": "1.0.0",
"firebase": "^8.6.8",
"firebaseui": "^4.8.0",
"copy-webpack-plugin": "^5.1.1",
"mixpanel-browser": "2.40.1"
},
Expand Down
3 changes: 3 additions & 0 deletions src/js/lib/content/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
<!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP -->
<!-- FIXME https://github.com/validator/validator/issues/917 -->
<!-- FIXME Security Vulnerabilities: https://github.com/enso-org/ide/issues/226 -->
<!-- NOTE `frame-src` section of `http-equiv` required only for authorization -->
<meta http-equiv="Content-Security-Policy" content="
default-src 'self';
frame-src 'self' data: https://accounts.google.com https://enso-org.firebaseapp.com;
script-src 'self' 'unsafe-eval' data: https://*;
style-src 'self' 'unsafe-inline' data: https://*;
connect-src 'self' data: ws://localhost:* ws://127.0.0.1:* http://localhost:* https://*;
Expand All @@ -22,6 +24,7 @@
/>
<title>Enso</title>
<link rel="stylesheet" href="/assets/style.css" />
<link type="text/css" rel="stylesheet" href="https://www.gstatic.com/firebasejs/ui/4.8.0/firebase-ui-auth.css" />
<script type="module" src="/assets/index.js" defer></script>
<script type="module" src="/assets/run.js" defer></script>
</head>
Expand Down
Loading