feat/fedi-redirect (#5682)
continuous-integration/drone/push Build is passing

So, this is a basic attempt at implementing the fedi redirects as described on the webpage.

Things I do not understand:

- In what format should we expect the address request to come?
- how one should determine the "location" param to be set in the header?
- What actually are the `.well-known` locations we need to redirect to the script?

Note that the php script is completely untested and almost certainly broken: this is a very rough POC

Co-authored-by: Darragh Elliott <me@delliott.net>
Reviewed-on: #5682
Co-authored-by: delliott <delliott@fsfe.org>
Co-committed-by: delliott <delliott@fsfe.org>
This commit was merged in pull request #5682.
This commit is contained in:
2026-03-08 10:59:24 +00:00
committed by tobiasd
parent 9c5238d93f
commit e23d967a44
4 changed files with 41 additions and 3 deletions
+2 -1
View File
@@ -331,4 +331,5 @@ RewriteRule ^about/printable(/.*)?$ /contribute/spreadtheword.html [R=301,L]
RewriteRule ^(tools|build)(/.*)?$ - [F,L]
# Redirect attempts to status to status.fsfe.org
RewriteRule ^status.fsfe.org(/.*)?$ https://status.fsfe.org/ [R=301,L]
# Redirect fediverse redirects to our script
RewriteRule ^\.well-known/webfinger$ /cgi-bin/webfinger.php [L]
+3
View File
@@ -51,6 +51,7 @@
full: Person is working 4 or 5 days a week
part: Person is working 3 or less days a week
freelancer: Person is working on honorary basis, no matter which salary or how long
<fediverse> Fediverse address of person.
-->
<!--
Technical information:
@@ -323,6 +324,7 @@
<function volunteers="web">coordinator/m</function>
<link>/about/people/tobiasd/tobiasd.html</link>
<avatar>tobiasd.png</avatar>
<fediverse handle="tobias@social.diekershoff.de">tobiasd@fsfe.org</fediverse>
</person>
<person id="dietrich">
@@ -627,6 +629,7 @@
<link>/about/people/kirschner/kirschner.html</link>
<avatar>kirschner.jpg</avatar>
<employee>full/m</employee>
<fediverse handle="kirschner@mastodon.social">mk@fsfe.org</fediverse>
</person>
<person id="kneissl">
+33
View File
@@ -0,0 +1,33 @@
<?php
$acc_request = strtolower($_GET['resource'] ?? '');
$xml_file = $_SERVER['DOCUMENT_ROOT'].'about/people/people.en.xml';
$people = simplexml_load_file($xml_file);
if (false === $people) {
http_response_code(500);
echo 'ERROR: Could not load people file. Please check the path:'.$xml_file;
exit;
}
foreach ($people->xpath('//fediverse') as $fedi_elem) {
if ('acct:'.strval($fedi_elem) === $acc_request) {
// if we have a location, return it and exit
if (isset($fedi_elem['handle'])) {
// Handles are in the form <username>@<server>
$handle = strval($fedi_elem['handle']);
$handle_sections = explode('@', $handle);
$response = 'Location: https://'.$handle_sections[1].'/.well-known/webfinger?resource=acct:'.$handle;
header($response);
exit;
}
http_response_code(500);
echo 'ERROR: fediverse element has no location attribute.';
exit;
}
}
// No matches
http_response_code(404);
echo '404 matching person not found.';
+3 -2
View File
@@ -1,5 +1,5 @@
# This is a config file for a site, that cuontains necessary settings
#
#
# Sources for the website
# All repos should be mirrored to https://git.fsfe.org/fsfe-system-hackers-mirrors
#
@@ -11,6 +11,7 @@ file_sets = [
{ source = "/dist/jquery.min.js", target = "scripts/thirdparty/" },
{ source = "/dist/jquery.min.map", target = "scripts/thirdparty/" },
]
[[dependencies]]
repo = "https://git.fsfe.org/fsfe-system-hackers-mirrors/lunr.js"
rev = "v2.3.9"
@@ -32,4 +33,4 @@ file_sets = [{ source = "/src", target = "cgi-bin/thirdparty/PHPMailer" }]
[deployment]
# This files contains relative paths we want to deploy even if they would be blocked by the copy_files method filtering.
# Special case hard code pass over order items xml required by cgi script
required_files = ["order/data/items.en.xml"]
required_files = ["order/data/items.en.xml", "about/people/people.en.xml"]