Update FederationController

This commit is contained in:
Daniel Supernault 2019-06-09 18:51:54 -06:00
parent 1b52febfab
commit b05325ab5b
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7

View file

@ -2,7 +2,10 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use App\Jobs\InboxPipeline\InboxWorker; use App\Jobs\InboxPipeline\{
InboxWorker,
InboxValidator
};
use App\Jobs\RemoteFollowPipeline\RemoteFollowPipeline; use App\Jobs\RemoteFollowPipeline\RemoteFollowPipeline;
use App\{ use App\{
AccountLog, AccountLog,
@ -18,8 +21,10 @@ use Cache;
use Carbon\Carbon; use Carbon\Carbon;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use League\Fractal; use League\Fractal;
use App\Util\ActivityPub\Helpers; use App\Util\ActivityPub\{
use App\Util\ActivityPub\HttpSignature; Helpers,
HttpSignature
};
use \Zttp\Zttp; use \Zttp\Zttp;
class FederationController extends Controller class FederationController extends Controller
@ -204,19 +209,9 @@ class FederationController extends Controller
abort_if(!config('federation.activitypub.enabled'), 404); abort_if(!config('federation.activitypub.enabled'), 404);
abort_if(!config('federation.activitypub.inbox'), 404); abort_if(!config('federation.activitypub.inbox'), 404);
$profile = Profile::whereNull('domain')->whereUsername($username)->firstOrFail(); $headers = $request->headers->all();
if($profile->status != null) { $payload = $request->getContent();
return ProfileController::accountCheck($profile); InboxValidator::dispatch($username, $headers, $payload);
}
$body = $request->getContent();
$bodyDecoded = json_decode($body, true, 8);
if($this->verifySignature($request, $profile) == true) {
InboxWorker::dispatch($request->headers->all(), $profile, $bodyDecoded);
} else if($this->blindKeyRotation($request, $profile) == true) {
InboxWorker::dispatch($request->headers->all(), $profile, $bodyDecoded);
} else {
abort(400, 'Bad Signature');
}
return; return;
} }