-
Notifications
You must be signed in to change notification settings - Fork 14
Fix Framework/tutorial: CSP violation from inline scripts; use ES modules + docs refresh #3039
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
base: dev
Are you sure you want to change the base?
Conversation
Adjust the time-server readme Grammar fixes Remove the compatibility.js include
26eb435 to
8ef7244
Compare
| <!doctype html> | ||
| <title>Tutorial - Time server</title> | ||
| <link rel="stylesheet" href="/css/src/bootstrap.css"> | ||
| <script src="/js/src/compatibility.js"></script> |
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.
| <script type="module"> | ||
| import sessionService from '/js/src/sessionService.js'; | ||
| sessionService.loadAndHideParameters(); | ||
| </script> | ||
| <script type="module" src="./session.js"></script> | ||
|
|
||
| <!-- Main application controller --> | ||
| <script type="module"> | ||
| // Import MVC | ||
| import {mount} from '/js/src/index.js'; | ||
| import view from './view.js'; | ||
| import Model from './Model.js'; | ||
|
|
||
| // Start application | ||
| const model = new Model(); | ||
| const debug = true; // shows when redraw is done | ||
| mount(document.body, view, model, debug); | ||
|
|
||
| // Expose model to interract with it the browser's console | ||
| window.model = model; | ||
| </script> | ||
| <script type="module" src="./app.js"></script> |
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.
| mount(document.body, view, model, debug); | ||
| ``` | ||
|
|
||
| This avoids inline `<script>` and works with the framework’s default Content Security Policy. |
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.
Added a short CSP explanation to preempt confusion if someone tries to inline scripts and hits browser blocks.
| The following `this._prepareWebSocket()` method (note that by convention all method names prepended with `_` are private) listens to two events: | ||
| - `authed` - notifies that client has successfully authorized by the server (automatically generated by server) | ||
| - `server-date` - custom message that includes server's time (as defined in the [Explaining server side](#explaining-server-side) section - look for `wsServer.bind`) | ||
| - `server-date` - custom message that includes server's time (as defined in the [Server side explained](#server-side-explained) section - look for `wsServer.bind`) |
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.
It looks like the correct section to link to is:
https://github.com/AliceO2Group/WebUi/blob/dev/Framework/docs/tutorial/time-server.md#server-side-explained
The previous anchor #explaining-server-side does not exist.


I DON'T have JIRA ticket
if it is new feature explain how plan to use ittest are addedFLP integration tests were ran successfulSummary
Make the tutorial run under the framework’s default Content Security Policy (CSP) and align the docs with the actual files. The previous tutorial used an inline
<script>which modern browsers block when CSP includesscript-src 'self'. It also referenced a legacycompatibility.jsthat isn’t shipped, causing a 404. This PR moves controller code into ES modules, removes the unused script, fixes a case-sensitive import, and updates the tutorial document.What changed
Framework/docs/tutorial/public/index.html<script src="/js/src/compatibility.js"></script>(not shipped; produced 404).Framework/docs/tutorial/public/session.js(new)sessionService.loadAndHideParameters().Framework/docs/tutorial/public/app.js(new)viewandModeland callsmount(document.body, view, model, true).window.modelfor easy console debugging in the tutorial (non-production).Framework/docs/tutorial/time-server.mdsession.jsandapp.js.Modelimport case (./Model.js) to match the file name.Why
Default CSP includes
script-src 'self', which blocks inline modules; external ES modules keep the example secure and working out-of-the-box.compatibility.jsis a legacy shim that isn’t included by current builds and isn’t needed here; leaving it causes a 404.Import case (
Model.jsvsmodel.js) matters on case-sensitive filesystems and previously caused a 404.Scope / risk
Docs + tutorial assets only. No framework/runtime behavior changes. Low risk.