better support for split domains
This commit is contained in:
parent
fa11d7d397
commit
1cfbff6d4c
5 changed files with 16 additions and 11 deletions
|
@ -1,6 +1,7 @@
|
||||||
[generic]
|
[generic]
|
||||||
protocol = 'https'
|
protocol = 'https'
|
||||||
externaldomain = 'your.fqdn'
|
externaldomain = 'federator.your.fqdn'
|
||||||
|
sourcedomain = 'your.fqdn'
|
||||||
|
|
||||||
[database]
|
[database]
|
||||||
host = '127.0.0.1'
|
host = '127.0.0.1'
|
||||||
|
|
|
@ -127,6 +127,7 @@ class FedUsers implements APIInterface
|
||||||
}
|
}
|
||||||
$config = $this->main->getConfig();
|
$config = $this->main->getConfig();
|
||||||
$domain = $config['generic']['externaldomain'];
|
$domain = $config['generic']['externaldomain'];
|
||||||
|
$sourcedomain = $config['generic']['sourcedomain'];
|
||||||
$jsonKey = json_encode($user->publicKey);
|
$jsonKey = json_encode($user->publicKey);
|
||||||
if (!is_string($jsonKey)) {
|
if (!is_string($jsonKey)) {
|
||||||
throw new \Federator\Exceptions\FileNotFound();
|
throw new \Federator\Exceptions\FileNotFound();
|
||||||
|
@ -137,6 +138,7 @@ class FedUsers implements APIInterface
|
||||||
'imageMediaType' => $user->imageMediaType,
|
'imageMediaType' => $user->imageMediaType,
|
||||||
'imageURL' => $user->imageURL,
|
'imageURL' => $user->imageURL,
|
||||||
'fqdn' => $domain,
|
'fqdn' => $domain,
|
||||||
|
'sourcedomain' => $sourcedomain,
|
||||||
'name' => $user->name,
|
'name' => $user->name,
|
||||||
'username' => $user->id,
|
'username' => $user->id,
|
||||||
'publickey' => trim($jsonKey, '"'),
|
'publickey' => trim($jsonKey, '"'),
|
||||||
|
|
|
@ -48,7 +48,8 @@ class WebFinger
|
||||||
$matches = [];
|
$matches = [];
|
||||||
$config = $this->main->getConfig();
|
$config = $this->main->getConfig();
|
||||||
$domain = $config['generic']['externaldomain'];
|
$domain = $config['generic']['externaldomain'];
|
||||||
if (preg_match("/^acct:([^@]+)@(.*)$/", $_resource, $matches) != 1 || $matches[2] !== $domain) {
|
$sourcedomain = $config['generic']['sourcedomain'];
|
||||||
|
if (preg_match("/^acct:([^@]+)@(.*)$/", $_resource, $matches) != 1 || $matches[2] !== $sourcedomain) {
|
||||||
throw new \Federator\Exceptions\InvalidArgument();
|
throw new \Federator\Exceptions\InvalidArgument();
|
||||||
}
|
}
|
||||||
$user = \Federator\DIO\User::getUserByName(
|
$user = \Federator\DIO\User::getUserByName(
|
||||||
|
@ -63,6 +64,7 @@ class WebFinger
|
||||||
$data = [
|
$data = [
|
||||||
'username' => $user->id,
|
'username' => $user->id,
|
||||||
'domain' => $domain,
|
'domain' => $domain,
|
||||||
|
'sourcedomain' => $sourcedomain,
|
||||||
];
|
];
|
||||||
$response = $this->main->renderTemplate('webfinger_acct.json', $data);
|
$response = $this->main->renderTemplate('webfinger_acct.json', $data);
|
||||||
$this->wellKnown->setResponse($response);
|
$this->wellKnown->setResponse($response);
|
||||||
|
|
|
@ -58,24 +58,24 @@
|
||||||
{rdelim}
|
{rdelim}
|
||||||
{rdelim}
|
{rdelim}
|
||||||
],
|
],
|
||||||
"id":"https://{$fqdn}/{$username}",
|
"id":"https://{$sourcedomain}/{$username}",
|
||||||
"type":"{$type}",
|
"type":"{$type}",
|
||||||
"following":"https://{$fqdn}/{$username}/following",
|
"following":"https://{$fqdn}/{$username}/following",
|
||||||
"followers":"https://{$fqdn}/{$username}/followers",
|
"followers":"https://{$fqdn}/{$username}/followers",
|
||||||
"inbox":"https://{$fqdn}/{$username}/inbox",
|
"inbox":"https://{$fqdn}/{$username}/inbox",
|
||||||
"outbox":"https://{$fqdn}/{$username}/outbox",
|
"outbox":"https://{$fqdn}/{$username}/outbox",
|
||||||
"featured":"https://{$fqdn}/{$username}/collections/featured",
|
{*"featured":"https://{$fqdn}/{$username}/collections/featured",
|
||||||
"featuredTags":"https://{$fqdn}/{$username}/collections/tags",
|
"featuredTags":"https://{$fqdn}/{$username}/collections/tags",*}
|
||||||
"preferredUsername":"{$username}",
|
"preferredUsername":"{$username}",
|
||||||
"name":"{$name}",
|
"name":"{$name}",
|
||||||
"summary":"{$summary}",
|
"summary":"{$summary}",
|
||||||
"url":"https://{$fqdn}/@{$username}",
|
"url":"https://{$sourcedomain}/@{$username}",
|
||||||
"manuallyApprovesFollowers":false,
|
"manuallyApprovesFollowers":false,
|
||||||
"discoverable":true,
|
"discoverable":true,
|
||||||
"published":"{$registered}",
|
"published":"{$registered}",
|
||||||
"publicKey":{ldelim}
|
"publicKey":{ldelim}
|
||||||
"id":"https://{$fqdn}/{$username}#main-key",
|
"id":"https://{$fqdn}/{$username}#main-key",
|
||||||
"owner":"https://{$fqdn}/{$username}",
|
"owner":"https://{$sourcedomain}/{$username}",
|
||||||
"publicKeyPem":"{$publickey}"
|
"publicKeyPem":"{$publickey}"
|
||||||
{rdelim},
|
{rdelim},
|
||||||
"tag":[],
|
"tag":[],
|
||||||
|
@ -83,7 +83,7 @@
|
||||||
{if $type==='group'}{ldelim}
|
{if $type==='group'}{ldelim}
|
||||||
"type":"PropertyValue",
|
"type":"PropertyValue",
|
||||||
"name":"website",
|
"name":"website",
|
||||||
"value":"\u003ca href=\"https://{$fqdn}/@{$username}\" target=\"_blank\" rel=\"nofollow noopener noreferrer me\"\u003e\u003cspan class=\"invisible\"\u003ehttps://\u003c/span\u003e\u003cspan class=\"\"\u003e{$fqdn}/@{$username}\u003c/span\u003e\u003cspan class=\"invisible\"\u003e\u003c/span\u003e\u003c/a\u003e"
|
"value":"\u003ca href=\"https://{$sourcedomain}/@{$username}\" target=\"_blank\" rel=\"nofollow noopener noreferrer me\"\u003e\u003cspan class=\"invisible\"\u003ehttps://\u003c/span\u003e\u003cspan class=\"\"\u003e{$fqdn}/@{$username}\u003c/span\u003e\u003cspan class=\"invisible\"\u003e\u003c/span\u003e\u003c/a\u003e"
|
||||||
{rdelim}{/if}
|
{rdelim}{/if}
|
||||||
],
|
],
|
||||||
"endpoints":{ldelim}
|
"endpoints":{ldelim}
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
{ldelim}
|
{ldelim}
|
||||||
"subject": "acct:{$username}@{$domain}",
|
"subject": "acct:{$username}@{$sourcedomain}",
|
||||||
"aliases": [
|
"aliases": [
|
||||||
"https://{$domain}/@{$username}"
|
"https://{$sourcedomain}/@{$username}"
|
||||||
],
|
],
|
||||||
"links": [
|
"links": [
|
||||||
{ldelim}"rel": "self", "type": "application/activity+json", "href": "https://{$domain}/{$username}"{rdelim},
|
{ldelim}"rel": "self", "type": "application/activity+json", "href": "https://{$domain}/@{$username}"{rdelim},
|
||||||
{if $type=='Group'}
|
{if $type=='Group'}
|
||||||
{ldelim}"rel": "http://webfinger.net/rel/profile-page", "type": "text/html", "href": "https://{$domain}/@{$username}/"{rdelim},
|
{ldelim}"rel": "http://webfinger.net/rel/profile-page", "type": "text/html", "href": "https://{$domain}/@{$username}/"{rdelim},
|
||||||
{/if}
|
{/if}
|
||||||
|
|
Loading…
Add table
Reference in a new issue