Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions src/Concerns/ProvidesConcurrencySupport.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

use Laravel\Octane\Contracts\DispatchesTasks;
use Laravel\Octane\SequentialTaskDispatcher;
use Laravel\Octane\Swoole\ServerStateFile;
use Laravel\Octane\Swoole\SwooleHttpTaskDispatcher;
use Laravel\Octane\Swoole\SwooleTaskDispatcher;
use Swoole\Http\Server;

Expand Down Expand Up @@ -40,11 +38,6 @@ public function tasks()
return match (true) {
app()->bound(DispatchesTasks::class) => app(DispatchesTasks::class),
app()->bound(Server::class) => new SwooleTaskDispatcher,
class_exists(Server::class) => (fn (array $serverState) => new SwooleHttpTaskDispatcher(
$serverState['state']['host'] ?? '127.0.0.1',
$serverState['state']['port'] ?? '8000',
new SequentialTaskDispatcher
))(app(ServerStateFile::class)->read()),
default => new SequentialTaskDispatcher,
};
}
Expand Down
45 changes: 0 additions & 45 deletions src/OctaneServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,14 @@

namespace Laravel\Octane;

use Illuminate\Contracts\Encryption\DecryptException;
use Illuminate\Contracts\Events\Dispatcher;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Crypt;
use Illuminate\Support\Facades\Event;
use Illuminate\Support\ServiceProvider;
use Laravel\Octane\Cache\OctaneArrayStore;
use Laravel\Octane\Cache\OctaneStore;
use Laravel\Octane\Contracts\DispatchesCoroutines;
use Laravel\Octane\Events\TickReceived;
use Laravel\Octane\Exceptions\DdException;
use Laravel\Octane\Exceptions\TaskException;
use Laravel\Octane\Exceptions\TaskTimeoutException;
use Laravel\Octane\Facades\Octane as OctaneFacade;
use Laravel\Octane\FrankenPhp\ServerProcessInspector as FrankenPhpServerProcessInspector;
use Laravel\Octane\FrankenPhp\ServerStateFile as FrankenPhpServerStateFile;
use Laravel\Octane\RoadRunner\ServerProcessInspector as RoadRunnerServerProcessInspector;
Expand All @@ -27,7 +19,6 @@
use Laravel\Octane\Swoole\ServerStateFile as SwooleServerStateFile;
use Laravel\Octane\Swoole\SignalDispatcher;
use Laravel\Octane\Swoole\SwooleCoroutineDispatcher;
use Laravel\Octane\Swoole\SwooleTaskDispatcher;

class OctaneServiceProvider extends ServiceProvider
{
Expand Down Expand Up @@ -183,7 +174,6 @@ public function boot()

$this->registerCacheDriver();
$this->registerCommands();
$this->registerHttpTaskHandlingRoutes();
$this->registerPublishing();
$this->registerLivewireCoroutineMutex();
}
Expand Down Expand Up @@ -290,41 +280,6 @@ protected function registerCommands()
}
}

/**
* Register the Octane routes that handle tasks from invokers not in a Server context.
*
* @return void
*/
protected function registerHttpTaskHandlingRoutes()
{
OctaneFacade::route('POST', '/octane/resolve-tasks', function (Request $request) {
try {
return new Response(serialize((new SwooleTaskDispatcher)->resolve(
unserialize(Crypt::decryptString($request->input('tasks'))),
$request->input('wait')
)), 200);
} catch (DecryptException) {
return new Response('', 403);
} catch (TaskException|DdException) {
return new Response('', 500);
} catch (TaskTimeoutException) {
return new Response('', 504);
}
});

OctaneFacade::route('POST', '/octane/dispatch-tasks', function (Request $request) {
try {
(new SwooleTaskDispatcher)->dispatch(
unserialize(Crypt::decryptString($request->input('tasks'))),
);
} catch (DecryptException) {
return new Response('', 403);
}

return new Response('', 200);
});
}

/**
* Register Octane's publishing.
*
Expand Down
78 changes: 0 additions & 78 deletions src/Swoole/SwooleHttpTaskDispatcher.php

This file was deleted.

29 changes: 29 additions & 0 deletions tests/Unit/NoHttpTaskRoutesTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

namespace Tests\Unit;

use Laravel\Octane\Facades\Octane;
use Laravel\Octane\SequentialTaskDispatcher;
use Tests\TestCase;

/**
* Octane used to register POST /octane/resolve-tasks and /octane/dispatch-tasks, which ran
* unserialize(Crypt::decryptString(input)). Anyone holding APP_KEY could run code through
* them, and in Nov 2026 attackers did, with a key leaked through git. They must not exist.
*/
class NoHttpTaskRoutesTest extends TestCase
{
public function test_the_task_routes_are_not_registered(): void
{
foreach (['/octane/resolve-tasks', '/octane/dispatch-tasks'] as $uri) {
$this->assertFalse(Octane::hasRouteFor('POST', $uri), $uri.' must not be routable');
$this->assertFalse(Octane::hasRouteFor('GET', $uri), $uri.' must not be routable');
}
}

public function test_tasks_outside_a_server_run_inline(): void
{
$this->assertInstanceOf(SequentialTaskDispatcher::class, Octane::tasks());
$this->assertSame([2, 3], Octane::concurrently([fn () => 1 + 1, fn () => 1 + 2]));
}
}
Loading