Feat: new ssh key file name on disk
This commit is contained in:
@@ -31,7 +31,6 @@ class PrivateKey extends BaseModel
|
|||||||
'name',
|
'name',
|
||||||
'description',
|
'description',
|
||||||
'private_key',
|
'private_key',
|
||||||
'fingerprint',
|
|
||||||
'is_git_related',
|
'is_git_related',
|
||||||
'team_id',
|
'team_id',
|
||||||
];
|
];
|
||||||
@@ -50,8 +49,6 @@ class PrivateKey extends BaseModel
|
|||||||
'private_key' => ['The private key is invalid.'],
|
'private_key' => ['The private key is invalid.'],
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$key->fingerprint = self::generateFingerprint($key->private_key);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
static::deleted(function ($key) {
|
static::deleted(function ($key) {
|
||||||
@@ -86,12 +83,6 @@ class PrivateKey extends BaseModel
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function generateFingerprint($privateKey)
|
|
||||||
{
|
|
||||||
$key = PublicKeyLoader::load($privateKey);
|
|
||||||
return $key->getPublicKey()->getFingerprint('sha256');
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function createAndStore(array $data)
|
public static function createAndStore(array $data)
|
||||||
{
|
{
|
||||||
$privateKey = new self($data);
|
$privateKey = new self($data);
|
||||||
@@ -143,20 +134,20 @@ class PrivateKey extends BaseModel
|
|||||||
|
|
||||||
public function storeInFileSystem()
|
public function storeInFileSystem()
|
||||||
{
|
{
|
||||||
$filename = "id_rsa@{$this->uuid}";
|
$filename = "ssh@{$this->uuid}";
|
||||||
Storage::disk('ssh-keys')->put($filename, $this->private_key);
|
Storage::disk('ssh-keys')->put($filename, $this->private_key);
|
||||||
return "/var/www/html/storage/app/ssh/keys/{$filename}";
|
return "/var/www/html/storage/app/ssh/keys/{$filename}";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function deleteFromStorage(self $privateKey)
|
public static function deleteFromStorage(self $privateKey)
|
||||||
{
|
{
|
||||||
$filename = "id_rsa@{$privateKey->uuid}";
|
$filename = "ssh@{$privateKey->uuid}";
|
||||||
Storage::disk('ssh-keys')->delete($filename);
|
Storage::disk('ssh-keys')->delete($filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getKeyLocation()
|
public function getKeyLocation()
|
||||||
{
|
{
|
||||||
return "/var/www/html/storage/app/ssh/keys/id_rsa@{$this->uuid}";
|
return "/var/www/html/storage/app/ssh/keys/ssh@{$this->uuid}";
|
||||||
}
|
}
|
||||||
|
|
||||||
public function updatePrivateKey(array $data)
|
public function updatePrivateKey(array $data)
|
||||||
|
|||||||
Reference in New Issue
Block a user