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
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ OPR_EXECUTOR_MAINTENANCE_INTERVAL=60
OPR_EXECUTOR_NETWORK=executor_runtimes
OPR_EXECUTOR_IMAGE=executor-local
OPR_EXECUTOR_SECRET=executor-secret-key
OPR_EXECUTOR_SECRET_PREVIOUS=executor-secret-key-previous
OPR_EXECUTOR_DOCKER_HUB_USERNAME=
OPR_EXECUTOR_DOCKER_HUB_PASSWORD=
OPR_EXECUTOR_RUNTIME_VERSIONS=v2,v5
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ docker compose down
| OPR_EXECUTOR_MAINTENANCE_INTERVAL| Interval (in seconds) at which the Executor performs maintenance tasks, ex: `60` |
| OPR_EXECUTOR_NETWORK | Network used by the executor for runtimes, ex: `openruntimes-runtimes` |
| OPR_EXECUTOR_SECRET | Secret key used by the executor for authentication |
| OPR_EXECUTOR_SECRET_PREVIOUS | Optional second key the executor also accepts, so callers can move to a new `OPR_EXECUTOR_SECRET` without downtime |

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forward the new variable in the README compose example

The Getting Started docker-compose.yml example at lines 50–64 explicitly forwards environment variables but omits OPR_EXECUTOR_SECRET_PREVIOUS. Setting this documented option in the example's .env therefore won't reach the executor, so the second key is not accepted for users following that setup.

Prompt To Fix With AI
This is a comment left during a code review.
Path: README.md
Line: 210

Comment:
**Forward the new variable in the README compose example**

The Getting Started `docker-compose.yml` example at lines 50–64 explicitly forwards environment variables but omits `OPR_EXECUTOR_SECRET_PREVIOUS`. Setting this documented option in the example's `.env` therefore won't reach the executor, so the second key is not accepted for users following that setup.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

🟡 Minor · documentation · Reply if this doesn't apply.

| OPR_EXECUTOR_DOCKER_HUB_USERNAME | Username for Docker Hub authentication (if applicable) |
| OPR_EXECUTOR_DOCKER_HUB_PASSWORD | Password for Docker Hub authentication (if applicable) |
| OPR_EXECUTOR_RUNTIME_VERSIONS | Version tag for runtime environments, ex: `v5` |
Expand Down
9 changes: 8 additions & 1 deletion app/controllers.php
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,14 @@ function (
->inject('request')
->action(function (Request $request): void {
$secretKey = \explode(' ', $request->getHeaderLine('authorization'))[1] ?? '';
if ($secretKey === '' || $secretKey === '0' || $secretKey !== System::getEnv('OPR_EXECUTOR_SECRET', '')) {

// OPR_EXECUTOR_SECRET_PREVIOUS keeps the old secret valid while callers move to a new one.
$accepted = \array_filter(
[System::getEnv('OPR_EXECUTOR_SECRET', ''), System::getEnv('OPR_EXECUTOR_SECRET_PREVIOUS', '')],
fn (string $secret): bool => $secret !== '' && $secret !== '0',
);

if ($secretKey === '' || $secretKey === '0' || \array_filter($accepted, fn (string $secret): bool => \hash_equals($secret, $secretKey)) === []) {
throw new Exception(Exception::GENERAL_UNAUTHORIZED, 'Missing executor key');
}
});
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ services:
- OPR_EXECUTOR_MAINTENANCE_INTERVAL
- OPR_EXECUTOR_NETWORK
- OPR_EXECUTOR_SECRET
- OPR_EXECUTOR_SECRET_PREVIOUS
- OPR_EXECUTOR_DOCKER_HUB_USERNAME
- OPR_EXECUTOR_DOCKER_HUB_PASSWORD
- OPR_EXECUTOR_RUNTIME_VERSIONS
Expand Down
15 changes: 15 additions & 0 deletions tests/e2e/ExecutorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,21 @@ public function testGetRuntimesUnauthorized(): void
$this->client->setKey($this->key);
}

public function testPreviousSecretAuthorizes(): void
{
// docker-compose.yml sets OPR_EXECUTOR_SECRET_PREVIOUS so a rotation can be exercised end to end.
$this->client->setKey('executor-secret-key-previous');
$response = $this->client->call(Client::METHOD_GET, '/runtimes', [], []);
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertIsArray($response['body']);

$this->client->setKey('executor-secret-key-unknown');
$response = $this->client->call(Client::METHOD_GET, '/runtimes', [], []);
$this->assertEquals(401, $response['headers']['status-code']);

$this->client->setKey($this->key);
}

public function testCommandsUnauthorized(): void
{
$this->client->setKey('');
Expand Down
Loading