From 65f27d41a2fbf417c2ef3f3fafb7aa27d7aefd2b Mon Sep 17 00:00:00 2001 From: DaneEveritt Date: Sat, 14 May 2022 15:51:05 -0400 Subject: [PATCH] Switch to more recent Laravel route definition methods --- app/Http/Kernel.php | 11 +- app/Providers/RouteServiceProvider.php | 49 ++----- routes/admin.php | 196 +++++++++++++------------ routes/api-application.php | 85 +++++------ routes/api-client.php | 129 ++++++++-------- routes/api-remote.php | 25 ++-- routes/auth.php | 70 +++++---- routes/base.php | 11 +- routes/server.php | 10 -- 9 files changed, 278 insertions(+), 308 deletions(-) delete mode 100644 routes/server.php diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php index cf7b4a8d3..ea4346aef 100644 --- a/app/Http/Kernel.php +++ b/app/Http/Kernel.php @@ -2,9 +2,9 @@ namespace Pterodactyl\Http; -use Illuminate\Http\Middleware\TrustProxies; use Pterodactyl\Models\ApiKey; use Illuminate\Auth\Middleware\Authorize; +use Illuminate\Http\Middleware\TrustProxies; use Illuminate\Auth\Middleware\Authenticate; use Pterodactyl\Http\Middleware\TrimStrings; use Illuminate\Session\Middleware\StartSession; @@ -72,21 +72,18 @@ class Kernel extends HttpKernel IsValidJson::class, StartSession::class, AuthenticateSession::class, + VerifyCsrfToken::class, + ], + 'application-api' => [ ApiSubstituteBindings::class, 'api..key:' . ApiKey::TYPE_APPLICATION, AuthenticateApplicationUser::class, - VerifyCsrfToken::class, AuthenticateIPAccess::class, ], 'client-api' => [ - HandleStatelessRequest::class, - IsValidJson::class, - StartSession::class, - AuthenticateSession::class, SubstituteClientApiBindings::class, 'api..key:' . ApiKey::TYPE_ACCOUNT, AuthenticateIPAccess::class, - VerifyCsrfToken::class, // This is perhaps a little backwards with the Client API, but logically you'd be unable // to create/get an API key without first enabling 2FA on the account, so I suppose in the // end it makes sense. diff --git a/app/Providers/RouteServiceProvider.php b/app/Providers/RouteServiceProvider.php index 2dedacb4a..0ccebcc64 100644 --- a/app/Providers/RouteServiceProvider.php +++ b/app/Providers/RouteServiceProvider.php @@ -10,15 +10,6 @@ use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvi class RouteServiceProvider extends ServiceProvider { - /** - * This namespace is applied to the controller routes in your routes file. - * - * In addition, it is set as the URL generator's root namespace. - * - * @var string - */ - protected $namespace = 'Pterodactyl\Http\Controllers'; - /** * Define your route model bindings, pattern filters, etc. */ @@ -27,35 +18,23 @@ class RouteServiceProvider extends ServiceProvider $this->configureRateLimiting(); $this->routes(function () { - Route::middleware(['web', 'auth', 'csrf']) - ->namespace("$this->namespace\\Base") - ->group(base_path('routes/base.php')); + Route::middleware(['web', 'csrf'])->group(function () { + Route::middleware('auth')->group(base_path('routes/base.php')); + Route::middleware('guest')->prefix('/auth')->group(base_path('routes/auth.php')); + Route::middleware(['auth', 'admin'])->prefix('/admin')->group(base_path('routes/admin.php')); + }); - Route::middleware(['web', 'auth', 'admin', 'csrf'])->prefix('/admin') - ->namespace("$this->namespace\\Admin") - ->group(base_path('routes/admin.php')); + Route::middleware('api')->group(function () { + Route::middleware(['application-api', 'throttle:api.application']) + ->prefix('/api/application') + ->group(base_path('routes/api-application.php')); - Route::middleware(['web', 'csrf'])->prefix('/auth') - ->namespace("$this->namespace\\Auth") - ->group(base_path('routes/auth.php')); + Route::middleware(['client-api', 'throttle:api.client']) + ->prefix('/api/client') + ->group(base_path('routes/api-client.php')); + }); - Route::middleware(['web', 'csrf', 'auth', 'server', 'node.maintenance']) - ->prefix('/api/server/{server}') - ->namespace("$this->namespace\\Server") - ->group(base_path('routes/server.php')); - - Route::middleware(['api', 'throttle:api.application']) - ->prefix('/api/application') - ->namespace("$this->namespace\\Api\\Application") - ->group(base_path('routes/api-application.php')); - - Route::middleware(['client-api', 'throttle:api.client']) - ->prefix('/api/client') - ->namespace("$this->namespace\\Api\\Client") - ->group(base_path('routes/api-client.php')); - - Route::middleware(['daemon'])->prefix('/api/remote') - ->namespace("$this->namespace\\Api\\Remote") + Route::middleware('daemon')->prefix('/api/remote') ->group(base_path('routes/api-remote.php')); }); } diff --git a/routes/admin.php b/routes/admin.php index fb45e6294..d89ae51db 100644 --- a/routes/admin.php +++ b/routes/admin.php @@ -1,9 +1,10 @@ name('admin.index'); +Route::get('/', [Admin\BaseController::class, 'index'])->name('admin.index'); /* |-------------------------------------------------------------------------- @@ -14,12 +15,12 @@ Route::get('/', 'BaseController@index')->name('admin.index'); | */ Route::group(['prefix' => 'api'], function () { - Route::get('/', 'ApiController@index')->name('admin.api.index'); - Route::get('/new', 'ApiController@create')->name('admin.api.new'); + Route::get('/', [Admin\ApiController::class, 'index'])->name('admin.api.index'); + Route::get('/new', [Admin\ApiController::class, 'create'])->name('admin.api.new'); - Route::post('/new', 'ApiController@store'); + Route::post('/new', [Admin\ApiController::class, 'store']); - Route::delete('/revoke/{identifier}', 'ApiController@delete')->name('admin.api.delete'); + Route::delete('/revoke/{identifier}', [Admin\ApiController::class, 'delete'])->name('admin.api.delete'); }); /* @@ -31,11 +32,11 @@ Route::group(['prefix' => 'api'], function () { | */ Route::group(['prefix' => 'locations'], function () { - Route::get('/', 'LocationController@index')->name('admin.locations'); - Route::get('/view/{location}', 'LocationController@view')->name('admin.locations.view'); + Route::get('/', [Admin\LocationController::class, 'index'])->name('admin.locations'); + Route::get('/view/{location}', [Admin\LocationController::class, 'view'])->name('admin.locations.view'); - Route::post('/', 'LocationController@create'); - Route::patch('/view/{location}', 'LocationController@update'); + Route::post('/', [Admin\LocationController::class, 'create']); + Route::patch('/view/{location}', [Admin\LocationController::class, 'update']); }); /* @@ -47,12 +48,12 @@ Route::group(['prefix' => 'locations'], function () { | */ Route::group(['prefix' => 'databases'], function () { - Route::get('/', 'DatabaseController@index')->name('admin.databases'); - Route::get('/view/{host}', 'DatabaseController@view')->name('admin.databases.view'); + Route::get('/', [Admin\DatabaseController::class, 'index'])->name('admin.databases'); + Route::get('/view/{host}', [Admin\DatabaseController::class, 'view'])->name('admin.databases.view'); - Route::post('/', 'DatabaseController@create'); - Route::patch('/view/{host}', 'DatabaseController@update'); - Route::delete('/view/{host}', 'DatabaseController@delete'); + Route::post('/', [Admin\DatabaseController::class, 'create']); + Route::patch('/view/{host}', [Admin\DatabaseController::class, 'update']); + Route::delete('/view/{host}', [Admin\DatabaseController::class, 'delete']); }); /* @@ -64,14 +65,15 @@ Route::group(['prefix' => 'databases'], function () { | */ Route::group(['prefix' => 'settings'], function () { - Route::get('/', 'Settings\IndexController@index')->name('admin.settings'); - Route::get('/mail', 'Settings\MailController@index')->name('admin.settings.mail'); - Route::get('/advanced', 'Settings\AdvancedController@index')->name('admin.settings.advanced'); - Route::post('/mail/test', 'Settings\MailController@test')->name('admin.settings.mail.test'); + Route::get('/', [Admin\Settings\IndexController::class, 'index'])->name('admin.settings'); + Route::get('/mail', [Admin\Settings\MailController::class, 'index'])->name('admin.settings.mail'); + Route::get('/advanced', [Admin\Settings\AdvancedController::class, 'index'])->name('admin.settings.advanced'); - Route::patch('/', 'Settings\IndexController@update'); - Route::patch('/mail', 'Settings\MailController@update'); - Route::patch('/advanced', 'Settings\AdvancedController@update'); + Route::post('/mail/test', [Admin\Settings\MailController::class, 'test'])->name('admin.settings.mail.test'); + + Route::patch('/', [Admin\Settings\IndexController::class, 'update']); + Route::patch('/mail', [Admin\Settings\MailController::class, 'update']); + Route::patch('/advanced', [Admin\Settings\AdvancedController::class, 'update']); }); /* @@ -83,15 +85,15 @@ Route::group(['prefix' => 'settings'], function () { | */ Route::group(['prefix' => 'users'], function () { - Route::get('/', 'UserController@index')->name('admin.users'); - Route::get('/accounts.json', 'UserController@json')->name('admin.users.json'); - Route::get('/new', 'UserController@create')->name('admin.users.new'); - Route::get('/view/{user}', 'UserController@view')->name('admin.users.view'); + Route::get('/', [Admin\UserController::class, 'index'])->name('admin.users'); + Route::get('/accounts.json', [Admin\UserController::class, 'json'])->name('admin.users.json'); + Route::get('/new', [Admin\UserController::class, 'create'])->name('admin.users.new'); + Route::get('/view/{user}', [Admin\UserController::class, 'view'])->name('admin.users.view'); - Route::post('/new', 'UserController@store'); - Route::patch('/view/{user}', 'UserController@update'); + Route::post('/new', [Admin\UserController::class, 'store']); - Route::delete('/view/{user}', 'UserController@delete'); + Route::patch('/view/{user}', [Admin\UserController::class, 'update']); + Route::delete('/view/{user}', [Admin\UserController::class, 'delete']); }); /* @@ -103,37 +105,37 @@ Route::group(['prefix' => 'users'], function () { | */ Route::group(['prefix' => 'servers'], function () { - Route::get('/', 'Servers\ServerController@index')->name('admin.servers'); - Route::get('/new', 'Servers\CreateServerController@index')->name('admin.servers.new'); - Route::get('/view/{server}', 'Servers\ServerViewController@index')->name('admin.servers.view'); + Route::get('/', [Admin\Servers\ServerController::class, 'index'])->name('admin.servers'); + Route::get('/new', [Admin\Servers\CreateServerController::class, 'index'])->name('admin.servers.new'); + Route::get('/view/{server}', [Admin\Servers\ServerViewController::class, 'index'])->name('admin.servers.view'); Route::group(['middleware' => [ServerInstalled::class]], function () { - Route::get('/view/{server}/details', 'Servers\ServerViewController@details')->name('admin.servers.view.details'); - Route::get('/view/{server}/build', 'Servers\ServerViewController@build')->name('admin.servers.view.build'); - Route::get('/view/{server}/startup', 'Servers\ServerViewController@startup')->name('admin.servers.view.startup'); - Route::get('/view/{server}/database', 'Servers\ServerViewController@database')->name('admin.servers.view.database'); - Route::get('/view/{server}/mounts', 'Servers\ServerViewController@mounts')->name('admin.servers.view.mounts'); + Route::get('/view/{server}/details', [Admin\Servers\ServerViewController::class, 'details'])->name('admin.servers.view.details'); + Route::get('/view/{server}/build', [Admin\Servers\ServerViewController::class, 'build'])->name('admin.servers.view.build'); + Route::get('/view/{server}/startup', [Admin\Servers\ServerViewController::class, 'startup'])->name('admin.servers.view.startup'); + Route::get('/view/{server}/database', [Admin\Servers\ServerViewController::class, 'database'])->name('admin.servers.view.database'); + Route::get('/view/{server}/mounts', [Admin\Servers\ServerViewController::class, 'mounts'])->name('admin.servers.view.mounts'); }); - Route::get('/view/{server}/manage', 'Servers\ServerViewController@manage')->name('admin.servers.view.manage'); - Route::get('/view/{server}/delete', 'Servers\ServerViewController@delete')->name('admin.servers.view.delete'); + Route::get('/view/{server}/manage', [Admin\Servers\ServerViewController::class, 'manage'])->name('admin.servers.view.manage'); + Route::get('/view/{server}/delete', [Admin\Servers\ServerViewController::class, 'delete'])->name('admin.servers.view.delete'); - Route::post('/new', 'Servers\CreateServerController@store'); - Route::post('/view/{server}/build', 'ServersController@updateBuild'); - Route::post('/view/{server}/startup', 'ServersController@saveStartup'); - Route::post('/view/{server}/database', 'ServersController@newDatabase'); - Route::post('/view/{server}/mounts/{mount}', 'ServersController@addMount')->name('admin.servers.view.mounts.toggle'); - Route::post('/view/{server}/manage/toggle', 'ServersController@toggleInstall')->name('admin.servers.view.manage.toggle'); - Route::post('/view/{server}/manage/suspension', 'ServersController@manageSuspension')->name('admin.servers.view.manage.suspension'); - Route::post('/view/{server}/manage/reinstall', 'ServersController@reinstallServer')->name('admin.servers.view.manage.reinstall'); - Route::post('/view/{server}/manage/transfer', 'Servers\ServerTransferController@transfer')->name('admin.servers.view.manage.transfer'); - Route::post('/view/{server}/delete', 'ServersController@delete'); + Route::post('/new', [Admin\Servers\CreateServerController::class, 'store']); + Route::post('/view/{server}/build', [Admin\ServersController::class, 'updateBuild']); + Route::post('/view/{server}/startup', [Admin\ServersController::class, 'saveStartup']); + Route::post('/view/{server}/database', [Admin\ServersController::class, 'newDatabase']); + Route::post('/view/{server}/mounts/{mount}', [Admin\ServersController::class, 'addMount'])->name('admin.servers.view.mounts.toggle'); + Route::post('/view/{server}/manage/toggle', [Admin\ServersController::class, 'toggleInstall'])->name('admin.servers.view.manage.toggle'); + Route::post('/view/{server}/manage/suspension', [Admin\ServersController::class, 'manageSuspension'])->name('admin.servers.view.manage.suspension'); + Route::post('/view/{server}/manage/reinstall', [Admin\ServersController::class, 'reinstallServer'])->name('admin.servers.view.manage.reinstall'); + Route::post('/view/{server}/manage/transfer', [Admin\Servers\ServerTransferController::class, 'transfer'])->name('admin.servers.view.manage.transfer'); + Route::post('/view/{server}/delete', [Admin\ServersController::class, 'delete']); - Route::patch('/view/{server}/details', 'ServersController@setDetails'); - Route::patch('/view/{server}/database', 'ServersController@resetDatabasePassword'); + Route::patch('/view/{server}/details', [Admin\ServersController::class, 'setDetails']); + Route::patch('/view/{server}/database', [Admin\ServersController::class, 'resetDatabasePassword']); - Route::delete('/view/{server}/database/{database}/delete', 'ServersController@deleteDatabase')->name('admin.servers.view.database.delete'); - Route::delete('/view/{server}/mounts/{mount}', 'ServersController@deleteMount'); + Route::delete('/view/{server}/database/{database}/delete', [Admin\ServersController::class, 'deleteDatabase'])->name('admin.servers.view.database.delete'); + Route::delete('/view/{server}/mounts/{mount}', [Admin\ServersController::class, 'deleteMount']); }); /* @@ -145,26 +147,26 @@ Route::group(['prefix' => 'servers'], function () { | */ Route::group(['prefix' => 'nodes'], function () { - Route::get('/', 'Nodes\NodeController@index')->name('admin.nodes'); - Route::get('/new', 'NodesController@create')->name('admin.nodes.new'); - Route::get('/view/{node}', 'Nodes\NodeViewController@index')->name('admin.nodes.view'); - Route::get('/view/{node}/settings', 'Nodes\NodeViewController@settings')->name('admin.nodes.view.settings'); - Route::get('/view/{node}/configuration', 'Nodes\NodeViewController@configuration')->name('admin.nodes.view.configuration'); - Route::get('/view/{node}/allocation', 'Nodes\NodeViewController@allocations')->name('admin.nodes.view.allocation'); - Route::get('/view/{node}/servers', 'Nodes\NodeViewController@servers')->name('admin.nodes.view.servers'); - Route::get('/view/{node}/system-information', 'Nodes\SystemInformationController'); + Route::get('/', [Admin\Nodes\NodeController::class, 'index'])->name('admin.nodes'); + Route::get('/new', [Admin\NodesController::class, 'create'])->name('admin.nodes.new'); + Route::get('/view/{node}', [Admin\Nodes\NodeViewController::class, 'index'])->name('admin.nodes.view'); + Route::get('/view/{node}/settings', [Admin\Nodes\NodeViewController::class, 'settings'])->name('admin.nodes.view.settings'); + Route::get('/view/{node}/configuration', [Admin\Nodes\NodeViewController::class, 'configuration'])->name('admin.nodes.view.configuration'); + Route::get('/view/{node}/allocation', [Admin\Nodes\NodeViewController::class, 'allocations'])->name('admin.nodes.view.allocation'); + Route::get('/view/{node}/servers', [Admin\Nodes\NodeViewController::class, 'servers'])->name('admin.nodes.view.servers'); + Route::get('/view/{node}/system-information', Admin\Nodes\SystemInformationController::class); - Route::post('/new', 'NodesController@store'); - Route::post('/view/{node}/allocation', 'NodesController@createAllocation'); - Route::post('/view/{node}/allocation/remove', 'NodesController@allocationRemoveBlock')->name('admin.nodes.view.allocation.removeBlock'); - Route::post('/view/{node}/allocation/alias', 'NodesController@allocationSetAlias')->name('admin.nodes.view.allocation.setAlias'); - Route::post('/view/{node}/settings/token', 'NodeAutoDeployController')->name('admin.nodes.view.configuration.token'); + Route::post('/new', [Admin\NodesController::class, 'store']); + Route::post('/view/{node}/allocation', [Admin\NodesController::class, 'createAllocation']); + Route::post('/view/{node}/allocation/remove', [Admin\NodesController::class, 'allocationRemoveBlock'])->name('admin.nodes.view.allocation.removeBlock'); + Route::post('/view/{node}/allocation/alias', [Admin\NodesController::class, 'allocationSetAlias'])->name('admin.nodes.view.allocation.setAlias'); + Route::post('/view/{node}/settings/token', Admin\NodeAutoDeployController::class)->name('admin.nodes.view.configuration.token'); - Route::patch('/view/{node}/settings', 'NodesController@updateSettings'); + Route::patch('/view/{node}/settings', [Admin\NodesController::class, 'updateSettings']); - Route::delete('/view/{node}/delete', 'NodesController@delete')->name('admin.nodes.view.delete'); - Route::delete('/view/{node}/allocation/remove/{allocation}', 'NodesController@allocationRemoveSingle')->name('admin.nodes.view.allocation.removeSingle'); - Route::delete('/view/{node}/allocations', 'NodesController@allocationRemoveMultiple')->name('admin.nodes.view.allocation.removeMultiple'); + Route::delete('/view/{node}/delete', [Admin\NodesController::class, 'delete'])->name('admin.nodes.view.delete'); + Route::delete('/view/{node}/allocation/remove/{allocation}', [Admin\NodesController::class, 'allocationRemoveSingle'])->name('admin.nodes.view.allocation.removeSingle'); + Route::delete('/view/{node}/allocations', [Admin\NodesController::class, 'allocationRemoveMultiple'])->name('admin.nodes.view.allocation.removeMultiple'); }); /* @@ -176,17 +178,17 @@ Route::group(['prefix' => 'nodes'], function () { | */ Route::group(['prefix' => 'mounts'], function () { - Route::get('/', 'MountController@index')->name('admin.mounts'); - Route::get('/view/{mount}', 'MountController@view')->name('admin.mounts.view'); + Route::get('/', [Admin\MountController::class, 'index'])->name('admin.mounts'); + Route::get('/view/{mount}', [Admin\MountController::class, 'view'])->name('admin.mounts.view'); - Route::post('/', 'MountController@create'); - Route::post('/{mount}/eggs', 'MountController@addEggs')->name('admin.mounts.eggs'); - Route::post('/{mount}/nodes', 'MountController@addNodes')->name('admin.mounts.nodes'); + Route::post('/', [Admin\MountController::class, 'create']); + Route::post('/{mount}/eggs', [Admin\MountController::class, 'addEggs'])->name('admin.mounts.eggs'); + Route::post('/{mount}/nodes', [Admin\MountController::class, 'addNodes'])->name('admin.mounts.nodes'); - Route::patch('/view/{mount}', 'MountController@update'); + Route::patch('/view/{mount}', [Admin\MountController::class, 'update']); - Route::delete('/{mount}/eggs/{egg_id}', 'MountController@deleteEgg'); - Route::delete('/{mount}/nodes/{node_id}', 'MountController@deleteNode'); + Route::delete('/{mount}/eggs/{egg_id}', [Admin\MountController::class, 'deleteEgg']); + Route::delete('/{mount}/nodes/{node_id}', [Admin\MountController::class, 'deleteNode']); }); /* @@ -198,28 +200,28 @@ Route::group(['prefix' => 'mounts'], function () { | */ Route::group(['prefix' => 'nests'], function () { - Route::get('/', 'Nests\NestController@index')->name('admin.nests'); - Route::get('/new', 'Nests\NestController@create')->name('admin.nests.new'); - Route::get('/view/{nest}', 'Nests\NestController@view')->name('admin.nests.view'); - Route::get('/egg/new', 'Nests\EggController@create')->name('admin.nests.egg.new'); - Route::get('/egg/{egg}', 'Nests\EggController@view')->name('admin.nests.egg.view'); - Route::get('/egg/{egg}/export', 'Nests\EggShareController@export')->name('admin.nests.egg.export'); - Route::get('/egg/{egg}/variables', 'Nests\EggVariableController@view')->name('admin.nests.egg.variables'); - Route::get('/egg/{egg}/scripts', 'Nests\EggScriptController@index')->name('admin.nests.egg.scripts'); + Route::get('/', [Admin\Nests\NestController::class, 'index'])->name('admin.nests'); + Route::get('/new', [Admin\Nests\NestController::class, 'create'])->name('admin.nests.new'); + Route::get('/view/{nest}', [Admin\Nests\NestController::class, 'view'])->name('admin.nests.view'); + Route::get('/egg/new', [Admin\Nests\EggController::class, 'create'])->name('admin.nests.egg.new'); + Route::get('/egg/{egg}', [Admin\Nests\EggController::class, 'view'])->name('admin.nests.egg.view'); + Route::get('/egg/{egg}/export', [Admin\Nests\EggShareController::class, 'export'])->name('admin.nests.egg.export'); + Route::get('/egg/{egg}/variables', [Admin\Nests\EggVariableController::class, 'view'])->name('admin.nests.egg.variables'); + Route::get('/egg/{egg}/scripts', [Admin\Nests\EggScriptController::class, 'index'])->name('admin.nests.egg.scripts'); - Route::post('/new', 'Nests\NestController@store'); - Route::post('/import', 'Nests\EggShareController@import')->name('admin.nests.egg.import'); - Route::post('/egg/new', 'Nests\EggController@store'); - Route::post('/egg/{egg}/variables', 'Nests\EggVariableController@store'); + Route::post('/new', [Admin\Nests\NestController::class, 'store']); + Route::post('/import', [Admin\Nests\EggShareController::class, 'import'])->name('admin.nests.egg.import'); + Route::post('/egg/new', [Admin\Nests\EggController::class, 'store']); + Route::post('/egg/{egg}/variables', [Admin\Nests\EggVariableController::class, 'store']); - Route::put('/egg/{egg}', 'Nests\EggShareController@update'); + Route::put('/egg/{egg}', [Admin\Nests\EggShareController::class, 'update']); - Route::patch('/view/{nest}', 'Nests\NestController@update'); - Route::patch('/egg/{egg}', 'Nests\EggController@update'); - Route::patch('/egg/{egg}/scripts', 'Nests\EggScriptController@update'); - Route::patch('/egg/{egg}/variables/{variable}', 'Nests\EggVariableController@update')->name('admin.nests.egg.variables.edit'); + Route::patch('/view/{nest}', [Admin\Nests\NestController::class, 'update']); + Route::patch('/egg/{egg}', [Admin\Nests\EggController::class, 'update']); + Route::patch('/egg/{egg}/scripts', [Admin\Nests\EggScriptController::class, 'update']); + Route::patch('/egg/{egg}/variables/{variable}', [Admin\Nests\EggVariableController::class, 'update'])->name('admin.nests.egg.variables.edit'); - Route::delete('/view/{nest}', 'Nests\NestController@destroy'); - Route::delete('/egg/{egg}', 'Nests\EggController@destroy'); - Route::delete('/egg/{egg}/variables/{variable}', 'Nests\EggVariableController@destroy'); + Route::delete('/view/{nest}', [Admin\Nests\NestController::class, 'destroy']); + Route::delete('/egg/{egg}', [Admin\Nests\EggController::class, 'destroy']); + Route::delete('/egg/{egg}/variables/{variable}', [Admin\Nests\EggVariableController::class, 'destroy']); }); diff --git a/routes/api-application.php b/routes/api-application.php index 160f5f8b0..29d3d8aeb 100644 --- a/routes/api-application.php +++ b/routes/api-application.php @@ -1,6 +1,7 @@ '/users'], function () { - Route::get('/', 'Users\UserController@index')->name('api.application.users'); - Route::get('/{user}', 'Users\UserController@view')->name('api.application.users.view'); - Route::get('/external/{external_id}', 'Users\ExternalUserController@index')->name('api.application.users.external'); + Route::get('/', [Application\Users\UserController::class, 'index'])->name('api.application.users'); + Route::get('/{user}', [Application\Users\UserController::class, 'view'])->name('api.application.users.view'); + Route::get('/external/{external_id}', [Application\Users\ExternalUserController::class, 'index'])->name('api.application.users.external'); - Route::post('/', 'Users\UserController@store'); - Route::patch('/{user}', 'Users\UserController@update'); + Route::post('/', [Application\Users\UserController::class, 'store']); + Route::patch('/{user}', [Application\Users\UserController::class, 'update']); - Route::delete('/{user}', 'Users\UserController@delete'); + Route::delete('/{user}', [Application\Users\UserController::class, 'delete']); }); /* @@ -31,20 +32,20 @@ Route::group(['prefix' => '/users'], function () { | */ Route::group(['prefix' => '/nodes'], function () { - Route::get('/', 'Nodes\NodeController@index')->name('api.application.nodes'); - Route::get('/deployable', 'Nodes\NodeDeploymentController'); - Route::get('/{node}', 'Nodes\NodeController@view')->name('api.application.nodes.view'); - Route::get('/{node}/configuration', 'Nodes\NodeConfigurationController'); + Route::get('/', [Application\Nodes\NodeController::class, 'index'])->name('api.application.nodes'); + Route::get('/deployable', Application\Nodes\NodeDeploymentController::class); + Route::get('/{node}', [Application\Nodes\NodeController::class, 'view'])->name('api.application.nodes.view'); + Route::get('/{node}/configuration', Application\Nodes\NodeConfigurationController::class); - Route::post('/', 'Nodes\NodeController@store'); - Route::patch('/{node}', 'Nodes\NodeController@update'); + Route::post('/', [Application\Nodes\NodeController::class, 'store']); + Route::patch('/{node}', [Application\Nodes\NodeController::class, 'update']); - Route::delete('/{node}', 'Nodes\NodeController@delete'); + Route::delete('/{node}', [Application\Nodes\NodeController::class, 'delete']); Route::group(['prefix' => '/{node}/allocations'], function () { - Route::get('/', 'Nodes\AllocationController@index')->name('api.application.allocations'); - Route::post('/', 'Nodes\AllocationController@store'); - Route::delete('/{allocation}', 'Nodes\AllocationController@delete')->name('api.application.allocations.view'); + Route::get('/', [Application\Nodes\AllocationController::class, 'index'])->name('api.application.allocations'); + Route::post('/', [Application\Nodes\AllocationController::class, 'store']); + Route::delete('/{allocation}', [Application\Nodes\AllocationController::class, 'delete'])->name('api.application.allocations.view'); }); }); @@ -57,13 +58,13 @@ Route::group(['prefix' => '/nodes'], function () { | */ Route::group(['prefix' => '/locations'], function () { - Route::get('/', 'Locations\LocationController@index')->name('api.applications.locations'); - Route::get('/{location}', 'Locations\LocationController@view')->name('api.application.locations.view'); + Route::get('/', [Application\Locations\LocationController::class, 'index'])->name('api.applications.locations'); + Route::get('/{location}', [Application\Locations\LocationController::class, 'view'])->name('api.application.locations.view'); - Route::post('/', 'Locations\LocationController@store'); - Route::patch('/{location}', 'Locations\LocationController@update'); + Route::post('/', [Application\Locations\LocationController::class, 'store']); + Route::patch('/{location}', [Application\Locations\LocationController::class, 'update']); - Route::delete('/{location}', 'Locations\LocationController@delete'); + Route::delete('/{location}', [Application\Locations\LocationController::class, 'delete']); }); /* @@ -75,31 +76,31 @@ Route::group(['prefix' => '/locations'], function () { | */ Route::group(['prefix' => '/servers'], function () { - Route::get('/', 'Servers\ServerController@index')->name('api.application.servers'); - Route::get('/{server}', 'Servers\ServerController@view')->name('api.application.servers.view'); - Route::get('/external/{external_id}', 'Servers\ExternalServerController@index')->name('api.application.servers.external'); + Route::get('/', [Application\Servers\ServerController::class, 'index'])->name('api.application.servers'); + Route::get('/{server}', [Application\Servers\ServerController::class, 'view'])->name('api.application.servers.view'); + Route::get('/external/{external_id}', [Application\Servers\ExternalServerController::class, 'index'])->name('api.application.servers.external'); - Route::patch('/{server}/details', 'Servers\ServerDetailsController@details')->name('api.application.servers.details'); - Route::patch('/{server}/build', 'Servers\ServerDetailsController@build')->name('api.application.servers.build'); - Route::patch('/{server}/startup', 'Servers\StartupController@index')->name('api.application.servers.startup'); + Route::patch('/{server}/details', [Application\Servers\ServerDetailsController::class, 'details'])->name('api.application.servers.details'); + Route::patch('/{server}/build', [Application\Servers\ServerDetailsController::class, 'build'])->name('api.application.servers.build'); + Route::patch('/{server}/startup', [Application\Servers\StartupController::class, 'index'])->name('api.application.servers.startup'); - Route::post('/', 'Servers\ServerController@store'); - Route::post('/{server}/suspend', 'Servers\ServerManagementController@suspend')->name('api.application.servers.suspend'); - Route::post('/{server}/unsuspend', 'Servers\ServerManagementController@unsuspend')->name('api.application.servers.unsuspend'); - Route::post('/{server}/reinstall', 'Servers\ServerManagementController@reinstall')->name('api.application.servers.reinstall'); + Route::post('/', [Application\Servers\ServerController::class, 'store']); + Route::post('/{server}/suspend', [Application\Servers\ServerManagementController::class, 'suspend'])->name('api.application.servers.suspend'); + Route::post('/{server}/unsuspend', [Application\Servers\ServerManagementController::class, 'unsuspend'])->name('api.application.servers.unsuspend'); + Route::post('/{server}/reinstall', [Application\Servers\ServerManagementController::class, 'reinstall'])->name('api.application.servers.reinstall'); - Route::delete('/{server}', 'Servers\ServerController@delete'); - Route::delete('/{server}/{force?}', 'Servers\ServerController@delete'); + Route::delete('/{server}', [Application\Servers\ServerController::class, 'delete']); + Route::delete('/{server}/{force?}', [Application\Servers\ServerController::class, 'delete']); // Database Management Endpoint Route::group(['prefix' => '/{server}/databases'], function () { - Route::get('/', 'Servers\DatabaseController@index')->name('api.application.servers.databases'); - Route::get('/{database}', 'Servers\DatabaseController@view')->name('api.application.servers.databases.view'); + Route::get('/', [Application\Servers\DatabaseController::class, 'index'])->name('api.application.servers.databases'); + Route::get('/{database}', [Application\Servers\DatabaseController::class, 'view'])->name('api.application.servers.databases.view'); - Route::post('/', 'Servers\DatabaseController@store'); - Route::post('/{database}/reset-password', 'Servers\DatabaseController@resetPassword'); + Route::post('/', [Application\Servers\DatabaseController::class, 'store']); + Route::post('/{database}/reset-password', [Application\Servers\DatabaseController::class, 'resetPassword']); - Route::delete('/{database}', 'Servers\DatabaseController@delete'); + Route::delete('/{database}', [Application\Servers\DatabaseController::class, 'delete']); }); }); @@ -112,12 +113,12 @@ Route::group(['prefix' => '/servers'], function () { | */ Route::group(['prefix' => '/nests'], function () { - Route::get('/', 'Nests\NestController@index')->name('api.application.nests'); - Route::get('/{nest}', 'Nests\NestController@view')->name('api.application.nests.view'); + Route::get('/', [Application\Nests\NestController::class, 'index'])->name('api.application.nests'); + Route::get('/{nest}', [Application\Nests\NestController::class, 'view'])->name('api.application.nests.view'); // Egg Management Endpoint Route::group(['prefix' => '/{nest}/eggs'], function () { - Route::get('/', 'Nests\EggController@index')->name('api.application.nests.eggs'); - Route::get('/{egg}', 'Nests\EggController@view')->name('api.application.nests.eggs.view'); + Route::get('/', [Application\Nests\EggController::class, 'index'])->name('api.application.nests.eggs'); + Route::get('/{egg}', [Application\Nests\EggController::class, 'view'])->name('api.application.nests.eggs.view'); }); }); diff --git a/routes/api-client.php b/routes/api-client.php index ec4988bc8..572f4505b 100644 --- a/routes/api-client.php +++ b/routes/api-client.php @@ -1,6 +1,7 @@ name('api:client.index'); -Route::get('/permissions', 'ClientController@permissions'); +Route::get('/', [Client\ClientController::class, 'index'])->name('api:client.index'); +Route::get('/permissions', [Client\ClientController::class, 'permissions']); Route::group(['prefix' => '/account'], function () { - Route::get('/', 'AccountController@index')->name('api:client.account')->withoutMiddleware(RequireTwoFactorAuthentication::class); - Route::get('/two-factor', 'TwoFactorController@index')->withoutMiddleware(RequireTwoFactorAuthentication::class); - Route::post('/two-factor', 'TwoFactorController@store')->withoutMiddleware(RequireTwoFactorAuthentication::class); - Route::delete('/two-factor', 'TwoFactorController@delete')->withoutMiddleware(RequireTwoFactorAuthentication::class); + Route::get('/', [Client\AccountController::class, 'index'])->name('api:client.account')->withoutMiddleware(RequireTwoFactorAuthentication::class); + Route::get('/two-factor', [Client\TwoFactorController::class, 'index'])->withoutMiddleware(RequireTwoFactorAuthentication::class); + Route::post('/two-factor', [Client\TwoFactorController::class, 'store'])->withoutMiddleware(RequireTwoFactorAuthentication::class); + Route::delete('/two-factor', [Client\TwoFactorController::class, 'delete'])->withoutMiddleware(RequireTwoFactorAuthentication::class); - Route::put('/email', 'AccountController@updateEmail')->name('api:client.account.update-email'); - Route::put('/password', 'AccountController@updatePassword')->name('api:client.account.update-password'); + Route::put('/email', [Client\AccountController::class, 'updateEmail'])->name('api:client.account.update-email'); + Route::put('/password', [Client\AccountController::class, 'updatePassword'])->name('api:client.account.update-password'); - Route::get('/api-keys', 'ApiKeyController@index'); - Route::post('/api-keys', 'ApiKeyController@store'); - Route::delete('/api-keys/{identifier}', 'ApiKeyController@delete'); + Route::get('/api-keys', [Client\ApiKeyController::class, 'index']); + Route::post('/api-keys', [Client\ApiKeyController::class, 'store']); + Route::delete('/api-keys/{identifier}', [Client\ApiKeyController::class, 'delete']); }); /* @@ -39,83 +40,83 @@ Route::group(['prefix' => '/account'], function () { | */ Route::group(['prefix' => '/servers/{server}', 'middleware' => [AuthenticateServerAccess::class, ResourceBelongsToServer::class]], function () { - Route::get('/', 'Servers\ServerController@index')->name('api:client:server.view'); - Route::get('/websocket', 'Servers\WebsocketController')->name('api:client:server.ws'); - Route::get('/resources', 'Servers\ResourceUtilizationController')->name('api:client:server.resources'); + Route::get('/', [Client\Servers\ServerController::class, 'index'])->name('api:client:server.view'); + Route::get('/websocket', Client\Servers\WebsocketController::class)->name('api:client:server.ws'); + Route::get('/resources', Client\Servers\ResourceUtilizationController::class)->name('api:client:server.resources'); - Route::post('/command', 'Servers\CommandController@index'); - Route::post('/power', 'Servers\PowerController@index'); + Route::post('/command', [Client\Servers\CommandController::class, 'index']); + Route::post('/power', [Client\Servers\PowerController::class, 'index']); Route::group(['prefix' => '/databases'], function () { - Route::get('/', 'Servers\DatabaseController@index'); - Route::post('/', 'Servers\DatabaseController@store'); - Route::post('/{database}/rotate-password', 'Servers\DatabaseController@rotatePassword'); - Route::delete('/{database}', 'Servers\DatabaseController@delete'); + Route::get('/', [Client\Servers\DatabaseController::class, 'index']); + Route::post('/', [Client\Servers\DatabaseController::class, 'store']); + Route::post('/{database}/rotate-password', [Client\Servers\DatabaseController::class, 'rotatePassword']); + Route::delete('/{database}', [Client\Servers\DatabaseController::class, 'delete']); }); Route::group(['prefix' => '/files'], function () { - Route::get('/list', 'Servers\FileController@directory'); - Route::get('/contents', 'Servers\FileController@contents'); - Route::get('/download', 'Servers\FileController@download'); - Route::put('/rename', 'Servers\FileController@rename'); - Route::post('/copy', 'Servers\FileController@copy'); - Route::post('/write', 'Servers\FileController@write'); - Route::post('/compress', 'Servers\FileController@compress'); - Route::post('/decompress', 'Servers\FileController@decompress'); - Route::post('/delete', 'Servers\FileController@delete'); - Route::post('/create-folder', 'Servers\FileController@create'); - Route::post('/chmod', 'Servers\FileController@chmod'); - Route::post('/pull', 'Servers\FileController@pull')->middleware(['throttle:10,5']); - Route::get('/upload', 'Servers\FileUploadController'); + Route::get('/list', [Client\Servers\FileController::class, 'directory']); + Route::get('/contents', [Client\Servers\FileController::class, 'contents']); + Route::get('/download', [Client\Servers\FileController::class, 'download']); + Route::put('/rename', [Client\Servers\FileController::class, 'rename']); + Route::post('/copy', [Client\Servers\FileController::class, 'copy']); + Route::post('/write', [Client\Servers\FileController::class, 'write']); + Route::post('/compress', [Client\Servers\FileController::class, 'compress']); + Route::post('/decompress', [Client\Servers\FileController::class, 'decompress']); + Route::post('/delete', [Client\Servers\FileController::class, 'delete']); + Route::post('/create-folder', [Client\Servers\FileController::class, 'create']); + Route::post('/chmod', [Client\Servers\FileController::class, 'chmod']); + Route::post('/pull', [Client\Servers\FileController::class, 'pull'])->middleware(['throttle:10,5']); + Route::get('/upload', Client\Servers\FileUploadController::class); }); Route::group(['prefix' => '/schedules'], function () { - Route::get('/', 'Servers\ScheduleController@index'); - Route::post('/', 'Servers\ScheduleController@store'); - Route::get('/{schedule}', 'Servers\ScheduleController@view'); - Route::post('/{schedule}', 'Servers\ScheduleController@update'); - Route::post('/{schedule}/execute', 'Servers\ScheduleController@execute'); - Route::delete('/{schedule}', 'Servers\ScheduleController@delete'); + Route::get('/', [Client\Servers\ScheduleController::class, 'index']); + Route::post('/', [Client\Servers\ScheduleController::class, 'store']); + Route::get('/{schedule}', [Client\Servers\ScheduleController::class, 'view']); + Route::post('/{schedule}', [Client\Servers\ScheduleController::class, 'update']); + Route::post('/{schedule}/execute', [Client\Servers\ScheduleController::class, 'execute']); + Route::delete('/{schedule}', [Client\Servers\ScheduleController::class, 'delete']); - Route::post('/{schedule}/tasks', 'Servers\ScheduleTaskController@store'); - Route::post('/{schedule}/tasks/{task}', 'Servers\ScheduleTaskController@update'); - Route::delete('/{schedule}/tasks/{task}', 'Servers\ScheduleTaskController@delete'); + Route::post('/{schedule}/tasks', [Client\Servers\ScheduleTaskController::class, 'store']); + Route::post('/{schedule}/tasks/{task}', [Client\Servers\ScheduleTaskController::class, 'update']); + Route::delete('/{schedule}/tasks/{task}', [Client\Servers\ScheduleTaskController::class, 'delete']); }); Route::group(['prefix' => '/network'], function () { - Route::get('/allocations', 'Servers\NetworkAllocationController@index'); - Route::post('/allocations', 'Servers\NetworkAllocationController@store'); - Route::post('/allocations/{allocation}', 'Servers\NetworkAllocationController@update'); - Route::post('/allocations/{allocation}/primary', 'Servers\NetworkAllocationController@setPrimary'); - Route::delete('/allocations/{allocation}', 'Servers\NetworkAllocationController@delete'); + Route::get('/allocations', [Client\Servers\NetworkAllocationController::class, 'index']); + Route::post('/allocations', [Client\Servers\NetworkAllocationController::class, 'store']); + Route::post('/allocations/{allocation}', [Client\Servers\NetworkAllocationController::class, 'update']); + Route::post('/allocations/{allocation}/primary', [Client\Servers\NetworkAllocationController::class, 'setPrimary']); + Route::delete('/allocations/{allocation}', [Client\Servers\NetworkAllocationController::class, 'delete']); }); Route::group(['prefix' => '/users'], function () { - Route::get('/', 'Servers\SubuserController@index'); - Route::post('/', 'Servers\SubuserController@store'); - Route::get('/{user}', 'Servers\SubuserController@view'); - Route::post('/{user}', 'Servers\SubuserController@update'); - Route::delete('/{user}', 'Servers\SubuserController@delete'); + Route::get('/', [Client\Servers\SubuserController::class, 'index']); + Route::post('/', [Client\Servers\SubuserController::class, 'store']); + Route::get('/{user}', [Client\Servers\SubuserController::class, 'view']); + Route::post('/{user}', [Client\Servers\SubuserController::class, 'update']); + Route::delete('/{user}', [Client\Servers\SubuserController::class, 'delete']); }); Route::group(['prefix' => '/backups'], function () { - Route::get('/', 'Servers\BackupController@index'); - Route::post('/', 'Servers\BackupController@store'); - Route::get('/{backup}', 'Servers\BackupController@view'); - Route::get('/{backup}/download', 'Servers\BackupController@download'); - Route::post('/{backup}/lock', 'Servers\BackupController@toggleLock'); - Route::post('/{backup}/restore', 'Servers\BackupController@restore'); - Route::delete('/{backup}', 'Servers\BackupController@delete'); + Route::get('/', [Client\Servers\BackupController::class, 'index']); + Route::post('/', [Client\Servers\BackupController::class, 'store']); + Route::get('/{backup}', [Client\Servers\BackupController::class, 'view']); + Route::get('/{backup}/download', [Client\Servers\BackupController::class, 'download']); + Route::post('/{backup}/lock', [Client\Servers\BackupController::class, 'toggleLock']); + Route::post('/{backup}/restore', [Client\Servers\BackupController::class, 'restore']); + Route::delete('/{backup}', [Client\Servers\BackupController::class, 'delete']); }); Route::group(['prefix' => '/startup'], function () { - Route::get('/', 'Servers\StartupController@index'); - Route::put('/variable', 'Servers\StartupController@update'); + Route::get('/', [Client\Servers\StartupController::class, 'index']); + Route::put('/variable', [Client\Servers\StartupController::class, 'update']); }); Route::group(['prefix' => '/settings'], function () { - Route::post('/rename', 'Servers\SettingsController@rename'); - Route::post('/reinstall', 'Servers\SettingsController@reinstall'); - Route::put('/docker-image', 'Servers\SettingsController@dockerImage'); + Route::post('/rename', [Client\Servers\SettingsController::class, 'rename']); + Route::post('/reinstall', [Client\Servers\SettingsController::class, 'reinstall']); + Route::put('/docker-image', [Client\Servers\SettingsController::class, 'dockerImage']); }); }); diff --git a/routes/api-remote.php b/routes/api-remote.php index 3d4839324..e6ab18825 100644 --- a/routes/api-remote.php +++ b/routes/api-remote.php @@ -1,25 +1,26 @@ '/servers/{uuid}'], function () { - Route::get('/', 'Servers\ServerDetailsController'); - Route::get('/install', 'Servers\ServerInstallController@index'); - Route::post('/install', 'Servers\ServerInstallController@store'); + Route::get('/', Remote\Servers\ServerDetailsController::class); + Route::get('/install', [Remote\Servers\ServerInstallController::class, 'index']); + Route::post('/install', [Remote\Servers\ServerInstallController::class, 'store']); - Route::post('/archive', 'Servers\ServerTransferController@archive'); - Route::get('/transfer/failure', 'Servers\ServerTransferController@failure'); - Route::get('/transfer/success', 'Servers\ServerTransferController@success'); + Route::post('/archive', [Remote\Servers\ServerTransferController::class, 'archive']); + Route::get('/transfer/failure', [Remote\Servers\ServerTransferController::class, 'failure']); + Route::get('/transfer/success', [Remote\Servers\ServerTransferController::class, 'success']); }); Route::group(['prefix' => '/backups'], function () { - Route::get('/{backup}', 'Backups\BackupRemoteUploadController'); - Route::post('/{backup}', 'Backups\BackupStatusController@index'); - Route::post('/{backup}/restore', 'Backups\BackupStatusController@restore'); + Route::get('/{backup}', Remote\Backups\BackupRemoteUploadController::class); + Route::post('/{backup}', [Remote\Backups\BackupStatusController::class, 'index']); + Route::post('/{backup}/restore', [Remote\Backups\BackupStatusController::class, 'restore']); }); diff --git a/routes/auth.php b/routes/auth.php index 0acd9fded..7d0930f11 100644 --- a/routes/auth.php +++ b/routes/auth.php @@ -1,5 +1,7 @@ 'guest'], function () { - // These routes are defined so that we can continue to reference them programatically. - // They all route to the same controller function which passes off to Vuejs. - Route::get('/login', 'LoginController@index')->name('auth.login'); - Route::get('/password', 'LoginController@index')->name('auth.forgot-password'); - Route::get('/password/reset/{token}', 'LoginController@index')->name('auth.reset'); - // Apply a throttle to authentication action endpoints, in addition to the - // recaptcha endpoints to slow down manual attack spammers even more. 🤷‍ - // - // @see \Pterodactyl\Providers\RouteServiceProvider - Route::middleware(['throttle:authentication'])->group(function () { - // Login endpoints. - Route::post('/login', 'LoginController@login')->middleware('recaptcha'); - Route::post('/login/checkpoint', 'LoginCheckpointController')->name('auth.login-checkpoint'); +// These routes are defined so that we can continue to reference them programatically. +// They all route to the same controller function which passes off to React. +Route::get('/login', [Auth\LoginController::class, 'index'])->name('auth.login'); +Route::get('/password', [Auth\LoginController::class, 'index'])->name('auth.forgot-password'); +Route::get('/password/reset/{token}', [Auth\LoginController::class, 'index'])->name('auth.reset'); - // Forgot password route. A post to this endpoint will trigger an - // email to be sent containing a reset token. - Route::post('/password', 'ForgotPasswordController@sendResetLinkEmail') - ->name('auth.post.forgot-password') - ->middleware('recaptcha'); - }); +// Apply a throttle to authentication action endpoints, in addition to the +// recaptcha endpoints to slow down manual attack spammers even more. 🤷‍ +// +// @see \Pterodactyl\Providers\RouteServiceProvider +Route::middleware(['throttle:authentication'])->group(function () { + // Login endpoints. + Route::post('/login', [Auth\LoginController::class, 'login'])->middleware('recaptcha'); + Route::post('/login/checkpoint', Auth\LoginCheckpointController::class)->name('auth.login-checkpoint'); - // Password reset routes. This endpoint is hit after going through - // the forgot password routes to acquire a token (or after an account - // is created). - Route::post('/password/reset', 'ResetPasswordController')->name('auth.reset-password'); - - // Catch any other combinations of routes and pass them off to the Vuejs component. - Route::fallback('LoginController@index'); + // Forgot password route. A post to this endpoint will trigger an + // email to be sent containing a reset token. + Route::post('/password', [Auth\ForgotPasswordController::class, 'sendResetLinkEmail']) + ->name('auth.post.forgot-password') + ->middleware('recaptcha'); }); -/* -|-------------------------------------------------------------------------- -| Routes Accessible only when logged in -|-------------------------------------------------------------------------- -| -| Endpoint: /auth -| -*/ -Route::post('/logout', 'LoginController@logout')->name('auth.logout')->middleware('auth', 'csrf'); +// Password reset routes. This endpoint is hit after going through +// the forgot password routes to acquire a token (or after an account +// is created). +Route::post('/password/reset', Auth\ResetPasswordController::class)->name('auth.reset-password'); + +// Remove the guest middleware and apply the authenticated middleware to this endpoint +// so it cannot be used unless you're already logged in. +Route::post('/logout', [Auth\LoginController::class, 'logout']) + ->withoutMiddleware('guest') + ->middleware('auth') + ->name('auth.logout'); + +// Catch any other combinations of routes and pass them off to the Vuejs component. +Route::fallback([Auth\LoginController::class, 'index']); diff --git a/routes/base.php b/routes/base.php index 3be62423e..8ca1fbc3a 100644 --- a/routes/base.php +++ b/routes/base.php @@ -1,15 +1,16 @@ name('index')->fallback(); -Route::get('/account', 'IndexController@index') +Route::get('/', [Base\IndexController::class, 'index'])->name('index')->fallback(); +Route::get('/account', [Base\IndexController::class, 'index']) ->withoutMiddleware(RequireTwoFactorAuthentication::class) ->name('account'); -Route::get('/locales/{locale}/{namespace}.json', 'LocaleController') - ->withoutMiddleware(RequireTwoFactorAuthentication::class) +Route::get('/locales/{locale}/{namespace}.json', Base\LocaleController::class) + ->withoutMiddleware(['auth', RequireTwoFactorAuthentication::class]) ->where('namespace', '.*'); -Route::get('/{react}', 'IndexController@index') +Route::get('/{react}', [Base\IndexController::class, 'index']) ->where('react', '^(?!(\/)?(api|auth|admin|daemon)).+'); diff --git a/routes/server.php b/routes/server.php deleted file mode 100644 index fb8c12499..000000000 --- a/routes/server.php +++ /dev/null @@ -1,10 +0,0 @@ -. - * - * This software is licensed under the terms of the MIT license. - * https://opensource.org/licenses/MIT - */ -Route::get('/')->name('server.index'); -Route::get('/console')->name('server.console');