3 * GNU Social - a federating social network
4 * Copyright (C) 2013, Free Software Foundation, Inc.
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Affero General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Affero General Public License for more details.
16 * You should have received a copy of the GNU Affero General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 * Implements WebFinger for GNU Social, as well as support for the
22 * '.well-known/host-meta' resource.
24 * Depends on: LRDD plugin
27 * @author Mikael Nordfeldth <mmn@hethane.se>
30 if (!defined('GNUSOCIAL')) { exit(1); }
32 class WebFingerPlugin extends Plugin
34 public function onRouterInitialized($m)
36 $m->connect('.well-known/host-meta', array('action' => 'hostmeta'));
37 $m->connect('.well-known/host-meta.:format',
38 array('action' => 'hostmeta',
39 'format' => '(xml|json)'));
40 // the resource GET parameter can be anywhere, so don't mention it here
41 $m->connect('.well-known/webfinger', array('action' => 'webfinger'));
42 $m->connect('.well-known/webfinger.:format',
43 array('action' => 'webfinger',
44 'format' => '(xml|json)'));
45 $m->connect('main/ownerxrd', array('action' => 'ownerxrd'));
49 public function onLoginAction($action, &$login)
61 public function onStartHostMetaLinks(array &$links)
63 foreach (Discovery::supportedMimeTypes() as $type) {
64 $links[] = new XML_XRD_Element_Link(Discovery::LRDD_REL,
65 common_local_url('webfinger') . '?resource={uri}',
72 * Add a link header for LRDD Discovery
74 public function onStartShowHTML($action)
76 if ($action instanceof ShowstreamAction) {
77 $acct = 'acct:'. $action->profile->nickname .'@'. common_config('site', 'server');
78 $url = common_local_url('webfinger') . '?resource='.$acct;
80 foreach (array(Discovery::JRD_MIMETYPE, Discovery::XRD_MIMETYPE) as $type) {
81 header('Link: <'.$url.'>; rel="'. Discovery::LRDD_REL.'"; type="'.$type.'"');
86 public function onPluginVersion(&$versions)
88 $versions[] = array('name' => 'WebFinger',
89 'version' => STATUSNET_VERSION,
90 'author' => 'Mikael Nordfeldth',
91 'homepage' => 'http://www.gnu.org/software/social/',
92 // TRANS: Plugin description.
93 'rawdescription' => _m('Adds WebFinger lookup to GNU Social'));