feat: generate public key from private keys
This commit is contained in:
parent
fda4ea8cca
commit
02f6673345
@ -135,7 +135,7 @@ public function setPrivateKey(string $type)
|
||||
{
|
||||
$this->selectedExistingPrivateKey = null;
|
||||
$this->privateKeyType = $type;
|
||||
if ($type === 'create' && !isDev()) {
|
||||
if ($type === 'create') {
|
||||
$this->createNewPrivateKey();
|
||||
}
|
||||
$this->currentState = 'create-private-key';
|
||||
|
@ -8,7 +8,7 @@
|
||||
class Change extends Component
|
||||
{
|
||||
public PrivateKey $private_key;
|
||||
|
||||
public $public_key;
|
||||
protected $rules = [
|
||||
'private_key.name' => 'required|string',
|
||||
'private_key.description' => 'nullable|string',
|
||||
@ -21,6 +21,14 @@ class Change extends Component
|
||||
'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()
|
||||
{
|
||||
try {
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use phpseclib3\Crypt\PublicKeyLoader;
|
||||
|
||||
class PrivateKey extends BaseModel
|
||||
{
|
||||
@ -19,6 +20,15 @@ static public function ownedByCurrentTeam(array $select = ['*'])
|
||||
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()
|
||||
{
|
||||
if ($this->servers()->count() === 0 && $this->applications()->count() === 0 && $this->githubApps()->count() === 0 && $this->gitlabApps()->count() === 0) {
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
// The release version of your application
|
||||
// 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'),
|
||||
// When left empty or `null` the Laravel environment will be used
|
||||
'environment' => config('app.env'),
|
||||
|
@ -1,3 +1,3 @@
|
||||
<?php
|
||||
|
||||
return '4.0.0-beta.32';
|
||||
return '4.0.0-beta.33';
|
||||
|
@ -114,7 +114,7 @@
|
||||
label="Description" id="privateKeyDescription" />
|
||||
<x-forms.textarea required placeholder="-----BEGIN OPENSSH PRIVATE KEY-----" label="Private Key"
|
||||
id="privateKey" />
|
||||
@if ($privateKeyType === 'create' && !isDev())
|
||||
@if ($privateKeyType === 'create')
|
||||
<span class="font-bold text-warning">Copy this to your server's ~/.ssh/authorized_keys
|
||||
file.</span>
|
||||
<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.description" label="Description" />
|
||||
<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="pl-1 ">Private Key <span class='text-helper'>*</span></div>
|
||||
<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 />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
|
@ -4,7 +4,7 @@
|
||||
"version": "3.12.36"
|
||||
},
|
||||
"v4": {
|
||||
"version": "4.0.0-beta.32"
|
||||
"version": "4.0.0-beta.33"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user