Merge pull request #1218 from coollabsio/next
feat: generate public key from private keys
This commit is contained in:
@@ -135,7 +135,7 @@ uZx9iFkCELtxrh31QJ68AAAAEXNhaWxANzZmZjY2ZDJlMmRkAQIDBA==
|
|||||||
{
|
{
|
||||||
$this->selectedExistingPrivateKey = null;
|
$this->selectedExistingPrivateKey = null;
|
||||||
$this->privateKeyType = $type;
|
$this->privateKeyType = $type;
|
||||||
if ($type === 'create' && !isDev()) {
|
if ($type === 'create') {
|
||||||
$this->createNewPrivateKey();
|
$this->createNewPrivateKey();
|
||||||
}
|
}
|
||||||
$this->currentState = 'create-private-key';
|
$this->currentState = 'create-private-key';
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ use Livewire\Component;
|
|||||||
class Change extends Component
|
class Change extends Component
|
||||||
{
|
{
|
||||||
public PrivateKey $private_key;
|
public PrivateKey $private_key;
|
||||||
|
public $public_key;
|
||||||
protected $rules = [
|
protected $rules = [
|
||||||
'private_key.name' => 'required|string',
|
'private_key.name' => 'required|string',
|
||||||
'private_key.description' => 'nullable|string',
|
'private_key.description' => 'nullable|string',
|
||||||
@@ -21,6 +21,14 @@ class Change extends Component
|
|||||||
'private_key.private_key' => 'private key'
|
'private_key.private_key' => 'private key'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
public function mount()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$this->public_key = $this->private_key->publicKey();
|
||||||
|
}catch(\Exception $e) {
|
||||||
|
return general_error_handler(err: $e, that: $this);
|
||||||
|
}
|
||||||
|
}
|
||||||
public function delete()
|
public function delete()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
|
use phpseclib3\Crypt\PublicKeyLoader;
|
||||||
|
|
||||||
class PrivateKey extends BaseModel
|
class PrivateKey extends BaseModel
|
||||||
{
|
{
|
||||||
@@ -19,6 +20,15 @@ class PrivateKey extends BaseModel
|
|||||||
return PrivateKey::whereTeamId(currentTeam()->id)->select($selectArray->all());
|
return PrivateKey::whereTeamId(currentTeam()->id)->select($selectArray->all());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function publicKey()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
return PublicKeyLoader::load($this->private_key)->getPublicKey()->toString('OpenSSH',['comment' => '']);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
return 'Error loading private key';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function isEmpty()
|
public function isEmpty()
|
||||||
{
|
{
|
||||||
if ($this->servers()->count() === 0 && $this->applications()->count() === 0 && $this->githubApps()->count() === 0 && $this->gitlabApps()->count() === 0) {
|
if ($this->servers()->count() === 0 && $this->applications()->count() === 0 && $this->githubApps()->count() === 0 && $this->gitlabApps()->count() === 0) {
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ return [
|
|||||||
|
|
||||||
// The release version of your application
|
// The release version of your application
|
||||||
// Example with dynamic git hash: trim(exec('git --git-dir ' . base_path('.git') . ' log --pretty="%h" -n1 HEAD'))
|
// Example with dynamic git hash: trim(exec('git --git-dir ' . base_path('.git') . ' log --pretty="%h" -n1 HEAD'))
|
||||||
'release' => '4.0.0-beta.32',
|
'release' => '4.0.0-beta.33',
|
||||||
'server_name' => env('APP_ID', 'coolify'),
|
'server_name' => env('APP_ID', 'coolify'),
|
||||||
// When left empty or `null` the Laravel environment will be used
|
// When left empty or `null` the Laravel environment will be used
|
||||||
'environment' => config('app.env'),
|
'environment' => config('app.env'),
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
return '4.0.0-beta.32';
|
return '4.0.0-beta.33';
|
||||||
|
|||||||
@@ -114,7 +114,7 @@
|
|||||||
label="Description" id="privateKeyDescription" />
|
label="Description" id="privateKeyDescription" />
|
||||||
<x-forms.textarea required placeholder="-----BEGIN OPENSSH PRIVATE KEY-----" label="Private Key"
|
<x-forms.textarea required placeholder="-----BEGIN OPENSSH PRIVATE KEY-----" label="Private Key"
|
||||||
id="privateKey" />
|
id="privateKey" />
|
||||||
@if ($privateKeyType === 'create' && !isDev())
|
@if ($privateKeyType === 'create')
|
||||||
<span class="font-bold text-warning">Copy this to your server's ~/.ssh/authorized_keys
|
<span class="font-bold text-warning">Copy this to your server's ~/.ssh/authorized_keys
|
||||||
file.</span>
|
file.</span>
|
||||||
<x-forms.textarea rows="7" readonly label="Public Key" id="publicKey" />
|
<x-forms.textarea rows="7" readonly label="Public Key" id="publicKey" />
|
||||||
|
|||||||
@@ -19,6 +19,10 @@
|
|||||||
<x-forms.input id="private_key.name" label="Name" required />
|
<x-forms.input id="private_key.name" label="Name" required />
|
||||||
<x-forms.input id="private_key.description" label="Description" />
|
<x-forms.input id="private_key.description" label="Description" />
|
||||||
<div>
|
<div>
|
||||||
|
<div class="flex items-end gap-2 py-2 ">
|
||||||
|
<div class="pl-1 ">Public Key</div>
|
||||||
|
</div>
|
||||||
|
<x-forms.input readonly id="public_key" />
|
||||||
<div class="flex items-end gap-2 py-2 ">
|
<div class="flex items-end gap-2 py-2 ">
|
||||||
<div class="pl-1 ">Private Key <span class='text-helper'>*</span></div>
|
<div class="pl-1 ">Private Key <span class='text-helper'>*</span></div>
|
||||||
<div class="text-xs text-white underline cursor-pointer" x-cloak x-show="!showPrivateKey"
|
<div class="text-xs text-white underline cursor-pointer" x-cloak x-show="!showPrivateKey"
|
||||||
@@ -43,5 +47,6 @@
|
|||||||
<x-forms.textarea rows="10" id="private_key.private_key" required />
|
<x-forms.textarea rows="10" id="private_key.private_key" required />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
"version": "3.12.36"
|
"version": "3.12.36"
|
||||||
},
|
},
|
||||||
"v4": {
|
"v4": {
|
||||||
"version": "4.0.0-beta.32"
|
"version": "4.0.0-beta.33"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user