webfinger enhancements: per RFC7033
This commit is contained in:
parent
7375e30506
commit
f924d38d8c
@ -19,6 +19,8 @@ function _well_known_init(&$a){
|
|||||||
require_once('mod/wfinger.php');
|
require_once('mod/wfinger.php');
|
||||||
wfinger_init($a);
|
wfinger_init($a);
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,9 +20,6 @@ function wfinger_init(&$a) {
|
|||||||
|
|
||||||
$resource = $_REQUEST['resource'];
|
$resource = $_REQUEST['resource'];
|
||||||
|
|
||||||
header('Access-Control-Allow-Origin: *');
|
|
||||||
|
|
||||||
header('Content-type: application/jrd+json');
|
|
||||||
|
|
||||||
$r = null;
|
$r = null;
|
||||||
|
|
||||||
@ -30,7 +27,13 @@ function wfinger_init(&$a) {
|
|||||||
|
|
||||||
if(strpos($resource,'acct:') === 0) {
|
if(strpos($resource,'acct:') === 0) {
|
||||||
$channel = str_replace('acct:','',$resource);
|
$channel = str_replace('acct:','',$resource);
|
||||||
$channel = substr($channel,0,strpos($channel,'@'));
|
if(strpos($channel,'@') !== false) {
|
||||||
|
$host = substr($channel,strpos($channel,'@')+1);
|
||||||
|
if(strcasecmp($host,get_app()->get_hostname())) {
|
||||||
|
goaway('https://' . $host . '/.well-known/webfinger?resource=' . $resource);
|
||||||
|
}
|
||||||
|
$channel = substr($channel,0,strpos($channel,'@'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(strpos($resource,'http') === 0) {
|
if(strpos($resource,'http') === 0) {
|
||||||
$channel = str_replace('~','',basename($resource));
|
$channel = str_replace('~','',basename($resource));
|
||||||
@ -43,6 +46,13 @@ function wfinger_init(&$a) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
header('Access-Control-Allow-Origin: *');
|
||||||
|
|
||||||
|
header('Content-type: application/jrd+json');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if($resource && $r) {
|
if($resource && $r) {
|
||||||
|
|
||||||
$result['subject'] = $resource;
|
$result['subject'] = $resource;
|
||||||
@ -55,6 +65,8 @@ function wfinger_init(&$a) {
|
|||||||
|
|
||||||
$result['aliases'] = array();
|
$result['aliases'] = array();
|
||||||
|
|
||||||
|
$result['properties'] = array('http://webfinger.example/ns/name' => $r[0]['channel_name']);
|
||||||
|
|
||||||
foreach($aliases as $alias)
|
foreach($aliases as $alias)
|
||||||
if($alias != $resource)
|
if($alias != $resource)
|
||||||
$result['aliases'][] = $alias;
|
$result['aliases'][] = $alias;
|
||||||
|
Reference in New Issue
Block a user