forked from mirror/pixelfed
Add preliminary Authorize Interaction support
This commit is contained in:
parent
ebf989a943
commit
4ca7c6c328
|
@ -0,0 +1,37 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Util\ActivityPub\Helpers;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class AuthorizeInteractionController extends Controller
|
||||||
|
{
|
||||||
|
public function get(Request $request)
|
||||||
|
{
|
||||||
|
$request->validate([
|
||||||
|
'uri' => 'required|url',
|
||||||
|
]);
|
||||||
|
|
||||||
|
abort_unless((bool) config_cache('federation.activitypub.enabled'), 404);
|
||||||
|
|
||||||
|
$uri = Helpers::validateUrl($request->input('uri'), true);
|
||||||
|
abort_unless($uri, 404);
|
||||||
|
|
||||||
|
if (! $request->user()) {
|
||||||
|
return redirect('/login?next='.urlencode($uri));
|
||||||
|
}
|
||||||
|
|
||||||
|
$status = Helpers::statusFetch($uri);
|
||||||
|
if ($status && isset($status['id'])) {
|
||||||
|
return redirect('/i/web/post/'.$status['id']);
|
||||||
|
}
|
||||||
|
|
||||||
|
$profile = Helpers::profileFetch($uri);
|
||||||
|
if ($profile && isset($profile['id'])) {
|
||||||
|
return redirect('/i/web/profile/'.$profile['id']);
|
||||||
|
}
|
||||||
|
|
||||||
|
return redirect('/i/web');
|
||||||
|
}
|
||||||
|
}
|
|
@ -66,6 +66,10 @@ class FederationController extends Controller
|
||||||
'type' => 'application/activity+json',
|
'type' => 'application/activity+json',
|
||||||
'href' => 'https://'.$domain.'/i/actor',
|
'href' => 'https://'.$domain.'/i/actor',
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
'rel' => 'http://ostatus.org/schema/1.0/subscribe',
|
||||||
|
'template' => 'https://'.$domain.'/authorize_interaction?uri={uri}',
|
||||||
|
],
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
@ -83,6 +83,9 @@ class RestrictedNames
|
||||||
'admin',
|
'admin',
|
||||||
'administrator',
|
'administrator',
|
||||||
|
|
||||||
|
// Federation
|
||||||
|
'authorize_interaction',
|
||||||
|
|
||||||
// Static Assets
|
// Static Assets
|
||||||
'assets',
|
'assets',
|
||||||
'public',
|
'public',
|
||||||
|
|
|
@ -5,8 +5,11 @@ namespace App\Util\Webfinger;
|
||||||
class Webfinger
|
class Webfinger
|
||||||
{
|
{
|
||||||
protected $user;
|
protected $user;
|
||||||
|
|
||||||
protected $subject;
|
protected $subject;
|
||||||
|
|
||||||
protected $aliases;
|
protected $aliases;
|
||||||
|
|
||||||
protected $links;
|
protected $links;
|
||||||
|
|
||||||
public function __construct($user)
|
public function __construct($user)
|
||||||
|
@ -49,6 +52,10 @@ class Webfinger
|
||||||
'type' => $avatarType,
|
'type' => $avatarType,
|
||||||
'href' => $avatar,
|
'href' => $avatar,
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
'rel' => 'http://ostatus.org/schema/1.0/subscribe',
|
||||||
|
'template' => 'https://'.config_cache('pixelfed.domain.app').'/authorize_interaction?uri={uri}',
|
||||||
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ Route::domain(config('pixelfed.domain.app'))->middleware(['validemail', 'twofact
|
||||||
Route::redirect('/home', '/')->name('home');
|
Route::redirect('/home', '/')->name('home');
|
||||||
Route::get('web/directory', 'LandingController@directoryRedirect');
|
Route::get('web/directory', 'LandingController@directoryRedirect');
|
||||||
Route::get('web/explore', 'LandingController@exploreRedirect');
|
Route::get('web/explore', 'LandingController@exploreRedirect');
|
||||||
|
Route::get('authorize_interaction', 'AuthorizeInteractionController@get');
|
||||||
|
|
||||||
Auth::routes();
|
Auth::routes();
|
||||||
Route::get('auth/raw/mastodon/start', 'RemoteAuthController@startRedirect');
|
Route::get('auth/raw/mastodon/start', 'RemoteAuthController@startRedirect');
|
||||||
|
@ -67,7 +68,7 @@ Route::domain(config('pixelfed.domain.app'))->middleware(['validemail', 'twofact
|
||||||
Route::get('lang/{locale}', 'SiteController@changeLocale');
|
Route::get('lang/{locale}', 'SiteController@changeLocale');
|
||||||
Route::get('restored', 'AccountController@accountRestored');
|
Route::get('restored', 'AccountController@accountRestored');
|
||||||
|
|
||||||
Route::get('verify-email', 'AccountController@verifyEmail');
|
Route::get('verify-email', 'AccountController@verifyEmail')->name('account.verify_email');
|
||||||
Route::post('verify-email', 'AccountController@sendVerifyEmail');
|
Route::post('verify-email', 'AccountController@sendVerifyEmail');
|
||||||
Route::get('verify-email/request', 'InternalApiController@requestEmailVerification');
|
Route::get('verify-email/request', 'InternalApiController@requestEmailVerification');
|
||||||
Route::post('verify-email/request', 'InternalApiController@requestEmailVerificationStore');
|
Route::post('verify-email/request', 'InternalApiController@requestEmailVerificationStore');
|
||||||
|
|
Loading…
Reference in New Issue