feat: generate public key from private keys
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use phpseclib3\Crypt\PublicKeyLoader;
|
||||
|
||||
class PrivateKey extends BaseModel
|
||||
{
|
||||
@@ -19,6 +20,15 @@ class PrivateKey extends BaseModel
|
||||
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) {
|
||||
|
||||
Reference in New Issue
Block a user