Add dynamic hostname switching so requests always go to the host the client is currently using
This commit is contained in:
parent
53abf86bb7
commit
d5478678a7
3
.gitignore
vendored
3
.gitignore
vendored
@ -2,4 +2,5 @@ tests/clover.xml
|
|||||||
*.spec
|
*.spec
|
||||||
*.tar.gz
|
*.tar.gz
|
||||||
richdocuments.zip
|
richdocuments.zip
|
||||||
build/
|
build/
|
||||||
|
/nbproject/private/
|
@ -49,7 +49,7 @@ if (class_exists('\OC\Files\Type\TemplateManager')) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Whitelist the wopi URL for iframes, required for Firefox
|
// Whitelist the wopi URL for iframes, required for Firefox
|
||||||
$wopiUrl = \OC::$server->getConfig()->getAppValue('richdocuments', 'wopi_url');
|
$wopiUrl = str_replace("hostname.host", $_SERVER["HTTP_HOST"], \OC::$server->getConfig()->getAppValue('richdocuments', 'wopi_url'));
|
||||||
if ($wopiUrl !== '') {
|
if ($wopiUrl !== '') {
|
||||||
$manager = \OC::$server->getContentSecurityPolicyManager();
|
$manager = \OC::$server->getContentSecurityPolicyManager();
|
||||||
$policy = new ContentSecurityPolicy();
|
$policy = new ContentSecurityPolicy();
|
||||||
|
@ -129,7 +129,7 @@ class DocumentController extends Controller {
|
|||||||
|
|
||||||
$response = new TemplateResponse('richdocuments', 'documents', $params, 'empty');
|
$response = new TemplateResponse('richdocuments', 'documents', $params, 'empty');
|
||||||
$policy = new ContentSecurityPolicy();
|
$policy = new ContentSecurityPolicy();
|
||||||
$policy->addAllowedFrameDomain($this->appConfig->getAppValue('wopi_url'));
|
$policy->addAllowedFrameDomain(str_replace("hostname.host", $_SERVER["HTTP_HOST"], $this->appConfig->getAppValue('wopi_url')));
|
||||||
$policy->allowInlineScript(true);
|
$policy->allowInlineScript(true);
|
||||||
$response->setContentSecurityPolicy($policy);
|
$response->setContentSecurityPolicy($policy);
|
||||||
return $response;
|
return $response;
|
||||||
@ -192,7 +192,7 @@ class DocumentController extends Controller {
|
|||||||
|
|
||||||
$response = new TemplateResponse('richdocuments', 'documents', $params, 'empty');
|
$response = new TemplateResponse('richdocuments', 'documents', $params, 'empty');
|
||||||
$policy = new ContentSecurityPolicy();
|
$policy = new ContentSecurityPolicy();
|
||||||
$policy->addAllowedFrameDomain($this->appConfig->getAppValue('wopi_url'));
|
$policy->addAllowedFrameDomain(str_replace("hostname.host", $_SERVER["HTTP_HOST"], $this->appConfig->getAppValue('wopi_url')));
|
||||||
$policy->allowInlineScript(true);
|
$policy->allowInlineScript(true);
|
||||||
$response->setContentSecurityPolicy($policy);
|
$response->setContentSecurityPolicy($policy);
|
||||||
return $response;
|
return $response;
|
||||||
|
@ -66,7 +66,8 @@ class DiscoveryManager {
|
|||||||
|
|
||||||
public function get() {
|
public function get() {
|
||||||
// First check if there is a local valid discovery file
|
// First check if there is a local valid discovery file
|
||||||
try {
|
// Skylar Ittner (2017-09-06): Disable the cache so clients on multiple hosts can use it without breaking Content Security Policy
|
||||||
|
/*try {
|
||||||
$file = $this->appData->getFile('discovery.xml');
|
$file = $this->appData->getFile('discovery.xml');
|
||||||
$decodedFile = json_decode($file->getContent(), true);
|
$decodedFile = json_decode($file->getContent(), true);
|
||||||
if($decodedFile['timestamp'] + 3600 > $this->timeFactory->getTime()) {
|
if($decodedFile['timestamp'] + 3600 > $this->timeFactory->getTime()) {
|
||||||
@ -74,9 +75,9 @@ class DiscoveryManager {
|
|||||||
}
|
}
|
||||||
} catch (NotFoundException $e) {
|
} catch (NotFoundException $e) {
|
||||||
$file = $this->appData->newFile('discovery.xml');
|
$file = $this->appData->newFile('discovery.xml');
|
||||||
}
|
}*/
|
||||||
|
|
||||||
$remoteHost = $this->config->getAppValue('richdocuments', 'wopi_url');
|
$remoteHost = str_replace("hostname.host", $_SERVER["HTTP_HOST"], $this->config->getAppValue('richdocuments', 'wopi_url'));
|
||||||
$wopiDiscovery = $remoteHost . '/hosting/discovery';
|
$wopiDiscovery = $remoteHost . '/hosting/discovery';
|
||||||
|
|
||||||
$client = $this->clientService->newClient();
|
$client = $this->clientService->newClient();
|
||||||
@ -87,12 +88,13 @@ class DiscoveryManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$responseBody = $response->getBody();
|
$responseBody = $response->getBody();
|
||||||
$file->putContent(
|
// Skylar: Disable saving too, we don't need it if we're not loading ever
|
||||||
|
/*$file->putContent(
|
||||||
json_encode([
|
json_encode([
|
||||||
'data' => $responseBody,
|
'data' => $responseBody,
|
||||||
'timestamp' => $this->timeFactory->getTime(),
|
'timestamp' => $this->timeFactory->getTime(),
|
||||||
])
|
])
|
||||||
);
|
);*/
|
||||||
return $responseBody;
|
return $responseBody;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
7
nbproject/project.properties
Normal file
7
nbproject/project.properties
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
include.path=${php.global.include.path}
|
||||||
|
php.version=PHP_56
|
||||||
|
source.encoding=UTF-8
|
||||||
|
src.dir=.
|
||||||
|
tags.asp=false
|
||||||
|
tags.short=false
|
||||||
|
web.root=.
|
9
nbproject/project.xml
Normal file
9
nbproject/project.xml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://www.netbeans.org/ns/project/1">
|
||||||
|
<type>org.netbeans.modules.php.project</type>
|
||||||
|
<configuration>
|
||||||
|
<data xmlns="http://www.netbeans.org/ns/php-project/1">
|
||||||
|
<name>richdocuments</name>
|
||||||
|
</data>
|
||||||
|
</configuration>
|
||||||
|
</project>
|
@ -5,7 +5,7 @@ script('richdocuments', 'admin');
|
|||||||
<h2><?php p($l->t('Collabora Online')) ?></h2>
|
<h2><?php p($l->t('Collabora Online')) ?></h2>
|
||||||
<label for="wopi_url"><?php p($l->t('Collabora Online server')) ?></label>
|
<label for="wopi_url"><?php p($l->t('Collabora Online server')) ?></label>
|
||||||
<input type="text" name="wopi_url" id="wopi_url" value="<?php p($_['wopi_url'])?>" style="width:300px;">
|
<input type="text" name="wopi_url" id="wopi_url" value="<?php p($_['wopi_url'])?>" style="width:300px;">
|
||||||
<br/><em><?php p($l->t('URL (and port) of the Collabora Online server that provides the editing functionality as a WOPI client.')) ?></em>
|
<br/><em><?php p($l->t('URL (and port) of the Collabora Online server that provides the editing functionality as a WOPI client. If you use "hostname.host" as the host, it will be replaced with the current server name.')) ?></em>
|
||||||
<br/><button type="button" id="wopi_apply"><?php p($l->t('Apply')) ?></button>
|
<br/><button type="button" id="wopi_apply"><?php p($l->t('Apply')) ?></button>
|
||||||
<span id="documents-admin-msg" class="msg"></span>
|
<span id="documents-admin-msg" class="msg"></span>
|
||||||
<br/>
|
<br/>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user