Skip to content

Commit

Permalink
Merge pull request #51 from gary-kim/fix/47/mic-camera-request
Browse files Browse the repository at this point in the history
Add camera, microphone, and display-capture to feat policy
  • Loading branch information
gary-kim authored May 16, 2020
2 parents 47cd417 + 01281fe commit eaedc2a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
7 changes: 7 additions & 0 deletions lib/Controller/AppController.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
use OCP\IConfig;
use OCP\IInitialStateService;
use OCP\IRequest;
use OCP\AppFramework\Http\FeaturePolicy;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\AppFramework\Controller;

Expand Down Expand Up @@ -63,6 +64,12 @@ public function index() {
$csp->addAllowedFrameDomain($this->request->getServerHost());
$response->setContentSecurityPolicy($csp);

$featurePolicy = new FeaturePolicy();
$featurePolicy->addAllowedCameraDomain('\'self\'');
$featurePolicy->addAllowedMicrophoneDomain('\'self\'');

$response->setFeaturePolicy($featurePolicy);

return $response;
}
}
7 changes: 7 additions & 0 deletions lib/Controller/StaticController.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
use OC\Security\CSP\ContentSecurityPolicyNonceManager;
use OCA\RiotChat\FileResponse;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\FeaturePolicy;
use OCP\AppFramework\Http\NotFoundResponse;
use OCP\Files\IMimeTypeDetector;
use OCP\IConfig;
Expand Down Expand Up @@ -162,6 +163,12 @@ private function createFileResponseWithContent(string $path, string $content, $c

$response->setContentSecurityPolicy($csp);

$featurePolicy = new FeaturePolicy();
$featurePolicy->addAllowedCameraDomain('\'self\'');
$featurePolicy->addAllowedMicrophoneDomain('\'self\'');

$response->setFeaturePolicy($featurePolicy);

return $response;
}

Expand Down
2 changes: 1 addition & 1 deletion templates/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
script('riotchat', 'main');
?>

<iframe id="riot-iframe" scrolling="no"></iframe>
<iframe id="riot-iframe" scrolling="no" allow="camera; microphone; display-capture"></iframe>

0 comments on commit eaedc2a

Please sign in to comment.