-
Notifications
You must be signed in to change notification settings - Fork 0
Release (2026-03-25) #121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Release (2026-03-25) #121
Changes from all commits
5be19a9
d5f9be4
56dcfde
d6f1eb7
3b0b4dc
b1ff761
563b560
d637557
23dfde9
369044f
8685253
dccdc33
5f0b5c1
8752f19
79b29a2
440ce98
044f608
362247e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -4,6 +4,7 @@ | |||||||||
|
|
||||||||||
| use FreedomtechHosting\FtLagoonPhp\Client; | ||||||||||
| use FreedomtechHosting\FtLagoonPhp\Ssh; | ||||||||||
| use Symfony\Component\Process\Process; | ||||||||||
|
|
||||||||||
| class LagoonClientService | ||||||||||
| { | ||||||||||
|
|
@@ -17,12 +18,16 @@ public function getAuthenticatedClient(): Client | |||||||||
| $clientConfig = $this->getClientConfig(); | ||||||||||
|
|
||||||||||
| if (! $clientConfig['ssh_private_key_file'] || ! file_exists($clientConfig['ssh_private_key_file'])) { | ||||||||||
| throw new \Exception('Global SSH private key not found.'); | ||||||||||
| $msg = 'Global SSH private key not found at: '.($clientConfig['ssh_private_key_file'] ?: 'not set'); | ||||||||||
| \Log::error($msg); | ||||||||||
| throw new \Exception($msg); | ||||||||||
| } | ||||||||||
|
|
||||||||||
| $token = $this->getLagoonToken($clientConfig); | ||||||||||
| if (empty($token)) { | ||||||||||
| throw new \Exception('Failed to retrieve Lagoon API token.'); | ||||||||||
| $msg = 'Failed to retrieve Lagoon API token. Ensure the SSH key at '.$clientConfig['ssh_private_key_file'].' is valid and authorized in Lagoon.'; | ||||||||||
| \Log::error($msg); | ||||||||||
| throw new \Exception($msg); | ||||||||||
| } | ||||||||||
|
|
||||||||||
| return $this->buildClientWithToken($clientConfig, $token); | ||||||||||
|
|
@@ -54,12 +59,73 @@ public function getClientConfig(): array | |||||||||
| { | ||||||||||
| $sshConfig = config('polydock.service_providers_singletons.PolydockServiceProviderFTLagoon', []); | ||||||||||
|
|
||||||||||
| // Primary source: config (which reads FTLAGOON_PRIVATE_KEY_FILE) | ||||||||||
| $keyFile = $sshConfig['ssh_private_key_file'] ?? null; | ||||||||||
|
|
||||||||||
| // Fallback to POLYDOCK_LAGOON_DEPLOY_PRIVATE_KEY_FILE if first is missing or default | ||||||||||
| if (empty($keyFile) || $keyFile === 'tests/fixtures/lagoon-private-key') { | ||||||||||
| $keyFile = config('polydock.lagoon_deploy_private_key_file'); | ||||||||||
| } | ||||||||||
|
|
||||||||||
| // Final fallback to system default | ||||||||||
| if (empty($keyFile)) { | ||||||||||
| $home = getenv('HOME'); | ||||||||||
| if ($home === false || $home === '') { | ||||||||||
| $home = $_SERVER['HOME'] ?? null; | ||||||||||
| } | ||||||||||
|
|
||||||||||
| if (! empty($home)) { | ||||||||||
| $keyFile = rtrim($home, '/').'/.ssh/id_rsa'; | ||||||||||
| } else { | ||||||||||
| // Leave $keyFile empty; it will be validated later in getAuthenticatedClient() | ||||||||||
| $keyFile = null; | ||||||||||
| } | ||||||||||
| } | ||||||||||
|
|
||||||||||
| // Fallback or override via content if provided (from config, not env()) | ||||||||||
| $keyContent = config('polydock.ftlagoon_private_key_content'); | ||||||||||
|
Comment on lines
+85
to
+86
|
||||||||||
| // Fallback or override via content if provided (from config, not env()) | |
| $keyContent = config('polydock.ftlagoon_private_key_content'); | |
| // Fallback or override via content if provided (prefer config, then env) | |
| $keyContent = config('polydock.ftlagoon_private_key_content', env('FTLAGOON_PRIVATE_KEY_CONTENT')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These reserved
user-*keys are set on the instance here, but later in this method the genericconfigloop can overwrite them (e.g. a client can passconfig: {"user-email": "other@example.com"}), which would desync claiming/stage-progression data from the provisioning email. Preventconfigfrom setting reserved keys (blacklist/whitelist), or apply theseuser-*keys after processingconfigso they always win.