-
-
Notifications
You must be signed in to change notification settings - Fork 243
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
Added additional CSP contents to enable videojs and ipcamera binding #698
Conversation
Signed-off-by: Dan Cunningham <dan@digitaldan.com>
Thanks for the investigation! |
Here is my setup and the exact error i get without the additional csp content - component: oh-video-card
config:
type: application/x-mpegurl
title: Front Drive
item: CameraFrontDrivewayHLS the item CameraFrontDrivewayHLS is set to: when the page loads i get these in the log, and the video never loads:
after adding the additional CSP tags, the content loads as expected. Thanks! |
Interesting, must be a video.js implementation technique to use blob: urls sometimes but not always. So maybe simply adding blob: to the default-src part would be enough? |
@@ -11,7 +11,7 @@ | |||
* Disables use of inline scripts in order to mitigate risk of XSS vulnerabilities. To change this: | |||
* Enable inline JS: add 'unsafe-inline' to default-src | |||
--> | |||
<meta http-equiv="Content-Security-Policy" content="default-src * 'self' 'unsafe-inline' 'unsafe-eval' data: gap: content:"> | |||
<meta http-equiv="Content-Security-Policy" content="default-src * 'self' 'unsafe-inline' 'unsafe-eval' data: gap: content:; media-src * blob:; worker-src * blob:"> |
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.
Does this work?
<meta http-equiv="Content-Security-Policy" content="default-src * 'self' 'unsafe-inline' 'unsafe-eval' data: gap: content:; media-src * blob:; worker-src * blob:"> | |
<meta http-equiv="Content-Security-Policy" content="default-src * 'self' 'unsafe-inline' 'unsafe-eval' data: gap: content: blob:"> |
Perhaps allowing blob: could also be valuable for images and so on so no harm in allowing them by default.
At some point I'll probably look after having a same-origin policy for scripts and CSS to mitigate importing malicious external libraries, maybe disable unsafe-eval too if it's not required.
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.
Yes, that works! I updated the PR with your change.
Signed-off-by: Dan Cunningham <dan@digitaldan.com>
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.
Thanks!
* master: Take all door subclasses in door location glance badge (openhab#727) [habpanel] Remove ItemStateEvent detection (openhab#737) Update license headers to 2021 (openhab#739) Fix openhab#714 - Sort popup dialogs by name and jump to selected item on open (openhab#724) Fix openhab#538 - Do not concatenate search for items (openhab#726) Fix openhab#722 - Show current GA metadata when editing (openhab#723) Fix openhab#720 - Fix various problems with google assistant metadata UI (openhab#721) Fix openhab#684 - Allow diacritics in search bars (openhab#718) CSP: allow blob: URLs (openhab#698) Apply Spotless (openhab#680) [unleash-maven-plugin] Preparation for next development cycle.
Needed in the somes for video streams in the video card. Signed-off-by: Dan Cunningham <dan@digitaldan.com>
Signed-off-by: Dan Cunningham dan@digitaldan.com
i was not able to load m3u8/ts content from our ipcamera binding with the new video widget as the CSP policy was blocking the media being loaded as well as blocking a web worker from doing something (might be in the videojs library?) .
The camera binding runs the HLS stream for cameras on different ports, so camera 1 might have a http dash stream on 10001, camera2 on 10002, and so on , which the browser will treat as different domains i believe. I'm no expert on CSP policy so i don't know if the exceptions in this PR create a meaningful security hole.
I personally would rather have a bit more relaxed CSP policy to load external content since the UI is not normally exposed unauthenticated (by firewall, the cloud service, etc..)