a0e107f17f
New plugins: * LRDD LRDD implements client-side RFC6415 and RFC7033 resource descriptor discovery procedures. I.e. LRDD, host-meta and WebFinger stuff. OStatus and OpenID now depend on the LRDD plugin (XML_XRD). * WebFinger This plugin implements the server-side of RFC6415 and RFC7033. Note: WebFinger technically doesn't handle XRD, but we serve both that and JRD (JSON Resource Descriptor), depending on Accept header and one ugly hack to check for old StatusNet installations. WebFinger depends on LRDD. We might make this even prettier by using Net_WebFinger, but it is not currently RFC7033 compliant (no /.well-known/webfinger resource GETs). Disabling the WebFinger plugin would effectively render your site non- federated (which might be desired on a private site). Disabling the LRDD plugin would make your site unable to do modern web URI lookups (making life just a little bit harder).
51 lines
1.4 KiB
PHP
51 lines
1.4 KiB
PHP
<?php
|
|
/**
|
|
* Implementation of discovery using HTTP Link header
|
|
*
|
|
* Discovers XRD file for a user by fetching the URL and reading any
|
|
* Link: headers in the HTTP response.
|
|
*
|
|
* @category Discovery
|
|
* @package StatusNet
|
|
* @author James Walker <james@status.net>
|
|
* @copyright 2010 StatusNet, Inc.
|
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
|
|
* @link http://status.net/
|
|
*/
|
|
class LRDDMethod_LinkHeader extends LRDDMethod
|
|
{
|
|
/**
|
|
* For HTTP IDs fetch the URL and look for Link headers.
|
|
*
|
|
* @todo fail out of WebFinger URIs faster
|
|
*/
|
|
public function discover($uri)
|
|
{
|
|
$response = self::fetchUrl($uri, HTTPClient::METHOD_HEAD);
|
|
|
|
$link_header = $response->getHeader('Link');
|
|
if (empty($link_header)) {
|
|
throw new Exception('No Link header found');
|
|
}
|
|
common_debug('LRDD LinkHeader found: '.var_export($link_header,true));
|
|
|
|
return self::parseHeader($link_header);
|
|
}
|
|
|
|
/**
|
|
* Given a string or array of headers, returns JRD-like assoc array
|
|
*
|
|
* @param string|array $header string or array of strings for headers
|
|
*
|
|
* @return array of associative arrays in JRD-like array format
|
|
*/
|
|
protected static function parseHeader($header)
|
|
{
|
|
$lh = new LinkHeader($header);
|
|
|
|
$link = new XML_XRD_Element_Link($lh->rel, $lh->href, $lh->type);
|
|
|
|
return array($link);
|
|
}
|
|
}
|