Skip to content

Commit

Permalink
refs #6 attempt to make sure csp lets the frame be
Browse files Browse the repository at this point in the history
Signed-off-by: Julien Veyssier <eneiluj@posteo.net>
  • Loading branch information
Julien Veyssier committed Feb 24, 2021
1 parent f927d16 commit 9c538df
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
This app integrates Spacedeck whiteboard server. It lets Nextcloud users create `.whiteboard` files
which can then be opened in the Files app and in Talk. Those files can be shared to other users
or via public links. Everyone having access to such a file can edit it collaboratively.]]></description>
<version>0.0.13</version>
<version>0.0.14</version>
<licence>agpl</licence>
<author>Julien Veyssier</author>
<namespace>Spacedeck</namespace>
Expand Down
9 changes: 7 additions & 2 deletions lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ public function __construct(array $urlParams = []) {
$spacedeckUrl = $container->getServer()->getConfig()->getAppValue(self::APP_ID, 'base_url', DEFAULT_SPACEDECK_URL);
if ($spacedeckUrl !== DEFAULT_SPACEDECK_URL) {
$this->updateCSP($spacedeckUrl);
} else {
$this->updateCSP();
}
}

Expand All @@ -73,13 +75,16 @@ private function loadFilesScripts() {
/**
* this might have been necessary in the past
*/
public function updateCSP(string $url) {
public function updateCSP(string $url = '') {
$container = $this->getContainer();

$cspManager = $container->getServer()->getContentSecurityPolicyManager();
$policy = new ContentSecurityPolicy();
$policy->addAllowedFrameDomain('\'self\'');
$policy->addAllowedFrameDomain($url);
$policy->addAllowedFrameAncestorDomain('\'self\'');
if ($url) {
$policy->addAllowedFrameDomain($url);
}

$cspManager->addDefaultPolicy($policy);
}
Expand Down

0 comments on commit 9c538df

Please sign in to comment.