Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add COOP+COEP+CORP headers #6597

Merged
merged 4 commits into from
May 10, 2023
Merged

Add COOP+COEP+CORP headers #6597

merged 4 commits into from
May 10, 2023

Conversation

somebody1234
Copy link
Contributor

Pull Request Description

Adds COOP+COEP+CORP headers. This is mainly required for high resolution timing (on Chrome, it increases performance.now resolution from 100us to 5us)

Important Notes

None

Checklist

Please ensure that the following checklist has been satisfied before submitting the PR:

  • The documentation has been updated, if necessary.
  • Screenshots/screencasts have been attached, if there are any visual changes. For interactive or animated visual changes, a screencast is preferred.
  • All code follows the
    Scala,
    Java,
    and
    Rust
    style guides. In case you are using a language not listed above, follow the Rust style guide.
  • All code has been tested:
    • Unit tests have been written where possible.
    • If GUI codebase was changed, the GUI was tested when built using ./run ide build.

@somebody1234 somebody1234 requested a review from wdanilo May 8, 2023 06:19
@somebody1234 somebody1234 added the CI: No changelog needed Do not require a changelog entry for this PR. label May 8, 2023
@somebody1234
Copy link
Contributor Author

mini self QA:
✔️ self.crossOriginIsolated === true + 5ms resolution performance.now on npm run watch-dashboard
✔️ self.crossOriginIsolated === true + 5ms resolution performance.now on ./run gui watch
✔️ self.crossOriginIsolated === true + 5ms resolution performance.now on ./run ide watch
✔️ self.crossOriginIsolated === true + 5ms resolution performance.now on ./run ide build
✔️ google login still works on npm run watch-dashboard
❓ oauth still works on desktop IDE - i cannot test as i'm not on macos

issues, unrelated to this PR:
❌ github login works on npm run watch-dashboard - it fails with OAuth - Error handling auth response. Error: User+is+not+confirmed.+ at @aws-amplify/auth/src/OAuth/OAuth.ts:222 (handleAuthResponse)
❌ oauth works on gui watch - this is a known issue. the main issue is that localhost:8080 isn't a valid redirect url for cognito

Comment on lines 114 to 115
response.setHeader('Cross-Origin-Embedder-Policy', 'require-corp')
response.setHeader('Cross-Origin-Opener-Policy', 'same-origin')
Copy link
Member

Choose a reason for hiding this comment

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

Please add description + links why we need it

@@ -0,0 +1,32 @@
/** @file A service worker that redirects paths without extensions to `/index.html`.
* This is only used in the cloud frontend. */
Copy link
Member

Choose a reason for hiding this comment

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

What is "cloud frontend"? I did not hear this name earlier.

@@ -0,0 +1,32 @@
/** @file A service worker that redirects paths without extensions to `/index.html`.
* This is only used in the cloud frontend. */
/// <reference lib="WebWorker" />
Copy link
Member

Choose a reason for hiding this comment

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

What is this comment about?

event.respondWith(
fetch(event.request.url).then(response => {
const clonedResponse = new Response(response.body, response)
clonedResponse.headers.set('Cross-Origin-Embedder-Policy', 'require-corp')
Copy link
Member

Choose a reason for hiding this comment

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

Please add description + links why we need it

Comment on lines 20 to 24
clonedResponse.headers.set('Cross-Origin-Opener-Policy', 'same-origin')
clonedResponse.headers.set('Cross-Origin-Resource-Policy', 'same-origin')
return clonedResponse
})
)
Copy link
Member

Choose a reason for hiding this comment

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

Also:

  1. this is the same as code in other place - can we refactor it to one place maybe?
  2. We have server built-into electron, why are we not using the same server with the watch scripts? would it not be cool to use the same code + make it possible to spawn electron in the watch mode? Ofc this is not part of this task, just a more general question.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

./run ide watch does use the same server, i believe, but ./run gui watch doesn't spawn electron at all. it might be possible to spawn electron on ./run gui watch, but in that case i'm not sure whether that would do anything different to ./run ide watch?

Comment on lines 17 to 24
? fetch('/index.html')
: fetch(event.request.url)
event.respondWith(
responsePromise.then(response => {
const clonedResponse = new Response(response.body, response)
clonedResponse.headers.set('Cross-Origin-Embedder-Policy', 'require-corp')
clonedResponse.headers.set('Cross-Origin-Opener-Policy', 'same-origin')
clonedResponse.headers.set('Cross-Origin-Resource-Policy', 'same-origin')
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 3rd place with the same code.

@wdanilo
Copy link
Member

wdanilo commented May 10, 2023

I tested it and it does seem to not break anything. I did not test loging with the new dashboard as its not enabled and I don't know how to run it, but if it did not break login using Google, then it should not influence anything else.

@wdanilo wdanilo merged commit 9597dd3 into develop May 10, 2023
@wdanilo wdanilo deleted the wip/sb/coop-coep-corp branch May 10, 2023 11:47
Procrat added a commit that referenced this pull request May 10, 2023
* develop:
  Limit the number of reported warnings (#6577)
  Add COOP+COEP+CORP headers (#6597)
  Fix issues with missing sourcemaps (#6572)
  Fix asset delete; implement project delete and project rename (#6566)
  Fix #6377: Change ctrl-r shortcut (#6620)
PabloBuchu added a commit that referenced this pull request May 11, 2023
Procrat added a commit that referenced this pull request May 11, 2023
…ing-6287

* develop:
  Fix shortcuts table formatting (#6644)
  Automatic type based dropdown does not include singleton in a union type (#6629)
  Make Meta.get_annotation work for constructor (#6633)
  Limit the number of reported warnings (#6577)
  Add COOP+COEP+CORP headers (#6597)
mergify bot pushed a commit that referenced this pull request May 11, 2023
This PR reverts latest changes regarding introducing COOP COEP CORP headers. It broke the map visualization (#6645)
somebody1234 added a commit that referenced this pull request May 11, 2023
@somebody1234 somebody1234 mentioned this pull request May 11, 2023
5 tasks
Procrat added a commit that referenced this pull request May 12, 2023
* develop:
  Implement loading spinner for visualisations. (#6512)
  Fix blank input port (#6614)
  Add `Date_Range` (#6621)
  All Vector operations shall be applicable on java.util.ArrayList (#6642)
  Fix redirect paths and enable authentication and new dashboard by default (#6605)
  Fix #6287: wrong nested breadcrumb ordering (#6617)
  Whitelist AWS Cognito domains (#6643)
  Revert "Add COOP+COEP+CORP headers (#6597)" (#6647)
  Fix shortcuts table formatting (#6644)
  Automatic type based dropdown does not include singleton in a union type (#6629)
  Make Meta.get_annotation work for constructor (#6633)
PabloBuchu pushed a commit that referenced this pull request May 12, 2023
* Revert "Revert "Add COOP+COEP+CORP headers (#6597)" (#6647)"

This reverts commit d853851.

* Fix loading third-party resources
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI: No changelog needed Do not require a changelog entry for this PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants