summaryrefslogtreecommitdiffstats
path: root/apps/user_webfinger/appinfo
diff options
context:
space:
mode:
authorTom Needham <needham.thomas@gmail.com>2012-04-07 17:31:30 +0000
committerTom Needham <needham.thomas@gmail.com>2012-04-07 17:31:30 +0000
commit9edf45a324c2f1d4532d02e5c8fa37ebfa0c9dab (patch)
treed7d33a1968370791ec054b5ac4442c41d64498b0 /apps/user_webfinger/appinfo
parentd2886f202024243ae4d92e2eea9d3726037a9601 (diff)
parentd1ae6512cc760c76798a5a8636d1d7908c706ae8 (diff)
downloadnextcloud-server-9edf45a324c2f1d4532d02e5c8fa37ebfa0c9dab.tar.gz
nextcloud-server-9edf45a324c2f1d4532d02e5c8fa37ebfa0c9dab.zip
Merge branch 'master' into migration
Diffstat (limited to 'apps/user_webfinger/appinfo')
-rw-r--r--apps/user_webfinger/appinfo/info.xml6
-rw-r--r--apps/user_webfinger/appinfo/install.php47
2 files changed, 49 insertions, 4 deletions
diff --git a/apps/user_webfinger/appinfo/info.xml b/apps/user_webfinger/appinfo/info.xml
index 55cf2cf2201..d47fb723a3a 100644
--- a/apps/user_webfinger/appinfo/info.xml
+++ b/apps/user_webfinger/appinfo/info.xml
@@ -2,9 +2,9 @@
<info>
<id>user_webfinger</id>
<name>Webfinger</name>
- <description>Provide WebFinger for all users so they get a user address like user@owncloudinstance which can be used for unhosted applications. If you don't run ownCloud in the root of your domain, for instance if you run it on example.com/owncloud/, then make sure you link example.com/.well-known/ to example.com/owncloud/apps/user_webfinger/ - by running something like "ln -s /var/www/owncloud/apps/user_webfinger /var/www/.well-known". Only enable this app if you run this ownCloud installation on a public web address, not if you run it on an intranet or on localhost.</description>
- <version>0.2</version>
+ <description>Provide WebFinger for all users so they get a user address like user@owncloudinstance which can be used for external applications. Other apps can provide information for webfinger requests, such as remoteStorage compatibility.</description>
+ <version>0.3</version>
<licence>AGPL or MIT</licence>
- <author>Michiel de Jong</author>
+ <author>Michiel de Jong, Florian Hülsmann</author>
<require>2</require>
</info>
diff --git a/apps/user_webfinger/appinfo/install.php b/apps/user_webfinger/appinfo/install.php
index f570a3a249b..c8d9a427425 100644
--- a/apps/user_webfinger/appinfo/install.php
+++ b/apps/user_webfinger/appinfo/install.php
@@ -1,6 +1,51 @@
<?php
+$hostMetaHeader = array(
+ 'Access-Control-Allow-Origin' => '*',
+ 'Content-Type' => 'application/xml+xrd'
+);
$appInfoDir = __DIR__;
$thisAppDir = dirname($appInfoDir);
$appsDir = dirname($thisAppDir);
$ownCloudDir = dirname($appsDir);
-@symlink($thisAppDir, $ownCloudDir.'/.well-known');
+$docRoot = $_SERVER['DOCUMENT_ROOT'];
+try {
+ $webRoot = substr(realpath($ownCloudDir), strlen(realpath($docRoot)));
+} catch(Exception $e) {
+ // some servers fail on realpath(), let's try it the unsecure way:
+ $webRoot = substr($ownCloudDir, strlen($docRoot));
+}
+$serverName = $_SERVER['SERVER_NAME'];
+$lrddTmpl = 'http';
+if(isset($_SERVER['HTTPS'])) {
+ $lrddTmpl .= 's';
+}
+$lrddTmpl .= '://' . $serverName . $webRoot . '/apps/user_webfinger/webfinger.php?q={uri}';
+$hostMetaPath = $docRoot . '/.well-known/host-meta';
+$hostMetaDir = $docRoot . '/.well-known';
+$hostMetaContents = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
+<XRD xmlns=\"http://docs.oasis-open.org/ns/xri/xrd-1.0\" xmlns:hm=\"http://host-meta.net/xrd/1.0\">
+ <hm:Host xmlns=\"http://host-meta.net/xrd/1.0\">" . $serverName . "</hm:Host>
+ <Link rel=\"lrdd\" template=\"" . $lrddTmpl . "\">
+ <Title>Resource Descriptor</Title>
+ </Link>
+</XRD>";
+@mkdir($hostMetaDir);
+$hostMeta = fopen($hostMetaPath, 'w');
+if(!$hostMeta) {
+ die("Could not open " . $hostMetaPath . " for writing, please check permissions!");
+}
+if(!fwrite($hostMeta, $hostMetaContents, strlen($hostMetaContents))) {
+ die("Could not write to " . $hostMetaPath . ", please check permissions!");
+}
+fclose($hostMeta);
+
+// write custom headers into .htaccess:
+$htaccess = fopen($hostMetaDir . '/.htaccess', 'w');
+//TODO: check compatibility!
+fwrite($htaccess, "<filesMatch \"^host-meta$\">
+<ifModule mod_headers.c>\n");
+foreach($hostMetaHeader as $header => $value) {
+ fwrite($htaccess, "Header set " . $header . " \"" . $value . "\"\n");
+}
+fwrite($htaccess, "</ifModule>\n</filesMatch>");
+fclose($htaccess);