Feat: Store all keys on disk by default

This commit is contained in:
peaklabs-dev
2024-09-16 18:45:08 +02:00
parent b09017ea46
commit 0bfdc1c531
2 changed files with 5 additions and 13 deletions

View File

@@ -10,7 +10,6 @@ return new class extends Migration
{
public function up()
{
// Empty the SSH keys folder
Storage::disk('ssh-keys')->deleteDirectory('');
Storage::disk('ssh-keys')->makeDirectory('');
@@ -19,7 +18,6 @@ return new class extends Migration
$table->boolean('is_sftp_key')->default(false);
});
// Re-save SSH keys on server only for records with is_server_ssh_key = true
PrivateKey::where('is_server_ssh_key', true)->chunk(100, function ($keys) {
foreach ($keys as $key) {
$key->storeInFileSystem();
@@ -30,8 +28,8 @@ return new class extends Migration
public function down()
{
Schema::table('private_keys', function (Blueprint $table) {
$table->dropColumn('is_sftp_storage_key');
$table->dropColumn('is_server_ssh_key');
$table->dropColumn('is_sftp_key');
});
}
};

View File

@@ -15,7 +15,7 @@ class PrivateKeySeeder extends Seeder
PrivateKey::create([
'id' => 0,
'team_id' => 0,
'name' => 'Testing-host',
'name' => 'Testing Host Key',
'description' => 'This is a test docker container',
'private_key' => '-----BEGIN OPENSSH PRIVATE KEY-----
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW
@@ -25,8 +25,9 @@ AAAECBQw4jg1WRT2IGHMncCiZhURCts2s24HoDS0thHnnRKVuGmoeGq/pojrsyP1pszcNV
uZx9iFkCELtxrh31QJ68AAAAEXNhaWxANzZmZjY2ZDJlMmRkAQIDBA==
-----END OPENSSH PRIVATE KEY-----
',
'is_server_ssh_key' => true,
]);
PrivateKey::create([
'id' => 1,
'team_id' => 0,
@@ -61,12 +62,5 @@ a1C8EDKapCw5hAhizEFOUQKOygL8Ipn+tmEUkORYdZ8Q8cWFCv9nIw==
-----END RSA PRIVATE KEY-----',
'is_git_related' => true,
]);
PrivateKey::create([
'id' => 2,
'team_id' => 0,
'name' => 'development-gitlab-app',
'description' => 'This is the key for using the development Gitlab app',
'private_key' => 'asdf',
]);
}
}