mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-10 08:44:49 +00:00
Update FederationController, fix webfinger endpoint
This commit is contained in:
parent
afe903c36e
commit
a0e15d89e2
1 changed files with 14 additions and 7 deletions
|
@ -48,9 +48,12 @@ class FederationController extends Controller
|
||||||
|
|
||||||
public function webfinger(Request $request)
|
public function webfinger(Request $request)
|
||||||
{
|
{
|
||||||
abort_if(!config('federation.webfinger.enabled'), 400);
|
if (!config('federation.webfinger.enabled') ||
|
||||||
|
!$request->has('resource') ||
|
||||||
abort_if(!$request->has('resource') || !$request->filled('resource'), 400);
|
!$request->filled('resource')
|
||||||
|
) {
|
||||||
|
return response('', 400);
|
||||||
|
}
|
||||||
|
|
||||||
$resource = $request->input('resource');
|
$resource = $request->input('resource');
|
||||||
$hash = hash('sha256', $resource);
|
$hash = hash('sha256', $resource);
|
||||||
|
@ -59,14 +62,18 @@ class FederationController extends Controller
|
||||||
return response()->json($cached, 200, [], JSON_UNESCAPED_SLASHES);
|
return response()->json($cached, 200, [], JSON_UNESCAPED_SLASHES);
|
||||||
}
|
}
|
||||||
$domain = config('pixelfed.domain.app');
|
$domain = config('pixelfed.domain.app');
|
||||||
abort_if(strpos($resource, $domain) == false, 400);
|
if(strpos($resource, $domain) == false) {
|
||||||
|
return response('', 400);
|
||||||
|
}
|
||||||
$parsed = Nickname::normalizeProfileUrl($resource);
|
$parsed = Nickname::normalizeProfileUrl($resource);
|
||||||
if(empty($parsed) || $parsed['domain'] !== $domain) {
|
if(empty($parsed) || $parsed['domain'] !== $domain) {
|
||||||
abort(400);
|
return response('', 400);
|
||||||
}
|
}
|
||||||
$username = $parsed['username'];
|
$username = $parsed['username'];
|
||||||
$profile = Profile::whereNull('domain')->whereUsername($username)->firstOrFail();
|
$profile = Profile::whereNull('domain')->whereUsername($username)->first();
|
||||||
abort_if($profile->status != null, 400);
|
if(!$profile || $profile->status !== null) {
|
||||||
|
return response('', 400);
|
||||||
|
}
|
||||||
$webfinger = (new Webfinger($profile))->generate();
|
$webfinger = (new Webfinger($profile))->generate();
|
||||||
Cache::put($key, $webfinger, 1209600);
|
Cache::put($key, $webfinger, 1209600);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue